|
| 1 | +// eslint.config.ts |
| 2 | +import js from "@eslint/js"; |
| 3 | +import tseslint from "typescript-eslint"; |
| 4 | +import stylistic from "@stylistic/eslint-plugin"; |
| 5 | +import jsdoc from "eslint-plugin-jsdoc"; |
| 6 | +import tsdoc from "eslint-plugin-tsdoc"; |
| 7 | +import prettierPlugin from "eslint-plugin-prettier"; |
| 8 | +import prettierConfig from "eslint-config-prettier/flat"; |
| 9 | +import prettierRecommended from "eslint-plugin-prettier/recommended"; |
| 10 | + |
| 11 | +export default tseslint.config( |
| 12 | + js.configs.recommended, |
| 13 | + stylistic.configs.recommended, |
| 14 | + ...tseslint.configs.recommended, |
| 15 | + ...tseslint.configs.recommendedTypeChecked, |
| 16 | + ...tseslint.configs.stylisticTypeChecked, |
| 17 | + jsdoc.configs["flat/recommended-typescript"], |
| 18 | + { |
| 19 | + ignores: ["dist", "node_modules"], |
| 20 | + plugins: { |
| 21 | + "@stylistic": stylistic, |
| 22 | + "@typescript-eslint": tseslint.plugin, |
| 23 | + jsdoc, |
| 24 | + tsdoc, |
| 25 | + prettierPlugin, |
| 26 | + }, |
| 27 | + languageOptions: { |
| 28 | + parser: tseslint.parser, |
| 29 | + parserOptions: { |
| 30 | + project: "./tsconfig.json", |
| 31 | + }, |
| 32 | + }, |
| 33 | + rules: { |
| 34 | + // --- stylistic --- |
| 35 | + "@stylistic/comma-spacing": ["error"], |
| 36 | + "@stylistic/quote-props": ["error", "as-needed"], |
| 37 | + "@stylistic/space-in-parens": ["error", "never"], |
| 38 | + "@stylistic/spaced-comment": ["error", "always", {block: {balanced: true}}], |
| 39 | + "@stylistic/arrow-spacing": "error", |
| 40 | + "@stylistic/arrow-parens": ["error", "as-needed"], |
| 41 | + "@stylistic/quotes": ["error", "double", {allowTemplateLiterals: true, avoidEscape: true}], |
| 42 | + "@stylistic/semi": ["error", "always"], |
| 43 | + "@stylistic/space-before-blocks": "error", |
| 44 | + "@stylistic/space-infix-ops": "error", |
| 45 | + "@stylistic/keyword-spacing": "error", |
| 46 | + "@stylistic/no-extra-semi": "error", |
| 47 | + |
| 48 | + // --- typescript-eslint --- |
| 49 | + "@typescript-eslint/ban-types": "warn", |
| 50 | + "@typescript-eslint/consistent-generic-constructors": ["error", "constructor"], |
| 51 | + "@typescript-eslint/consistent-type-exports": "error", |
| 52 | + "@typescript-eslint/consistent-type-imports": "error", |
| 53 | + "@typescript-eslint/explicit-function-return-type": "error", |
| 54 | + "@typescript-eslint/explicit-member-accessibility": ["error", {accessibility: "no-public"}], |
| 55 | + "@typescript-eslint/no-explicit-any": "error", |
| 56 | + "@typescript-eslint/no-inferrable-types": "error", |
| 57 | + "@typescript-eslint/member-ordering": [ |
| 58 | + "error", |
| 59 | + { |
| 60 | + default: { |
| 61 | + memberTypes: [ |
| 62 | + "signature", |
| 63 | + "public-static-field", |
| 64 | + "protected-static-field", |
| 65 | + "private-static-field", |
| 66 | + "public-decorated-field", |
| 67 | + "protected-decorated-field", |
| 68 | + "private-decorated-field", |
| 69 | + "public-instance-field", |
| 70 | + "protected-instance-field", |
| 71 | + "private-instance-field", |
| 72 | + "public-abstract-field", |
| 73 | + "protected-abstract-field", |
| 74 | + "public-field", |
| 75 | + "protected-field", |
| 76 | + "private-field", |
| 77 | + "static-field", |
| 78 | + "instance-field", |
| 79 | + "abstract-field", |
| 80 | + "decorated-field", |
| 81 | + "field", |
| 82 | + "public-constructor", |
| 83 | + "protected-constructor", |
| 84 | + "private-constructor", |
| 85 | + "constructor", |
| 86 | + ["public-static-get", "public-static-set"], |
| 87 | + ["protected-static-get", "protected-static-set"], |
| 88 | + ["private-static-get", "private-static-set"], |
| 89 | + ["public-decorated-get", "public-decorated-set"], |
| 90 | + ["protected-decorated-get", "protected-decorated-set"], |
| 91 | + ["private-decorated-get", "private-decorated-set"], |
| 92 | + ["public-instance-get", "public-instance-set"], |
| 93 | + ["protected-instance-get", "protected-instance-set"], |
| 94 | + ["private-instance-get", "private-instance-set"], |
| 95 | + ["public-abstract-get", "public-abstract-set"], |
| 96 | + ["protected-abstract-get", "protected-abstract-set"], |
| 97 | + ["public-get", "public-set"], |
| 98 | + ["protected-get", "protected-set"], |
| 99 | + ["private-get", "private-set"], |
| 100 | + ["static-get", "static-set"], |
| 101 | + ["instance-get", "instance-set"], |
| 102 | + ["abstract-get", "abstract-set"], |
| 103 | + ["decorated-get", "decorated-set"], |
| 104 | + ["get", "set"], |
| 105 | + "public-static-method", |
| 106 | + "protected-static-method", |
| 107 | + "private-static-method", |
| 108 | + "public-decorated-method", |
| 109 | + "protected-decorated-method", |
| 110 | + "private-decorated-method", |
| 111 | + "public-instance-method", |
| 112 | + "protected-instance-method", |
| 113 | + "private-instance-method", |
| 114 | + "public-abstract-method", |
| 115 | + "protected-abstract-method", |
| 116 | + "public-method", |
| 117 | + "protected-method", |
| 118 | + "private-method", |
| 119 | + "static-method", |
| 120 | + "instance-method", |
| 121 | + "abstract-method", |
| 122 | + "decorated-method", |
| 123 | + "method", |
| 124 | + ], |
| 125 | + order: "alphabetically", |
| 126 | + }, |
| 127 | + }, |
| 128 | + ], |
| 129 | + "@typescript-eslint/no-unnecessary-type-arguments": "error", |
| 130 | + "@typescript-eslint/no-unnecessary-type-assertion": "error", |
| 131 | + "@typescript-eslint/no-unused-vars": [ |
| 132 | + "error", |
| 133 | + { |
| 134 | + argsIgnorePattern: "^_", |
| 135 | + caughtErrorsIgnorePattern: "^_", |
| 136 | + destructuredArrayIgnorePattern: "^_", |
| 137 | + varsIgnorePattern: "^_", |
| 138 | + }, |
| 139 | + ], |
| 140 | + "@typescript-eslint/no-var-requires": "error", |
| 141 | + "@typescript-eslint/prefer-readonly": "error", |
| 142 | + "@typescript-eslint/no-magic-numbers": [ |
| 143 | + "error", |
| 144 | + {ignoreEnums: true, ignoreNumericLiteralTypes: true}, |
| 145 | + ], |
| 146 | + "@typescript-eslint/no-unused-expressions": "error", |
| 147 | + "@typescript-eslint/no-throw-literal": "error", |
| 148 | + "@typescript-eslint/no-empty-function": "error", |
| 149 | + "@typescript-eslint/no-useless-constructor": "error", |
| 150 | + |
| 151 | + // --- core rules --- |
| 152 | + "no-console": "error", |
| 153 | + "sort-imports": [ |
| 154 | + "error", |
| 155 | + { |
| 156 | + allowSeparatedGroups: false, |
| 157 | + ignoreCase: false, |
| 158 | + ignoreDeclarationSort: false, |
| 159 | + ignoreMemberSort: false, |
| 160 | + memberSyntaxSortOrder: ["none", "all", "multiple", "single"], |
| 161 | + }, |
| 162 | + ], |
| 163 | + "tsdoc/syntax": "warn", |
| 164 | + "no-nested-ternary": "error", |
| 165 | + "no-unneeded-ternary": "error", |
| 166 | + "no-var": "error", |
| 167 | + "prefer-const": "error", |
| 168 | + "prefer-object-spread": "error", |
| 169 | + "prefer-template": "error", |
| 170 | + yoda: ["error", "never", {exceptRange: true}], |
| 171 | + "no-duplicate-imports": "error", |
| 172 | + "no-useless-rename": "error", |
| 173 | + "no-useless-return": "error", |
| 174 | + "no-useless-computed-key": "error", |
| 175 | + "no-useless-concat": "error", |
| 176 | + "no-useless-escape": "error", |
| 177 | + "constructor-super": "error", |
| 178 | + "no-this-before-super": "error", |
| 179 | + "no-duplicate-case": "error", |
| 180 | + "no-empty": "error", |
| 181 | + "no-func-assign": "error", |
| 182 | + "no-irregular-whitespace": "error", |
| 183 | + "no-unexpected-multiline": "error", |
| 184 | + "no-unreachable": "error", |
| 185 | + "valid-typeof": "error", |
| 186 | + "no-unsafe-finally": "error", |
| 187 | + "no-case-declarations": "error", |
| 188 | + "no-empty-pattern": "error", |
| 189 | + "no-extra-boolean-cast": "error", |
| 190 | + "no-inner-declarations": "error", |
| 191 | + "no-prototype-builtins": "error", |
| 192 | + "no-self-assign": "error", |
| 193 | + "no-unused-labels": "error", |
| 194 | + "no-useless-catch": "error", |
| 195 | + |
| 196 | + // disabilitazioni duplicate (sostituite da @typescript-eslint) |
| 197 | + "no-useless-constructor": "off", |
| 198 | + "no-empty-function": "off", |
| 199 | + "no-throw-literal": "off", |
| 200 | + "no-unused-expressions": "off", |
| 201 | + "no-magic-numbers": "off", |
| 202 | + }, |
| 203 | + }, |
| 204 | + prettierConfig, |
| 205 | + prettierRecommended, |
| 206 | +); |
0 commit comments