|
| 1 | +const eslint = require("@eslint/js"); |
| 2 | +const tseslint = require("typescript-eslint"); |
| 3 | +const tsdoc = require("eslint-plugin-tsdoc"); |
| 4 | +const jest = require("eslint-plugin-jest"); |
| 5 | +const globals = require("globals"); |
| 6 | +const prettier = require("eslint-config-prettier"); |
| 7 | + |
| 8 | +/** @type {import("eslint").Linter.Config[]} */ |
| 9 | +module.exports = [ |
| 10 | + { |
| 11 | + ignores: ["dist/", "tests/env/", "coverage/", "playgrounds/", "docs/"], |
| 12 | + }, |
| 13 | + // Standard linting for js files |
| 14 | + { |
| 15 | + files: ["**/*.js"], |
| 16 | + languageOptions: { sourceType: "script", globals: globals.node }, |
| 17 | + plugins: { eslint }, |
| 18 | + rules: eslint.configs.recommended.rules, |
| 19 | + }, |
| 20 | + // TypeScript linting for ts files |
| 21 | + ...tseslint.configs.recommendedTypeChecked.map((config) => ({ |
| 22 | + ...config, |
| 23 | + files: ["**/*.ts"], |
| 24 | + languageOptions: { |
| 25 | + ...config.languageOptions, |
| 26 | + globals: { ...config.languageOptions?.globals, ...globals.node }, |
| 27 | + parserOptions: { |
| 28 | + ...config.languageOptions?.parserOptions, |
| 29 | + project: "tsconfig.eslint.json", |
| 30 | + }, |
| 31 | + }, |
| 32 | + plugins: { ...config.plugins, tsdoc }, |
| 33 | + rules: { |
| 34 | + ...config.rules, |
| 35 | + "tsdoc/syntax": "error", |
| 36 | + // @TODO: Remove the ones between "~~", adapt code |
| 37 | + // ~~ |
| 38 | + "@typescript-eslint/prefer-as-const": "off", |
| 39 | + "@typescript-eslint/ban-ts-comment": "off", |
| 40 | + "@typescript-eslint/no-unsafe-call": "off", |
| 41 | + "@typescript-eslint/no-unsafe-member-access": "off", |
| 42 | + "@typescript-eslint/no-unsafe-return": "off", |
| 43 | + "@typescript-eslint/no-unsafe-assignment": "off", |
| 44 | + "@typescript-eslint/no-unsafe-argument": "off", |
| 45 | + "@typescript-eslint/no-floating-promises": "off", |
| 46 | + // ~~ |
| 47 | + "@typescript-eslint/array-type": ["warn", { default: "array-simple" }], |
| 48 | + // @TODO: Should be careful with this rule, should leave it be and disable |
| 49 | + // it within files where necessary with explanations |
| 50 | + "@typescript-eslint/no-explicit-any": "off", |
| 51 | + "@typescript-eslint/no-unused-vars": [ |
| 52 | + "error", |
| 53 | + // argsIgnorePattern: https://eslint.org/docs/latest/rules/no-unused-vars#argsignorepattern |
| 54 | + // varsIgnorePattern: https://eslint.org/docs/latest/rules/no-unused-vars#varsignorepattern |
| 55 | + { args: "all", argsIgnorePattern: "^_", varsIgnorePattern: "^_" }, |
| 56 | + ], |
| 57 | + // @TODO: Not recommended to disable rule, should instead disable locally |
| 58 | + // with explanation |
| 59 | + "@typescript-eslint/ban-ts-ignore": "off", |
| 60 | + }, |
| 61 | + })), |
| 62 | + // Jest linting for test files |
| 63 | + { |
| 64 | + files: ["tests/*.ts"], |
| 65 | + ...jest.configs["flat/recommended"], |
| 66 | + // languageOptions: { |
| 67 | + // ...jest.configs['flat/recommended'].languageOptions, |
| 68 | + // globals: globals.jest, |
| 69 | + // }, |
| 70 | + rules: { |
| 71 | + ...jest.configs["flat/recommended"].rules, |
| 72 | + // @TODO: Remove all of these rules and adapt code! |
| 73 | + "jest/no-disabled-tests": "off", |
| 74 | + "jest/expect-expect": "off", |
| 75 | + "jest/no-conditional-expect": "off", |
| 76 | + "jest/valid-title": "off", |
| 77 | + "jest/no-jasmine-globals": "off", |
| 78 | + "jest/valid-expect-in-promise": "off", |
| 79 | + "jest/valid-expect": "off", |
| 80 | + "jest/no-alias-methods": "off", |
| 81 | + }, |
| 82 | + }, |
| 83 | + prettier, |
| 84 | +]; |
0 commit comments