Skip to content

Commit 1c43385

Browse files
committed
chore: update eslint to v9
1 parent ea8a47d commit 1c43385

5 files changed

Lines changed: 572 additions & 435 deletions

File tree

.eslintignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

.eslintrc.js

Lines changed: 0 additions & 159 deletions
This file was deleted.

eslint.config.mjs

Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
import js from "@eslint/js";
2+
import importPlugin from "eslint-plugin-import";
3+
import jestPlugin from "eslint-plugin-jest";
4+
import jestDomPlugin from "eslint-plugin-jest-dom";
5+
import reactPlugin from "eslint-plugin-react";
6+
import reactHooksPlugin from "eslint-plugin-react-hooks";
7+
import testingLibraryPlugin from "eslint-plugin-testing-library";
8+
import { defineConfig } from "eslint/config";
9+
import tseslint from "typescript-eslint";
10+
11+
export default defineConfig([
12+
{
13+
name: "global ignores",
14+
ignores: ["dist"],
15+
},
16+
{
17+
files: [`**/*.{js,cjs,mjs,ts,tsx,mts}`],
18+
},
19+
js.configs.recommended,
20+
tseslint.configs.recommended,
21+
reactPlugin.configs.flat.recommended,
22+
reactHooksPlugin.configs.flat.recommended,
23+
{
24+
plugins: {
25+
import: importPlugin,
26+
},
27+
},
28+
{
29+
languageOptions: {
30+
parserOptions: {
31+
project: ["./tsconfig-eslint.json"],
32+
},
33+
},
34+
settings: {
35+
react: {
36+
version: "detect",
37+
},
38+
},
39+
},
40+
{
41+
rules: {
42+
complexity: "error",
43+
curly: "error",
44+
eqeqeq: ["error", "smart"],
45+
"no-alert": "error",
46+
"no-console": "error",
47+
"no-prototype-builtins": "off",
48+
"no-unused-vars": "off",
49+
"no-process-env": "error",
50+
51+
/* typescript-eslint rules */
52+
"@typescript-eslint/adjacent-overload-signatures": "off",
53+
"@typescript-eslint/no-restricted-types": [
54+
"error",
55+
{
56+
types: {
57+
IStringTMap: "Prefer Record<string, T>",
58+
},
59+
},
60+
],
61+
"@typescript-eslint/camelcase": "off",
62+
"@typescript-eslint/explicit-function-return-type": "off",
63+
"@typescript-eslint/explicit-member-accessibility": [
64+
"error",
65+
{
66+
accessibility: "no-public",
67+
overrides: { parameterProperties: "explicit" },
68+
},
69+
],
70+
"@typescript-eslint/explicit-module-boundary-types": "off",
71+
"@typescript-eslint/interface-name-prefix": "off",
72+
"@typescript-eslint/no-empty-function": "off",
73+
"@typescript-eslint/no-explicit-any": "off",
74+
"@typescript-eslint/no-inferrable-types": "off",
75+
"@typescript-eslint/no-namespace": "off",
76+
"@typescript-eslint/no-non-null-assertion": "off",
77+
"@typescript-eslint/only-throw-error": "error",
78+
"@typescript-eslint/no-use-before-define": "off",
79+
"@typescript-eslint/no-unused-expressions": [
80+
"error",
81+
{
82+
allowShortCircuit: true,
83+
allowTernary: true,
84+
allowTaggedTemplates: true,
85+
enforceForJSX: true,
86+
},
87+
],
88+
"@typescript-eslint/no-unused-vars": [
89+
"error",
90+
{
91+
argsIgnorePattern: "^_",
92+
ignoreRestSiblings: true,
93+
},
94+
],
95+
"@typescript-eslint/no-var-requires": "off",
96+
97+
/* react rules */
98+
"react/display-name": "off",
99+
"react/jsx-curly-brace-presence": ["error", { props: "never" }],
100+
"react/no-deprecated": "warn",
101+
"react/no-unescaped-entities": ["error", { forbid: [">", "}"] }],
102+
"react/prop-types": "off",
103+
"react/no-danger": "error",
104+
"react/self-closing-comp": "error",
105+
"react/function-component-definition": [
106+
"error",
107+
{
108+
namedComponents: "arrow-function",
109+
},
110+
],
111+
112+
/* import rules */
113+
"import/no-unassigned-import": "error",
114+
"import/order": "off", // Use prettier for import order formatting
115+
},
116+
},
117+
{
118+
files: ["**/?(*.)+(test).ts?(x)"],
119+
extends: [
120+
jestPlugin.configs["flat/recommended"],
121+
jestPlugin.configs["flat/style"],
122+
],
123+
rules: {
124+
"jest/expect-expect": [
125+
"warn",
126+
{
127+
assertFunctionNames: ["expect*"],
128+
additionalTestBlockFunctions: [],
129+
},
130+
],
131+
"jest/no-standalone-expect": [
132+
"error",
133+
{ additionalTestBlockFunctions: ["afterEach"] },
134+
],
135+
},
136+
},
137+
{
138+
files: ["test/**/*"],
139+
languageOptions: {
140+
globals: jestPlugin.environments.globals.globals,
141+
},
142+
rules: {
143+
"no-undef": "off",
144+
"@typescript-eslint/no-unused-expressions": "off",
145+
"react/jsx-curly-brace-presence": "off",
146+
},
147+
},
148+
{
149+
files: ["**/?(*.)+(test).tsx"],
150+
extends: [
151+
testingLibraryPlugin.configs["flat/react"],
152+
jestDomPlugin.configs["flat/recommended"],
153+
],
154+
rules: {
155+
"testing-library/prefer-user-event": "error",
156+
},
157+
},
158+
{
159+
files: ["src/mjml/*"],
160+
rules: {
161+
"react/function-component-definition": "off",
162+
},
163+
},
164+
]);

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"build-dist": "/bin/rm -rf dist && yarn build-cjs && yarn build-esm",
3131
"build-cjs": "tsc -p tsconfig.json",
3232
"build-esm": "tsc -p tsconfig-esm.json",
33-
"lint": "eslint .",
33+
"lint": "eslint",
3434
"format": "prettier --write .",
3535
"test": "node --experimental-vm-modules node_modules/jest/bin/jest.js",
3636
"test-dist-skip-build": "node --experimental-vm-modules node_modules/jest/bin/jest.js --config=jest-dist.config.mjs",
@@ -40,6 +40,7 @@
4040
"prepare": "husky install"
4141
},
4242
"devDependencies": {
43+
"@eslint/js": "^9.39.4",
4344
"@semantic-release/changelog": "^6.0.3",
4445
"@semantic-release/git": "^10.0.1",
4546
"@semantic-release/github": "^12.0.0",
@@ -53,10 +54,8 @@
5354
"@types/node": "^22.19.0",
5455
"@types/react": "^18.3",
5556
"@types/react-dom": "^18.3",
56-
"@typescript-eslint/eslint-plugin": "^8.59.2",
57-
"@typescript-eslint/parser": "^8.59.2",
5857
"del": "^6.0.0",
59-
"eslint": "^8.57.1",
58+
"eslint": "^9.39.4",
6059
"eslint-plugin-import": "^2.32.0",
6160
"eslint-plugin-jest": "^29.15.2",
6261
"eslint-plugin-jest-dom": "^5.5.0",
@@ -75,7 +74,8 @@
7574
"semantic-release": "^24.0.0",
7675
"ts-jest": "^29.4.9",
7776
"ts-node": "^10.9.2",
78-
"typescript": "5.9.3"
77+
"typescript": "5.9.3",
78+
"typescript-eslint": "^8.59.2"
7979
},
8080
"peerDependencies": {
8181
"mjml": "^5.0.0",

0 commit comments

Comments
 (0)