|
| 1 | +// Originally found in https://github.com/patternfly/patternfly-react |
| 2 | +import { fixupPluginRules } from "@eslint/compat"; |
| 3 | +import js from "@eslint/js"; |
| 4 | +import patternflyReact from "eslint-plugin-patternfly-react"; |
| 5 | +import eslintPluginPrettierRecommended from "eslint-plugin-prettier/recommended"; |
| 6 | +import reactHooks from "eslint-plugin-react-hooks"; |
| 7 | +import reactRecommended from "eslint-plugin-react/configs/recommended.js"; |
| 8 | +import testingLibrary from "eslint-plugin-testing-library"; |
| 9 | +import globals from "globals"; |
| 10 | +import tseslint from "typescript-eslint"; |
| 11 | + |
| 12 | +// https://github.com/sindresorhus/globals/issues/239 |
| 13 | +const GLOBALS_BROWSER_FIX = Object.assign({}, globals.browser, { |
| 14 | + AudioWorkletGlobalScope: globals.browser["AudioWorkletGlobalScope "], |
| 15 | +}); |
| 16 | +delete GLOBALS_BROWSER_FIX["AudioWorkletGlobalScope "]; |
| 17 | + |
| 18 | +export default [ |
| 19 | + { |
| 20 | + ignores: [ |
| 21 | + "**/dist", |
| 22 | + "**/css", |
| 23 | + "packages/react-core/src/helpers/Popper/thirdparty", |
| 24 | + "packages/react-docs/patternfly-docs/generated", |
| 25 | + ".history/*", |
| 26 | + "packages/react-docs/static", |
| 27 | + "**/*-env.d.ts", |
| 28 | + ], |
| 29 | + }, |
| 30 | + js.configs.recommended, |
| 31 | + ...tseslint.configs.recommended, |
| 32 | + reactRecommended, |
| 33 | + eslintPluginPrettierRecommended, |
| 34 | + { |
| 35 | + plugins: { |
| 36 | + "patternfly-react": fixupPluginRules(patternflyReact), |
| 37 | + "react-hooks": fixupPluginRules(reactHooks), |
| 38 | + }, |
| 39 | + languageOptions: { |
| 40 | + globals: { |
| 41 | + ...GLOBALS_BROWSER_FIX, |
| 42 | + ...globals.node, |
| 43 | + ...globals.jest, |
| 44 | + }, |
| 45 | + }, |
| 46 | + settings: { |
| 47 | + react: { |
| 48 | + version: "detect", |
| 49 | + }, |
| 50 | + }, |
| 51 | + rules: { |
| 52 | + ...reactHooks.configs.recommended.rules, |
| 53 | + "@typescript-eslint/ban-ts-comment": "off", |
| 54 | + "@typescript-eslint/adjacent-overload-signatures": "error", |
| 55 | + "@typescript-eslint/array-type": "error", |
| 56 | + "@typescript-eslint/ban-types": "off", |
| 57 | + "@typescript-eslint/consistent-type-assertions": "error", |
| 58 | + "@typescript-eslint/consistent-type-definitions": "off", // changed from 'error', |
| 59 | + "@typescript-eslint/explicit-member-accessibility": "off", |
| 60 | + "@typescript-eslint/explicit-module-boundary-types": "off", |
| 61 | + "@typescript-eslint/indent": "off", |
| 62 | + "@typescript-eslint/no-duplicate-enum-values": "off", |
| 63 | + "@typescript-eslint/no-empty-function": "off", |
| 64 | + "@typescript-eslint/no-empty-interface": "off", |
| 65 | + "@typescript-eslint/no-explicit-any": "off", |
| 66 | + "@typescript-eslint/no-inferrable-types": "off", |
| 67 | + "@typescript-eslint/no-misused-new": "error", |
| 68 | + "@typescript-eslint/no-namespace": "error", |
| 69 | + "@typescript-eslint/no-unused-vars": [ |
| 70 | + "error", |
| 71 | + { |
| 72 | + argsIgnorePattern: "^_", |
| 73 | + }, |
| 74 | + ], |
| 75 | + "@typescript-eslint/no-use-before-define": "off", |
| 76 | + "@typescript-eslint/no-var-requires": "off", |
| 77 | + "@typescript-eslint/prefer-for-of": "error", |
| 78 | + "@typescript-eslint/prefer-function-type": "error", |
| 79 | + "@typescript-eslint/prefer-namespace-keyword": "error", |
| 80 | + "@typescript-eslint/unified-signatures": "error", |
| 81 | + "@typescript-eslint/explicit-function-return-type": "off", |
| 82 | + "arrow-body-style": "error", |
| 83 | + camelcase: "off", // changed |
| 84 | + // camelcase: [ |
| 85 | + // 'error', |
| 86 | + // { |
| 87 | + // ignoreDestructuring: true |
| 88 | + // } |
| 89 | + // ], |
| 90 | + "constructor-super": "error", |
| 91 | + curly: "error", |
| 92 | + "dot-notation": "error", |
| 93 | + eqeqeq: ["error", "smart"], |
| 94 | + "guard-for-in": "error", |
| 95 | + "max-classes-per-file": ["error", 1], |
| 96 | + "max-len": "off", |
| 97 | + "no-nested-ternary": "error", |
| 98 | + "no-bitwise": "error", |
| 99 | + "no-caller": "error", |
| 100 | + "no-cond-assign": "error", |
| 101 | + "no-console": "off", // changed from 'error' |
| 102 | + "no-debugger": "error", |
| 103 | + "no-empty": "error", |
| 104 | + "no-eval": "error", |
| 105 | + "no-new-wrappers": "error", |
| 106 | + "no-prototype-builtins": "off", |
| 107 | + "no-shadow": "off", |
| 108 | + "no-throw-literal": "error", |
| 109 | + "no-trailing-spaces": "off", |
| 110 | + "no-undef-init": "error", |
| 111 | + "no-constant-binary-expression": "off", |
| 112 | + "no-unsafe-finally": "error", |
| 113 | + "no-unused-expressions": [ |
| 114 | + "error", |
| 115 | + { |
| 116 | + allowTernary: true, |
| 117 | + allowShortCircuit: true, |
| 118 | + }, |
| 119 | + ], |
| 120 | + "no-unused-labels": "error", |
| 121 | + "no-var": "error", |
| 122 | + "object-shorthand": "error", |
| 123 | + "one-var": ["error", "never"], |
| 124 | + "patternfly-react/import-tokens-icons": "error", |
| 125 | + "patternfly-react/no-anonymous-functions": "error", |
| 126 | + "prefer-const": "error", |
| 127 | + radix: ["error", "as-needed"], |
| 128 | + "react/prop-types": 0, |
| 129 | + "react/display-name": 0, |
| 130 | + "react-hooks/exhaustive-deps": "warn", |
| 131 | + "react/no-unescaped-entities": ["error", { forbid: [">", "}"] }], |
| 132 | + "spaced-comment": "error", |
| 133 | + "use-isnan": "error", |
| 134 | + "patternfly-react/no-layout-effect": "error", |
| 135 | + "valid-typeof": "off", |
| 136 | + }, |
| 137 | + }, |
| 138 | + { |
| 139 | + files: ["**/examples/*", "**/demos/examples/**/*"], |
| 140 | + rules: { |
| 141 | + "patternfly-react/no-anonymous-functions": "off", |
| 142 | + }, |
| 143 | + }, |
| 144 | + { |
| 145 | + files: ["**/*.test.[jt]s?(x)"], |
| 146 | + plugins: { |
| 147 | + "testing-library": fixupPluginRules(testingLibrary), |
| 148 | + }, |
| 149 | + rules: { |
| 150 | + ...testingLibrary.configs.react.rules, |
| 151 | + "@typescript-eslint/no-unused-vars": "off", |
| 152 | + "testing-library/no-container": "off", // added |
| 153 | + "testing-library/no-node-access": "off", |
| 154 | + "testing-library/no-unnecessary-act": "off", // added |
| 155 | + "react/jsx-key": "off", |
| 156 | + "react/no-children-prop": "off", |
| 157 | + "no-console": "off", |
| 158 | + }, |
| 159 | + }, |
| 160 | + { |
| 161 | + files: ["packages/react-integration/demo-app-ts/**/*"], |
| 162 | + rules: { |
| 163 | + "patternfly-react/no-anonymous-functions": "off", |
| 164 | + "react/react-in-jsx-scope": "off", |
| 165 | + "spaced-comment": "off", |
| 166 | + }, |
| 167 | + }, |
| 168 | +]; |
0 commit comments