|
| 1 | +// @ts-check |
| 2 | + |
| 3 | +import importPlugin from "eslint-plugin-import"; |
| 4 | +import jsdoc from "eslint-plugin-jsdoc"; |
| 5 | +import n from "eslint-plugin-n"; |
| 6 | +import tseslint from "typescript-eslint"; |
| 7 | +import stylistic from "@stylistic/eslint-plugin"; |
| 8 | + |
| 9 | + |
| 10 | +export default tseslint.config({ |
| 11 | + ignores: ["dist/", "docs-site/"] |
| 12 | +}, { |
| 13 | + files: ["**/**.{,c,m}{js,ts}"], |
| 14 | + extends: [ |
| 15 | + stylistic.configs["recommended-flat"], |
| 16 | + jsdoc.configs["flat/recommended"], |
| 17 | + importPlugin.flatConfigs.recommended |
| 18 | + ], |
| 19 | + plugins: { |
| 20 | + n |
| 21 | + }, |
| 22 | + languageOptions: { |
| 23 | + globals: { |
| 24 | + Atomics: "readonly", |
| 25 | + SharedArrayBuffer: "readonly" |
| 26 | + }, |
| 27 | + |
| 28 | + ecmaVersion: 2023, |
| 29 | + sourceType: "module" |
| 30 | + }, |
| 31 | + settings: { |
| 32 | + "import/resolver": { |
| 33 | + typescript: true, |
| 34 | + node: true |
| 35 | + }, |
| 36 | + jsdoc: { |
| 37 | + exemptDestructuredRootsFromChecks: true, |
| 38 | + |
| 39 | + tagNamePreference: { |
| 40 | + hidden: "hidden" |
| 41 | + } |
| 42 | + } |
| 43 | + }, |
| 44 | + rules: { |
| 45 | + "@stylistic/indent": ["off"], |
| 46 | + "indent": ["warn", 4, { |
| 47 | + SwitchCase: 1, |
| 48 | + FunctionDeclaration: { |
| 49 | + parameters: "first" |
| 50 | + }, |
| 51 | + ignoredNodes: [ |
| 52 | + // fix for indent warnings on function object return types when the function has no parameters |
| 53 | + 'FunctionExpression[params.length=0][returnType.type="TSTypeAnnotation"]' |
| 54 | + ] |
| 55 | + }], |
| 56 | + "@stylistic/indent-binary-ops": ["off"], |
| 57 | + "@stylistic/eqeqeq": ["off"], |
| 58 | + "@stylistic/no-undef": "off", |
| 59 | + "@stylistic/quotes": ["warn", "double", {avoidEscape: true}], |
| 60 | + "no-unused-vars": ["warn", { |
| 61 | + args: "none", |
| 62 | + ignoreRestSiblings: true, |
| 63 | + varsIgnorePattern: "^set", |
| 64 | + caughtErrors: "none" |
| 65 | + }], |
| 66 | + "@stylistic/no-prototype-builtins": ["off"], |
| 67 | + "@stylistic/object-curly-spacing": ["warn", "never"], |
| 68 | + "@stylistic/semi": ["warn", "always"], |
| 69 | + "@stylistic/no-undefined": ["off"], |
| 70 | + "@stylistic/array-bracket-newline": ["error", "consistent"], |
| 71 | + "@stylistic/brace-style": ["error", "1tbs", { |
| 72 | + allowSingleLine: false |
| 73 | + }], |
| 74 | + "@stylistic/comma-spacing": ["error", { |
| 75 | + before: false, |
| 76 | + after: true |
| 77 | + }], |
| 78 | + "@stylistic/comma-style": ["error", "last"], |
| 79 | + "@stylistic/comma-dangle": ["warn", "never"], |
| 80 | + "no-var": ["error"], |
| 81 | + "import/order": ["error", { |
| 82 | + groups: ["builtin", "external", "internal", "parent", "sibling", "index", "type", "object", "unknown"], |
| 83 | + warnOnUnassignedImports: true |
| 84 | + }], |
| 85 | + "n/file-extension-in-import": ["error", "always"], |
| 86 | + "newline-per-chained-call": ["error", { |
| 87 | + ignoreChainWithDepth: 2 |
| 88 | + }], |
| 89 | + "no-confusing-arrow": ["error"], |
| 90 | + "no-const-assign": ["error"], |
| 91 | + "no-duplicate-imports": ["error", { |
| 92 | + includeExports: true |
| 93 | + }], |
| 94 | + camelcase: ["warn"], |
| 95 | + "@stylistic/jsx-quotes": ["warn"], |
| 96 | + yoda: ["error", "never", { |
| 97 | + exceptRange: true |
| 98 | + }], |
| 99 | + "no-eval": ["error"], |
| 100 | + "array-callback-return": ["error"], |
| 101 | + "no-empty": ["error", { |
| 102 | + allowEmptyCatch: true |
| 103 | + }], |
| 104 | + "@stylistic/keyword-spacing": ["warn"], |
| 105 | + "@stylistic/space-infix-ops": ["warn"], |
| 106 | + "@stylistic/spaced-comment": ["warn", "always", { |
| 107 | + markers: ["/"] |
| 108 | + }], |
| 109 | + "@stylistic/eol-last": ["warn", "always"], |
| 110 | + "@stylistic/max-len": ["warn", { |
| 111 | + code: 140, |
| 112 | + tabWidth: 4, |
| 113 | + ignoreStrings: true |
| 114 | + }], |
| 115 | + "@stylistic/quote-props": ["off"], |
| 116 | + "@stylistic/arrow-parens": ["warn", "always"], |
| 117 | + "@stylistic/no-multiple-empty-lines": ["off"], |
| 118 | + "@stylistic/operator-linebreak": ["off"], |
| 119 | + "@stylistic/block-spacing": ["warn", "never"], |
| 120 | + "@stylistic/no-extra-parens": ["off"], |
| 121 | + "@stylistic/padded-blocks": ["warn"], |
| 122 | + "@stylistic/multiline-ternary": ["off"], |
| 123 | + "@stylistic/lines-between-class-members": ["warn", { |
| 124 | + enforce: [ |
| 125 | + {blankLine: "always", prev: "method", next: "*"}, |
| 126 | + {blankLine: "always", prev: "*", next: "method"} |
| 127 | + ] |
| 128 | + }], |
| 129 | + "@stylistic/no-trailing-spaces": ["off"], |
| 130 | + "@stylistic/no-multi-spaces": ["warn"], |
| 131 | + "@stylistic/generator-star-spacing": ["off"] |
| 132 | + } |
| 133 | +}, { |
| 134 | + files: ["**/**.{,c,m}ts"], |
| 135 | + extends: [ |
| 136 | + jsdoc.configs["flat/recommended-typescript"], |
| 137 | + ...tseslint.configs.recommended |
| 138 | + ], |
| 139 | + settings: { |
| 140 | + "import/resolver": { |
| 141 | + typescript: true, |
| 142 | + node: true |
| 143 | + } |
| 144 | + }, |
| 145 | + rules: { |
| 146 | + "no-constant-condition": ["warn"], |
| 147 | + "import/named": ["off"], |
| 148 | + "@typescript-eslint/explicit-module-boundary-types": ["off"], |
| 149 | + "@typescript-eslint/ban-ts-comment": ["off"], |
| 150 | + "@typescript-eslint/no-explicit-any": ["off"], |
| 151 | + "@typescript-eslint/no-inferrable-types": ["off"], |
| 152 | + "@typescript-eslint/no-unused-vars": ["warn", { |
| 153 | + args: "none", |
| 154 | + ignoreRestSiblings: true, |
| 155 | + varsIgnorePattern: "^set", |
| 156 | + caughtErrors: "none" |
| 157 | + }], |
| 158 | + "@typescript-eslint/no-empty-object-type": ["off"], |
| 159 | + "@typescript-eslint/member-ordering": ["warn", { |
| 160 | + default: ["field", "constructor", "method", "signature"], |
| 161 | + typeLiterals: [] |
| 162 | + }], |
| 163 | + "@typescript-eslint/parameter-properties": ["warn", { |
| 164 | + allow: [] |
| 165 | + }], |
| 166 | + "@typescript-eslint/explicit-member-accessibility": ["warn"], |
| 167 | + "@stylistic/member-delimiter-style": ["warn", { |
| 168 | + multiline: { |
| 169 | + delimiter: "comma", |
| 170 | + requireLast: false |
| 171 | + }, |
| 172 | + singleline: { |
| 173 | + delimiter: "comma", |
| 174 | + requireLast: false |
| 175 | + }, |
| 176 | + multilineDetection: "brackets" |
| 177 | + }], |
| 178 | + |
| 179 | + "jsdoc/require-param": ["off"], |
| 180 | + "jsdoc/check-param-names": ["warn", { |
| 181 | + checkDestructured: false |
| 182 | + }], |
| 183 | + "jsdoc/require-returns": ["off"], |
| 184 | + "jsdoc/require-jsdoc": ["off"], |
| 185 | + "jsdoc/require-yields": ["off"], |
| 186 | + "jsdoc/require-param-description": ["off"] |
| 187 | + } |
| 188 | +}, { |
| 189 | + files: ["**/**.{,c,m}ts"], |
| 190 | + rules: { |
| 191 | + "@stylistic/max-len": ["off"] |
| 192 | + } |
| 193 | +}); |
0 commit comments