|
| 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 | +]; |
0 commit comments