|
| 1 | +import eslintComments from "eslint-plugin-eslint-comments"; |
| 2 | +import _import from "eslint-plugin-import"; |
| 3 | +import jest from "eslint-plugin-jest"; |
| 4 | +import babel from "@babel/eslint-plugin"; |
| 5 | +import {fixupPluginRules} from "@eslint/compat"; |
| 6 | +import globals from "globals"; |
| 7 | +import path from "node:path"; |
| 8 | +import {fileURLToPath} from "node:url"; |
| 9 | +import js from "@eslint/js"; |
| 10 | +import {FlatCompat} from "@eslint/eslintrc"; |
| 11 | + |
| 12 | +const __filename = fileURLToPath(import.meta.url); |
| 13 | +const __dirname = path.dirname(__filename); |
| 14 | +const compat = new FlatCompat({ |
| 15 | + baseDirectory: __dirname, |
| 16 | + recommendedConfig: js.configs.recommended, |
| 17 | + allConfig: js.configs.all, |
| 18 | +}); |
| 19 | + |
| 20 | +export default [ |
| 21 | + { |
| 22 | + ignores: [ |
| 23 | + "**/node_modules", |
| 24 | + "flow-typed/**/*.js", |
| 25 | + "**/coverage", |
| 26 | + "**/dist", |
| 27 | + ], |
| 28 | + }, |
| 29 | + ...compat.extends("@khanacademy"), |
| 30 | + { |
| 31 | + plugins: { |
| 32 | + "eslint-comments": eslintComments, |
| 33 | + import: fixupPluginRules(_import), |
| 34 | + jest, |
| 35 | + "@babel": babel, |
| 36 | + }, |
| 37 | + |
| 38 | + languageOptions: { |
| 39 | + globals: { |
| 40 | + ...globals.jest, |
| 41 | + ...globals.node, |
| 42 | + }, |
| 43 | + }, |
| 44 | + |
| 45 | + rules: { |
| 46 | + "constructor-super": "error", |
| 47 | + curly: "error", |
| 48 | + eqeqeq: ["error", "allow-null"], |
| 49 | + "generator-star-spacing": "error", |
| 50 | + "guard-for-in": "error", |
| 51 | + "linebreak-style": ["error", "unix"], |
| 52 | + "no-alert": "error", |
| 53 | + "no-array-constructor": "error", |
| 54 | + "no-console": "error", |
| 55 | + "no-debugger": "error", |
| 56 | + "no-dupe-class-members": "error", |
| 57 | + "no-dupe-keys": "error", |
| 58 | + "no-extra-bind": "error", |
| 59 | + "no-new": "error", |
| 60 | + "no-new-func": "error", |
| 61 | + "no-new-object": "error", |
| 62 | + "no-throw-literal": "error", |
| 63 | + "@babel/no-invalid-this": "error", |
| 64 | + "no-with": "error", |
| 65 | + "no-async-promise-executor": "error", |
| 66 | + "no-const-assign": "error", |
| 67 | + |
| 68 | + "no-else-return": [ |
| 69 | + "error", |
| 70 | + { |
| 71 | + allowElseIf: false, |
| 72 | + }, |
| 73 | + ], |
| 74 | + |
| 75 | + "no-irregular-whitespace": "off", |
| 76 | + "no-multi-str": "error", |
| 77 | + "no-prototype-builtins": "off", |
| 78 | + |
| 79 | + "no-restricted-syntax": [ |
| 80 | + "error", |
| 81 | + { |
| 82 | + selector: "IntersectionTypeAnnotation", |
| 83 | + message: |
| 84 | + "Use exact object types and the spread operator instead", |
| 85 | + }, |
| 86 | + ], |
| 87 | + |
| 88 | + "no-return-await": "error", |
| 89 | + "no-this-before-super": "error", |
| 90 | + "no-useless-catch": "off", |
| 91 | + "no-useless-call": "error", |
| 92 | + "no-undef": "error", |
| 93 | + "no-unexpected-multiline": "error", |
| 94 | + "no-unreachable": "error", |
| 95 | + "no-unused-expressions": "error", |
| 96 | + |
| 97 | + "no-unused-vars": [ |
| 98 | + "error", |
| 99 | + { |
| 100 | + args: "none", |
| 101 | + varsIgnorePattern: "^_*$", |
| 102 | + }, |
| 103 | + ], |
| 104 | + |
| 105 | + "no-var": "error", |
| 106 | + "one-var": ["error", "never"], |
| 107 | + "prefer-const": "error", |
| 108 | + "prefer-spread": "error", |
| 109 | + "require-await": "error", |
| 110 | + "require-yield": "error", |
| 111 | + "prefer-template": "off", |
| 112 | + "arrow-parens": "off", |
| 113 | + "prefer-arrow-callback": "off", |
| 114 | + "no-case-declarations": "off", |
| 115 | + "valid-jsdoc": "off", |
| 116 | + "require-jsdoc": "off", |
| 117 | + "eslint-comments/no-unlimited-disable": "error", |
| 118 | + "eslint-comments/no-unused-disable": "error", |
| 119 | + |
| 120 | + "import/extensions": [ |
| 121 | + "error", |
| 122 | + "never", |
| 123 | + { |
| 124 | + ignorePackages: true, |
| 125 | + }, |
| 126 | + ], |
| 127 | + |
| 128 | + "import/no-cycle": [ |
| 129 | + "error", |
| 130 | + { |
| 131 | + ignoreExternal: true, |
| 132 | + commonjs: true, |
| 133 | + maxDepth: 6, |
| 134 | + }, |
| 135 | + ], |
| 136 | + |
| 137 | + "import/named": "error", |
| 138 | + "import/default": "error", |
| 139 | + "import/namespace": "error", |
| 140 | + |
| 141 | + "import/no-unassigned-import": [ |
| 142 | + "error", |
| 143 | + { |
| 144 | + allow: ["@jest/globals", "jest-extended"], |
| 145 | + }, |
| 146 | + ], |
| 147 | + |
| 148 | + "jest/no-focused-tests": "error", |
| 149 | + "jest/no-identical-title": "error", |
| 150 | + "jest/prefer-to-contain": "error", |
| 151 | + "jest/prefer-to-have-length": "error", |
| 152 | + "jest/valid-title": "error", |
| 153 | + |
| 154 | + "prettier/prettier": [ |
| 155 | + "error", |
| 156 | + { |
| 157 | + tabWidth: 4, |
| 158 | + trailingComma: "all", |
| 159 | + bracketSpacing: false, |
| 160 | + }, |
| 161 | + ], |
| 162 | + }, |
| 163 | + }, |
| 164 | +]; |
0 commit comments