Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 3 additions & 22 deletions .eslintrc.js → .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ module.exports = {
"react-hooks",
"import",
/* testing plugins */
"jest",
"jest-dom",
"testing-library",
],
extends: [
Expand Down Expand Up @@ -89,7 +87,8 @@ module.exports = {
},
],
"@typescript-eslint/no-var-requires": "off",

"@typescript-eslint/consistent-type-imports": "error",
"@typescript-eslint/no-import-type-side-effects": "error",
/* react rules */
"react/display-name": "off",
"react/jsx-curly-brace-presence": ["error", { props: "never" }],
Expand All @@ -116,26 +115,8 @@ module.exports = {
"import/no-unassigned-import": "off",
},
},
{
files: ["**/?(*.)+(test).ts?(x)"],
extends: ["plugin:jest/recommended", "plugin:jest/style"],
rules: {
"jest/expect-expect": [
"warn",
{
assertFunctionNames: ["expect*"],
additionalTestBlockFunctions: [],
},
],
"jest/no-standalone-expect": [
"error",
{ additionalTestBlockFunctions: ["afterEach"] },
],
},
},
{
files: ["test/**/*"],
env: { jest: true },
rules: {
"no-undef": "off",
"@typescript-eslint/no-unused-expressions": "off",
Expand All @@ -144,7 +125,7 @@ module.exports = {
},
{
files: ["**/?(*.)+(test).tsx"],
extends: ["plugin:testing-library/react", "plugin:jest-dom/recommended"],
extends: ["plugin:testing-library/react"],
rules: {
"testing-library/prefer-user-event": "error",
},
Expand Down
9 changes: 0 additions & 9 deletions jest-dist.config.mjs

This file was deleted.

10 changes: 0 additions & 10 deletions jest.config.mjs

This file was deleted.

26 changes: 11 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"url": "https://github.com/Faire/mjml-react/issues"
},
"main": "dist/index.js",
"type": "module",
"types": "dist/index.d.ts",
"directories": {
"test": "test"
Expand All @@ -27,16 +28,15 @@
"access": "public"
},
"scripts": {
"build-dist": "/bin/rm -rf dist && yarn build-cjs && yarn build-esm",
"build-cjs": "tsc -p tsconfig.json",
"build-esm": "tsc -p tsconfig-esm.json",
"build-dist": "/bin/rm -rf dist && yarn build-esm",
"build-esm": "tsc -p tsconfig.json",
"lint": "eslint .",
"format": "prettier --write .",
"test": "node --experimental-vm-modules node_modules/jest/bin/jest.js",
"test-dist-skip-build": "node --experimental-vm-modules node_modules/jest/bin/jest.js --config=jest-dist.config.mjs",
"test": "vitest run",
"test-dist-skip-build": "vitest run --config vitest-dist.config.js",
"test-dist": "yarn build-dist && yarn test-dist-skip-build",
"generate-mjml-react": "ts-node scripts/generate-mjml-react.ts",
"build-mjml-react": "ts-node scripts/build-mjml-react.ts",
"generate-mjml-react": "node scripts/generate-mjml-react.ts",
"build-mjml-react": "node scripts/build-mjml-react.ts",
"prepare": "husky install"
},
"devDependencies": {
Expand All @@ -45,7 +45,6 @@
"@semantic-release/github": "^12.0.0",
"@semantic-release/npm": "^13.1.5",
"@trivago/prettier-plugin-sort-imports": "^3.2.0",
"@types/jest": "^29.5.14",
"@types/lodash.camelcase": "^4.3.9",
"@types/lodash.kebabcase": "^4.1.9",
"@types/lodash.upperfirst": "^4.3.9",
Expand All @@ -55,16 +54,14 @@
"@types/react-dom": "^18.3",
"@typescript-eslint/eslint-plugin": "^8.59.2",
"@typescript-eslint/parser": "^8.59.2",
"@vitejs/plugin-react": "^6.1.1",
"del": "^6.0.0",
"eslint": "^8.57.1",
"eslint-plugin-import": "^2.32.0",
"eslint-plugin-jest": "^29.15.2",
"eslint-plugin-jest-dom": "^5.5.0",
"eslint-plugin-react": "^7.37.5",
"eslint-plugin-react-hooks": "^7.1.1",
"eslint-plugin-testing-library": "^7.16.2",
"husky": "^8.0.0",
"jest": "^29.7.0",
"lodash.camelcase": "^4.3.0",
"lodash.upperfirst": "^4.3.1",
"mjml": "^5.0.1",
Expand All @@ -73,16 +70,15 @@
"react": "^18.3",
"react-dom": "^18.3",
"semantic-release": "^24.0.0",
"ts-jest": "^29.4.9",
"ts-node": "^10.9.2",
"typescript": "5.9.3"
"typescript": "5.9.3",
"vite": "^8.2.2",
"vitest": "^5.0.0"
},
"peerDependencies": {
"mjml": "^5.0.0",
"react": "^16.0.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
"react-dom": "^16.0.0 || ^17.0.0 || ^18.0.0 || ^19.0.0"
},
"module": "dist/esm/index.js",
"dependencies": {
"lodash.kebabcase": "^4.1.1"
},
Expand Down
18 changes: 8 additions & 10 deletions scripts/generate-mjml-react.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
#!/usr/bin/env ts-node

/**
* Generate the mjml components
*
* usage `node --require ts-node/register scripts/generate-mjml-react.ts`
* usage `node scripts/generate-mjml-react.ts`
*/
import * as childProcess from "child_process";
import * as del from "del";
import * as fs from "fs";
import camelCase from "lodash.camelcase";
import upperFirst from "lodash.upperfirst";
// @ts-expect-error - no types available for mjml-preset-core
import * as presetCore from "mjml-preset-core";
import presetCore from "mjml-preset-core";
import * as path from "path";

import { getPropTypeFromMjmlAttributeType } from "./generate-mjml-react-utils/getPropTypeFromMjmlAttributeType";
import { getPropTypeFromMjmlAttributeType } from "./generate-mjml-react-utils/getPropTypeFromMjmlAttributeType.ts";

const MJML_REACT_DIR = "src";

Expand Down Expand Up @@ -182,7 +180,7 @@ ${GENERATED_HEADER_TSX}

import React from "react";

import { convertPropsToMjmlAttributes } from "../${UTILS_FILE}";
import { convertPropsToMjmlAttributes } from "../${UTILS_FILE}/index.ts";

export interface I${reactName}Props {
${types}
Expand Down Expand Up @@ -250,8 +248,8 @@ ${GENERATED_HEADER_TSX}
${MJML_COMPONENTS_TO_GENERATE.map(({ componentName }) => {
const mjmlPackageName = componentName.replace("mj-", "mjml-");
const reactName = upperFirst(camelCase(mjmlPackageName));
return `export { ${reactName} } from './${reactName}';
export type { I${reactName}Props } from './${reactName}';`;
return `export { ${reactName} } from './${reactName}.tsx';
export type { I${reactName}Props } from './${reactName}.tsx';`;
}).join("\n")}
`
);
Expand All @@ -263,8 +261,8 @@ fs.writeFileSync(
`
${GENERATED_HEADER_TSX}

export * from "./${UTILS_FILE}";
export * from "./${MJML_COMPONENTS_FOLDER}";
export * from "./${UTILS_FILE}/index.ts";
export * from "./${MJML_COMPONENTS_FOLDER}/index.tsx";
`
);

Expand Down
10 changes: 5 additions & 5 deletions src/extensions/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export { MjmlComment } from "./mjml-comment";
export { MjmlConditionalComment } from "./mjml-conditional-comment";
export { MjmlYahooStyle } from "./mjml-yahoo-style";
export { MjmlTrackingPixel } from "./mjml-tracking-pixel";
export { MjmlHtml } from "./mjml-html";
export { MjmlComment } from "./mjml-comment.ts";
export { MjmlConditionalComment } from "./mjml-conditional-comment.tsx";
export { MjmlYahooStyle } from "./mjml-yahoo-style.tsx";
export { MjmlTrackingPixel } from "./mjml-tracking-pixel.tsx";
export { MjmlHtml } from "./mjml-html.ts";
2 changes: 1 addition & 1 deletion src/extensions/mjml-comment.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { Component } from "react";

import { convertPropsToMjmlAttributes } from "../utils";
import { convertPropsToMjmlAttributes } from "../utils/index.ts";

export class MjmlComment extends Component<{ children?: React.ReactNode }> {
render() {
Expand Down
2 changes: 1 addition & 1 deletion src/extensions/mjml-conditional-comment.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { Component } from "react";

import { MjmlComment } from "./mjml-comment";
import { MjmlComment } from "./mjml-comment.ts";

interface IMjmlConditionalComment {
children?: React.ReactNode;
Expand Down
2 changes: 1 addition & 1 deletion src/extensions/mjml-tracking-pixel.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { Component } from "react";

import { MjmlRaw } from "..";
import { MjmlRaw } from "../mjml/MjmlRaw.tsx";

interface IMjmlTrackingPixel {
src: string;
Expand Down
2 changes: 1 addition & 1 deletion src/extensions/mjml-yahoo-style.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { Component } from "react";

import { MjmlRaw } from "..";
import { MjmlRaw } from "../mjml/MjmlRaw.tsx";

export class MjmlYahooStyle extends Component<{ children?: React.ReactNode }> {
render() {
Expand Down
4 changes: 2 additions & 2 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
* Modify `scripts/generate-mjml-react.ts` to make changes to these files
*/

export * from "./utils";
export * from "./mjml";
export * from "./utils/index.ts";
export * from "./mjml/index.tsx";
2 changes: 1 addition & 1 deletion src/mjml/Mjml.tsx

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/mjml/MjmlAccordion.tsx

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/mjml/MjmlAccordionElement.tsx

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/mjml/MjmlAccordionText.tsx

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/mjml/MjmlAccordionTitle.tsx

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/mjml/MjmlAll.tsx

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/mjml/MjmlAttributes.tsx

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/mjml/MjmlBody.tsx

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/mjml/MjmlBreakpoint.tsx

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/mjml/MjmlButton.tsx

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/mjml/MjmlCarousel.tsx

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/mjml/MjmlCarouselImage.tsx

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/mjml/MjmlClass.tsx

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/mjml/MjmlColumn.tsx

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/mjml/MjmlDivider.tsx

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading