Skip to content

Commit 6353a6d

Browse files
committed
chore: migrate to eslint 9
1 parent a3ec6c0 commit 6353a6d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+2018
-1862
lines changed

.eslintignore

-13
This file was deleted.

.eslintrc.cjs

-3
This file was deleted.

.storybook/main.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type {StorybookConfig} from "@storybook/react-vite";
1+
import type { StorybookConfig } from "@storybook/react-vite";
22

33
const config: StorybookConfig = {
44
staticDirs: ["../packages/tailwind/build"],

.storybook/preview.ts

+10-8
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
1-
import tailwind from '@tsed/tailwind-formio'
2-
import {Formio, Templates} from '@tsed/react-formio'
3-
import {INITIAL_VIEWPORTS} from '@storybook/addon-viewport'
41
import "./styles/index.css";
52

6-
Formio.use(tailwind)
7-
Templates.framework = 'tailwind'
3+
import { INITIAL_VIEWPORTS } from "@storybook/addon-viewport";
4+
import { Formio, Templates } from "@tsed/react-formio";
5+
import tailwind from "@tsed/tailwind-formio";
6+
7+
// eslint-disable-next-line react-hooks/rules-of-hooks
8+
Formio.use(tailwind);
9+
Templates.framework = "tailwind";
810

911
/** @type { import('@storybook/react').Preview } */
1012
const preview = {
1113
parameters: {
12-
actions: {argTypesRegex: '^on[A-Z].*'},
14+
actions: { argTypesRegex: "^on[A-Z].*" },
1315
controls: {
1416
matchers: {
1517
color: /(background|color)$/i,
@@ -20,6 +22,6 @@ const preview = {
2022
viewport: {
2123
viewports: INITIAL_VIEWPORTS
2224
}
23-
}
25+
};
2426

25-
export default preview
27+
export default preview;

eslint.config.mjs

+146
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
import typescriptEslint from "@typescript-eslint/eslint-plugin";
2+
import typescriptParser from "@typescript-eslint/parser";
3+
import pluginJsxA11y from "eslint-plugin-jsx-a11y";
4+
import pluginPrettierRecommended from "eslint-plugin-prettier/recommended";
5+
import pluginReact from "eslint-plugin-react";
6+
import pluginReactHooks from "eslint-plugin-react-hooks";
7+
import pluginSimpleImportSort from "eslint-plugin-simple-import-sort";
8+
import pluginTestingLibrary from "eslint-plugin-testing-library";
9+
// import vitest from "eslint-plugin-vitest";
10+
import pluginWorkspaces from "eslint-plugin-workspaces";
11+
12+
export default [
13+
{
14+
ignores: ["**/coverage", "**/dist/**", "**/build/**", "**/storybook-static", "**/*.ejs.js"]
15+
},
16+
{
17+
files: ["**/*.{js,mjs,cjs,jsx,mjsx,ts,tsx,mtsx}"],
18+
...pluginReact.configs.flat.recommended,
19+
settings: {
20+
react: {
21+
version: "detect"
22+
}
23+
},
24+
languageOptions: {
25+
...pluginReact.configs.flat.recommended.languageOptions
26+
// globals: {
27+
// ...globals.serviceworker,
28+
// ...globals.browser
29+
// }
30+
},
31+
rules: {
32+
...pluginReact.configs.flat.recommended.rules,
33+
"react/no-unescaped-entities": "off",
34+
"react/react-in-jsx-scope": "off",
35+
"react/prop-types": "off",
36+
"react/display-name": "warn"
37+
}
38+
},
39+
{
40+
files: ["**/*.{js,mjs,cjs,jsx,mjsx,ts,tsx,mtsx}"],
41+
languageOptions: {
42+
ecmaVersion: "latest",
43+
sourceType: "module",
44+
parser: typescriptParser,
45+
parserOptions: {
46+
ecmaFeatures: {
47+
jsx: true
48+
},
49+
ecmaVersion: "latest",
50+
sourceType: "module"
51+
}
52+
// globals: {
53+
// ...globals.browser
54+
// }
55+
},
56+
plugins: {
57+
"@typescript-eslint": typescriptEslint
58+
},
59+
rules: {
60+
"@typescript-eslint/no-unused-vars": "error"
61+
}
62+
},
63+
pluginJsxA11y.flatConfigs.recommended,
64+
{
65+
files: ["**/*.{js,mjs,cjs,jsx,mjsx,ts,tsx,mtsx}"],
66+
languageOptions: {
67+
parserOptions: {
68+
ecmaFeatures: {
69+
jsx: true
70+
}
71+
}
72+
},
73+
plugins: {
74+
"react-hooks": pluginReactHooks,
75+
"simple-import-sort": pluginSimpleImportSort,
76+
workspaces: pluginWorkspaces
77+
},
78+
rules: {
79+
"simple-import-sort/imports": "error",
80+
"simple-import-sort/exports": "error",
81+
"workspaces/no-absolute-imports": "error",
82+
"react-hooks/rules-of-hooks": "error", // Checks rules of Hooks
83+
"react-hooks/exhaustive-deps": "warn" // Checks effect dependencies
84+
}
85+
},
86+
// {
87+
// files: ["**/*.spec.{js,mjs,cjs,jsx,mjsx,ts,tsx,mtsx}"],
88+
// plugins: {
89+
// vitest
90+
// },
91+
// rules: {
92+
// ...vitest.configs.recommended.rules
93+
// }
94+
// },
95+
// {
96+
// files: ["**/*.spec.{js,mjs,cjs,jsx,mjsx,ts,tsx,mtsx}"], // or any other pattern
97+
// plugins: {
98+
// vitest
99+
// },
100+
// rules: {
101+
// ...vitest.configs.recommended.rules, // you can also use vitest.configs.all.rules to enable all rules
102+
// "vitest/consistent-test-it": [
103+
// "error",
104+
// { fn: "it", withinDescribe: "it" }
105+
// ],
106+
// "vitest/no-alias-methods": "error"
107+
// }
108+
// },
109+
{
110+
files: ["**/*.spec.{js,mjs,cjs,jsx,mjsx,ts,tsx,mtsx}"],
111+
plugins: {
112+
"testing-library": pluginTestingLibrary
113+
},
114+
rules: {
115+
"testing-library/await-async-events": ["error", { eventModule: "userEvent" }],
116+
"testing-library/await-async-queries": "error",
117+
"testing-library/await-async-utils": "error",
118+
"testing-library/no-await-sync-events": ["error", { eventModules: ["fire-event"] }],
119+
"testing-library/no-await-sync-queries": "error",
120+
"testing-library/no-container": "error",
121+
"testing-library/no-debugging-utils": "warn",
122+
"testing-library/no-dom-import": ["error", "react"],
123+
"testing-library/no-global-regexp-flag-in-query": "error",
124+
"testing-library/no-manual-cleanup": "error",
125+
"testing-library/no-node-access": "warn",
126+
"testing-library/no-promise-in-fire-event": "error",
127+
"testing-library/no-render-in-lifecycle": "error",
128+
"testing-library/no-unnecessary-act": "error",
129+
"testing-library/no-wait-for-multiple-assertions": "error",
130+
"testing-library/no-wait-for-side-effects": "error",
131+
"testing-library/no-wait-for-snapshot": "error",
132+
"testing-library/prefer-find-by": "error",
133+
"testing-library/prefer-presence-queries": "error",
134+
"testing-library/prefer-query-by-disappearance": "error",
135+
"testing-library/prefer-screen-queries": "error",
136+
"testing-library/render-result-naming-convention": "error"
137+
}
138+
},
139+
pluginPrettierRecommended,
140+
{
141+
files: ["**/*.{js,mjs,cjs,jsx,mjsx,ts,tsx,mtsx}"],
142+
rules: {
143+
curly: ["error", "all"]
144+
}
145+
}
146+
];

package.json

+18-21
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,8 @@
1818
"configure": "monorepo ci configure",
1919
"test": "lerna run test --stream",
2020
"test:coverage:update": "lerna run test:coverage:update --stream",
21-
"lint": "lerna run lint --stream",
22-
"lint:fix": "lerna run lint:fix --stream",
23-
"prettier": "prettier '**/*.{ts,js,json,md,yml,yaml}' --write",
21+
"lint": "eslint",
22+
"lint:fix": "eslint",
2423
"build": "monorepo build --verbose",
2524
"publish": "monorepo publish --dry-run",
2625
"start": "lerna run start --stream --parallel",
@@ -63,8 +62,8 @@
6362
},
6463
"devDependencies": {
6564
"@chromatic-com/storybook": "3.2.3",
66-
"@commitlint/cli": "^17.0.3",
67-
"@commitlint/config-conventional": "^17.0.3",
65+
"@commitlint/cli": "19.6.1",
66+
"@commitlint/config-conventional": "19.6.0",
6867
"@storybook/addon-a11y": "^8.4.7",
6968
"@storybook/addon-essentials": "^8.4.7",
7069
"@storybook/addon-interactions": "^8.4.7",
@@ -90,23 +89,23 @@
9089
"@types/prop-types": "^15.7.5",
9190
"@types/react-dnd": "3.0.2",
9291
"@types/react-dnd-html5-backend": "3.0.2",
92+
"@typescript-eslint/eslint-plugin": "8.18.2",
93+
"@typescript-eslint/parser": "8.18.2",
9394
"@vitejs/plugin-react": "^4.3.4",
9495
"autoprefixer": "^10.4.7",
95-
"babel-eslint": "^10.1.0",
9696
"camelcase": "6.3.0",
9797
"chromatic": "11.20.2",
9898
"cross-env": "7.0.3",
99-
"eslint": "^8.15.0",
100-
"eslint-config-prettier": "^8.5.0",
101-
"eslint-config-react-app": "^7.0.1",
102-
"eslint-plugin-import": "^2.26.0",
103-
"eslint-plugin-jsx-a11y": "^6.5.1",
104-
"eslint-plugin-prettier": "^4.2.1",
105-
"eslint-plugin-react": "^7.30.1",
106-
"eslint-plugin-react-hooks": "^4.6.0",
107-
"eslint-plugin-simple-import-sort": "^7.0.0",
108-
"eslint-plugin-testing-library": "^5.5.1",
109-
"eslint-plugin-workspaces": "^0.7.0",
99+
"eslint": "9.17.0",
100+
"eslint-config-prettier": "9.1.0",
101+
"eslint-plugin-jsx-a11y": "6.10.2",
102+
"eslint-plugin-prettier": "5.2.1",
103+
"eslint-plugin-react": "7.37.3",
104+
"eslint-plugin-react-hooks": "5.1.0",
105+
"eslint-plugin-simple-import-sort": "12.1.1",
106+
"eslint-plugin-storybook": "0.11.1",
107+
"eslint-plugin-testing-library": "7.1.1",
108+
"eslint-plugin-workspaces": "0.10.1",
110109
"fs-extra": "10.1.0",
111110
"husky": "^8.0.1",
112111
"jest": "^28.1.2",
@@ -121,16 +120,14 @@
121120
"postcss-normalize": "10.0.1",
122121
"postcss-preset-env": "7.7.2",
123122
"postcss-safe-parser": "6.0.0",
124-
"prettier": "^2.6.2",
125-
"prettier-eslint": "^14.0.3",
123+
"prettier": "3.4.2",
126124
"prop-types": "^15.8.1",
127125
"react": "^18.2.0",
128126
"react-dom": "^18.2.0",
129127
"react-svg": "10.0.23",
130128
"rimraf": "^3.0.2",
131129
"semantic-release": "23.0.5",
132130
"semantic-release-slack-bot": "4.0.2",
133-
"serve": "^13.0.4",
134131
"storybook": "^8.4.7",
135132
"typescript": "4.9.5",
136133
"vite": "5.1.8",
@@ -161,7 +158,7 @@
161158
]
162159
},
163160
"lint-staged": {
164-
"**/*.{ts,js}": [
161+
"**/*.{tsx,ts,js,jsx}": [
165162
"eslint --fix"
166163
],
167164
"**/*.{json,md,yml,yaml}": [

packages/config/package.json

-4
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,6 @@
88
"license": "MIT",
99
"private": true,
1010
"type": "commonjs",
11-
"scripts": {
12-
"lint": "eslint \"**/*.{js,jsx,ts,tsx}\"",
13-
"lint:fix": "yarn lint --fix"
14-
},
1511
"bin": {
1612
"write-coverage": "./bin/write-coverage.js"
1713
},

packages/react-formio-container/package.json

-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313
}
1414
},
1515
"scripts": {
16-
"lint": "eslint \"**/*.{js,jsx,ts,tsx}\"",
17-
"lint:fix": "yarn lint --fix",
1816
"test": "cross-env NODE_ENV=test jest --coverage",
1917
"test:coverage:update": "write-coverage",
2018
"build": "microbundle --no-compress --format modern,cjs --jsx React.createElement --jsxFragment React.Fragment --globals react/jsx-runtime=jsx",

packages/react-formio-container/src/utils/HttpClient.ts

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { Formio } from "@tsed/react-formio";
22

33
export class HttpClient {
4-
// eslint-disable-next-line no-useless-constructor
54
constructor(private host?: string) {}
65

76
get<T = any>(endpoint: string, data?: any, options?: any): Promise<T> {

packages/react-formio-container/src/views/formEdit.view.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { FormEdit } from "@tsed/react-formio";
2+
import classnames from "classnames";
23
import React from "react";
34

45
import { useForm } from "../hooks/useForm.hook";
@@ -7,7 +8,7 @@ export function FormEditView({ className, ...props }: ReturnType<typeof useForm>
78
const { form, saveForm, duplicateForm, i18n } = props;
89
const Component = props.FormEditComponent || FormEdit;
910
return (
10-
<div className={"p-3 pb-1"}>
11+
<div className={classnames("p-3 pb-1", className)}>
1112
<Component {...props} form={form} onSubmit={saveForm} onCopy={duplicateForm} options={{ i18n }} />
1213
</div>
1314
);

packages/react-formio-stores/package.json

-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313
}
1414
},
1515
"scripts": {
16-
"lint": "eslint \"**/*.{js,jsx,ts,tsx}\"",
17-
"lint:fix": "yarn lint --fix",
1816
"test": "cross-env NODE_ENV=test jest --coverage",
1917
"test:coverage:update": "write-coverage",
2018
"build": "microbundle --no-compress --format modern,cjs --jsx React.createElement --jsxFragment React.Fragment --globals react/jsx-runtime=jsx",

packages/react-formio-stores/src/stores/auth/getAccess.action.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,5 +52,5 @@ export async function getAccess(dispatch: any) {
5252
dispatch(formAccessUser(AUTH, { formAccess }));
5353
dispatch(userRoles(AUTH, { roles: result.roles }));
5454
dispatch(userForms(AUTH, { forms: result.forms }));
55-
} catch (err) {}
55+
} catch {}
5656
}

packages/react-formio-stores/src/stores/auth/getProjectAccess.action.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,5 @@ export async function getProjectAccess(dispatch: any) {
2121
const projectAccess = transformProjectAccess(project.access);
2222

2323
dispatch(projectAccessUser(AUTH, projectAccess));
24-
} catch (er) {}
24+
} catch {}
2525
}

packages/react-formio-stores/src/stores/root/root.selectors.spec.ts

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ describe("root Selectors", () => {
44
describe("selectRoot()", () => {
55
it("should return submission", () => {
66
expect(
7-
// eslint-disable-next-line no-undef
87
selectRoot("submission", {
98
submission: {
109
data: {

packages/react-formio/package.json

-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
"source": "src/index.ts",
1414
"license": "MIT",
1515
"scripts": {
16-
"lint": "eslint \"**/*.{js,jsx,ts,tsx}\"",
1716
"lint:fix": "yarn lint --fix",
1817
"test": "cross-env NODE_ENV=test jest --coverage",
1918
"test:coverage:update": "write-coverage",

packages/react-formio/src/components/actions-table/actionsTable.component.spec.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ describe("ActionsTable", () => {
6060

6161
const btn = screen.getByTestId("action-table-add");
6262

63-
await fireEvent.click(btn);
63+
fireEvent.click(btn);
6464
expect(onAddAction).not.toHaveBeenCalled();
6565
});
6666
it("should call addAction with the selected action", async () => {
@@ -73,7 +73,7 @@ describe("ActionsTable", () => {
7373

7474
await userEvent.selectOptions(select, String(args.availableActions[1].value));
7575

76-
await fireEvent.click(btn);
76+
fireEvent.click(btn);
7777

7878
expect(btn).not.toHaveProperty("disabled", true);
7979
expect(onAddAction).toHaveBeenCalledWith("sql");

packages/react-formio/src/components/form-access/formAccess.component.tsx

-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ export interface FormAccessProps {
2323
}
2424

2525
function useFormAccess({ form: formDefinition, roles, onSubmit, options }: FormAccessProps) {
26-
// eslint-disable-next-line no-undef
2726
const form = useMemo(() => getFormAccess(roles), [roles]);
2827

2928
const [submissions, setSubmissions] = useState(() => dataAccessToSubmissions(formDefinition, form));

0 commit comments

Comments
 (0)