|
| 1 | +import { defineConfig } from "oxlint"; |
| 2 | + |
| 3 | +const disabledRules = [ |
| 4 | + "eslint/arrow-body-style", |
| 5 | + "eslint/capitalized-comments", |
| 6 | + "eslint/class-methods-use-this", |
| 7 | + "eslint/complexity", |
| 8 | + "eslint/id-length", |
| 9 | + "eslint/init-declarations", |
| 10 | + "eslint/max-classes-per-file", |
| 11 | + "eslint/max-lines-per-function", |
| 12 | + "eslint/max-lines", |
| 13 | + "eslint/max-params", |
| 14 | + "eslint/max-statements", |
| 15 | + "eslint/no-console", |
| 16 | + "eslint/no-continue", |
| 17 | + "eslint/no-eq-null", |
| 18 | + "eslint/no-magic-numbers", |
| 19 | + "eslint/no-negated-condition", |
| 20 | + "eslint/no-plusplus", |
| 21 | + "eslint/no-ternary", |
| 22 | + "eslint/no-undefined", |
| 23 | + "eslint/no-use-before-define", |
| 24 | + "eslint/no-void", |
| 25 | + "eslint/prefer-destructuring", |
| 26 | + "eslint/sort-imports", |
| 27 | + "eslint/sort-keys", |
| 28 | + "eslint/sort-vars", |
| 29 | + "func-style", |
| 30 | + "import/exports-last", |
| 31 | + "import/group-exports", |
| 32 | + "import/max-dependencies", |
| 33 | + "import/no-named-export", |
| 34 | + "import/no-namespace", |
| 35 | + "import/no-nodejs-modules", |
| 36 | + "import/no-relative-parent-imports", |
| 37 | + "import/prefer-default-export", |
| 38 | + "oxc/no-async-await", |
| 39 | + "oxc/no-optional-chaining", |
| 40 | + "oxc/no-rest-spread-properties", |
| 41 | + "promise/avoid-new", |
| 42 | + "promise/prefer-await-to-callbacks", |
| 43 | + "react-perf/jsx-no-new-function-as-prop", |
| 44 | + "react/jsx-max-depth", |
| 45 | + "react/no-multi-comp", |
| 46 | + "react/only-export-components", |
| 47 | + "react/react-in-jsx-scope", |
| 48 | + "typescript/explicit-function-return-type", |
| 49 | + "typescript/parameter-properties", |
| 50 | + "typescript/prefer-readonly-parameter-types", |
| 51 | + "typescript/promise-function-async", |
| 52 | + "typescript/strict-void-return", |
| 53 | + "unicorn/filename-case", |
| 54 | + "unicorn/no-array-callback-reference", |
| 55 | + "unicorn/no-array-for-each", |
| 56 | + "unicorn/no-null", |
| 57 | + "unicorn/prefer-at", |
| 58 | + "unicorn/prefer-module", |
| 59 | + "unicorn/prefer-spread", |
| 60 | + "unicorn/prefer-ternary", |
| 61 | + "unicorn/switch-case-braces", |
| 62 | +]; |
| 63 | + |
| 64 | +// oxlint-disable-next-line import/no-default-export |
| 65 | +export default defineConfig({ |
| 66 | + ignorePatterns: [ |
| 67 | + "resources/playground/**", |
| 68 | + "packages/app-neovim/cursorless.nvim/**", |
| 69 | + "packages/app-vscode/src/keyboard/grammar/generated/**", |
| 70 | + "packages/lib-engine/src/customCommandGrammar/generated/**", |
| 71 | + "packages/lib-engine/src/snippets/vendor/**", |
| 72 | + ], |
| 73 | + options: { |
| 74 | + typeAware: true, |
| 75 | + typeCheck: false, |
| 76 | + }, |
| 77 | + plugins: [ |
| 78 | + "eslint", |
| 79 | + "typescript", |
| 80 | + "unicorn", |
| 81 | + "oxc", |
| 82 | + "import", |
| 83 | + "node", |
| 84 | + "promise", |
| 85 | + "react", |
| 86 | + "react-perf", |
| 87 | + ], |
| 88 | + jsPlugins: [ |
| 89 | + { |
| 90 | + name: "mocha", |
| 91 | + specifier: "eslint-plugin-mocha", |
| 92 | + }, |
| 93 | + ], |
| 94 | + |
| 95 | + rules: { |
| 96 | + ...Object.fromEntries(disabledRules.map((r) => [r, "off"])), |
| 97 | + curly: "warn", |
| 98 | + eqeqeq: [ |
| 99 | + "warn", |
| 100 | + "always", |
| 101 | + { |
| 102 | + null: "never", |
| 103 | + }, |
| 104 | + ], |
| 105 | + "eslint/no-constant-condition": [ |
| 106 | + "warn", |
| 107 | + { |
| 108 | + checkLoops: false, |
| 109 | + }, |
| 110 | + ], |
| 111 | + "eslint/no-restricted-imports": [ |
| 112 | + "warn", |
| 113 | + { |
| 114 | + paths: [ |
| 115 | + { |
| 116 | + name: "node:assert", |
| 117 | + message: "Use node:assert/strict instead", |
| 118 | + }, |
| 119 | + ], |
| 120 | + patterns: [ |
| 121 | + { |
| 122 | + group: ["../*/src", "../*/src/*", "../../*/src", "../../*/src/*"], |
| 123 | + message: "Relative package imports are not allowed", |
| 124 | + }, |
| 125 | + ], |
| 126 | + }, |
| 127 | + ], |
| 128 | + "eslint/no-throw-literal": "warn", |
| 129 | + "eslint/no-unused-vars": [ |
| 130 | + "warn", |
| 131 | + { |
| 132 | + argsIgnorePattern: "^_", |
| 133 | + varsIgnorePattern: "^_", |
| 134 | + caughtErrorsIgnorePattern: "^_", |
| 135 | + ignoreRestSiblings: true, |
| 136 | + }, |
| 137 | + ], |
| 138 | + "import/no-duplicates": "warn", |
| 139 | + "mocha/no-exclusive-tests": "warn", |
| 140 | + "mocha/no-pending-tests": "warn", |
| 141 | + "no-warning-comments": [ |
| 142 | + "warn", |
| 143 | + { |
| 144 | + terms: ["todo"], |
| 145 | + }, |
| 146 | + ], |
| 147 | + "typescript/consistent-type-assertions": [ |
| 148 | + "warn", |
| 149 | + { |
| 150 | + assertionStyle: "as", |
| 151 | + }, |
| 152 | + ], |
| 153 | + "typescript/consistent-type-imports": "warn", |
| 154 | + "typescript/no-base-to-string": "off", |
| 155 | + "typescript/restrict-template-expressions": "off", |
| 156 | + "typescript/unbound-method": "off", |
| 157 | + "unicorn/prefer-module": "warn", |
| 158 | + "unicorn/prefer-node-protocol": "warn", |
| 159 | + "unicorn/throw-new-error": "warn", |
| 160 | + }, |
| 161 | + |
| 162 | + overrides: [ |
| 163 | + { |
| 164 | + files: ["packages/app-vscode/src/scripts/**/*.ts"], |
| 165 | + rules: { |
| 166 | + "no-restricted-imports": [ |
| 167 | + "warn", |
| 168 | + { |
| 169 | + paths: [ |
| 170 | + { |
| 171 | + name: "vscode", |
| 172 | + message: "Scripts shouldn't depend on vscode", |
| 173 | + }, |
| 174 | + ], |
| 175 | + }, |
| 176 | + ], |
| 177 | + }, |
| 178 | + }, |
| 179 | + |
| 180 | + { |
| 181 | + files: ["packages/lib-common/**/*.ts", "packages/lib-engine/**/*.ts"], |
| 182 | + rules: { |
| 183 | + "import/no-nodejs-modules": "warn", |
| 184 | + }, |
| 185 | + }, |
| 186 | + |
| 187 | + { |
| 188 | + files: [ |
| 189 | + "packages/lib-common/**/*.test.ts", |
| 190 | + "packages/lib-engine/**/*.test.ts", |
| 191 | + "packages/lib-engine/src/scripts/**/*.ts", |
| 192 | + "packages/lib-engine/src/testUtil/**/*.ts", |
| 193 | + ], |
| 194 | + rules: { |
| 195 | + "import/no-nodejs-modules": "off", |
| 196 | + }, |
| 197 | + }, |
| 198 | + |
| 199 | + { |
| 200 | + files: ["packages/lib-common/src/types/command/**/*.ts"], |
| 201 | + rules: { |
| 202 | + "eslint/no-restricted-imports": [ |
| 203 | + "warn", |
| 204 | + { |
| 205 | + patterns: [ |
| 206 | + { |
| 207 | + group: ["@cursorless/*", "../*"], |
| 208 | + message: "API types shouldn't have any dependencies", |
| 209 | + }, |
| 210 | + ], |
| 211 | + paths: [ |
| 212 | + { |
| 213 | + name: "@*", |
| 214 | + message: "API types shouldn't have any dependencies", |
| 215 | + }, |
| 216 | + ], |
| 217 | + }, |
| 218 | + ], |
| 219 | + }, |
| 220 | + }, |
| 221 | + ], |
| 222 | +}); |
0 commit comments