|
| 1 | +// @ts-check |
| 2 | +import eslint from "@eslint/js"; |
| 3 | +import eslintPluginSimpleImportSort from "eslint-plugin-simple-import-sort"; |
| 4 | +import eslintPluginUnicorn from "eslint-plugin-unicorn"; |
| 5 | +import globals from "globals"; |
| 6 | +import tseslint from "typescript-eslint"; |
| 7 | + |
| 8 | +export default tseslint.config( |
| 9 | + { |
| 10 | + files: ["**/*.{ts,tsx,cts,mts,js,cjs,mjs}"], |
| 11 | + }, |
| 12 | + { |
| 13 | + ignores: [ |
| 14 | + "**/dist/**", |
| 15 | + "**/node_modules/**", |
| 16 | + "bin/**", |
| 17 | + "coverage/**", |
| 18 | + ], |
| 19 | + }, |
| 20 | + eslint.configs.recommended, |
| 21 | + ...tseslint.configs.strictTypeChecked, |
| 22 | + eslintPluginUnicorn.configs["flat/recommended"], |
| 23 | + { |
| 24 | + languageOptions: { |
| 25 | + parserOptions: { |
| 26 | + warnOnUnsupportedTypeScriptVersion: false, |
| 27 | + ecmaVersion: "latest", |
| 28 | + sourceType: "module", |
| 29 | + project: true, |
| 30 | + }, |
| 31 | + globals: globals.node, |
| 32 | + }, |
| 33 | + plugins: { |
| 34 | + "simple-import-sort": eslintPluginSimpleImportSort, |
| 35 | + }, |
| 36 | + }, |
| 37 | + { |
| 38 | + "rules": { |
| 39 | + "eqeqeq": "error", |
| 40 | + "no-constant-condition": "off", |
| 41 | + "no-inner-declarations": "off", |
| 42 | + "no-undef": "off", |
| 43 | + "no-unused-vars": "off", |
| 44 | + "no-restricted-globals": ["error", "console", "process"], |
| 45 | + "simple-import-sort/imports": "error", |
| 46 | + "simple-import-sort/exports": "error", |
| 47 | + // In theory good, but less good when declaring a new interface and |
| 48 | + // stopping to think about its contents. |
| 49 | + "@typescript-eslint/no-empty-interface": "off", |
| 50 | + "@typescript-eslint/no-namespace": "off", |
| 51 | + "@typescript-eslint/no-unused-vars": ["warn", { "argsIgnorePattern": "^_", "varsIgnorePattern": "^_" }], |
| 52 | + "@typescript-eslint/no-use-before-define": "off", |
| 53 | + "@typescript-eslint/no-explicit-any": "off", |
| 54 | + "@typescript-eslint/no-unsafe-argument": "off", |
| 55 | + "@typescript-eslint/no-unsafe-assignment": "off", |
| 56 | + "@typescript-eslint/no-unsafe-call": "off", |
| 57 | + "@typescript-eslint/no-unsafe-member-access": "off", |
| 58 | + "@typescript-eslint/no-unsafe-return": "off", |
| 59 | + "@typescript-eslint/no-empty-object-type": "off", |
| 60 | + "@typescript-eslint/require-await": "off", |
| 61 | + "@typescript-eslint/restrict-template-expressions": "off", |
| 62 | + "@typescript-eslint/naming-convention": [ |
| 63 | + "error", |
| 64 | + { |
| 65 | + "selector": [ |
| 66 | + "classProperty", |
| 67 | + "typeProperty", |
| 68 | + "parameterProperty", |
| 69 | + "classMethod", |
| 70 | + "typeMethod", |
| 71 | + "accessor", |
| 72 | + ], |
| 73 | + "modifiers": ["private"], |
| 74 | + "leadingUnderscore": "require", |
| 75 | + "format": ["camelCase"], |
| 76 | + "filter": { |
| 77 | + "regex": "^(test_| )", |
| 78 | + "match": false, |
| 79 | + }, |
| 80 | + }, |
| 81 | + { |
| 82 | + "selector": [ |
| 83 | + "classProperty", |
| 84 | + "typeProperty", |
| 85 | + "parameterProperty", |
| 86 | + "classMethod", |
| 87 | + "typeMethod", |
| 88 | + "accessor", |
| 89 | + ], |
| 90 | + "modifiers": ["protected"], |
| 91 | + "leadingUnderscore": "allow", |
| 92 | + "format": ["camelCase"], |
| 93 | + "filter": { |
| 94 | + "regex": "^(test_| )", |
| 95 | + "match": false, |
| 96 | + }, |
| 97 | + }, |
| 98 | + { |
| 99 | + "selector": [ |
| 100 | + "classProperty", |
| 101 | + "typeProperty", |
| 102 | + "parameterProperty", |
| 103 | + "classMethod", |
| 104 | + "typeMethod", |
| 105 | + "accessor", |
| 106 | + ], |
| 107 | + "modifiers": ["public"], |
| 108 | + "leadingUnderscore": "forbid", |
| 109 | + "format": ["camelCase"], |
| 110 | + "filter": { |
| 111 | + "regex": "^(test_| )", |
| 112 | + "match": false, |
| 113 | + }, |
| 114 | + }, |
| 115 | + ], |
| 116 | + "unicorn/no-negated-condition": "off", |
| 117 | + "unicorn/catch-error-name": "off", |
| 118 | + "unicorn/filename-case": "off", |
| 119 | + "unicorn/no-array-callback-reference": "off", |
| 120 | + "unicorn/no-await-expression-member": "off", |
| 121 | + "unicorn/no-useless-undefined": "off", |
| 122 | + "unicorn/prevent-abbreviations": "off", |
| 123 | + "unicorn/switch-case-braces": "off", |
| 124 | + "unicorn/prefer-string-replace-all": "off", // Bad suggestion for old targets |
| 125 | + }, |
| 126 | + }, |
| 127 | + { |
| 128 | + files: [ |
| 129 | + ".ncurc.cjs", |
| 130 | + "eslint.config.mjs", |
| 131 | + "vite.config.ts", |
| 132 | + ], |
| 133 | + extends: [tseslint.configs.disableTypeChecked], |
| 134 | + }, |
| 135 | +); |
0 commit comments