|
| 1 | +const { FlatCompat } = require("@eslint/eslintrc"); |
| 2 | +const js = require("@eslint/js"); |
| 3 | +const path = require("path"); |
| 4 | + |
| 5 | +const compat = new FlatCompat({ |
| 6 | + baseDirectory: __dirname, |
| 7 | + recommendedConfig: js.configs.recommended, |
| 8 | + allConfig: js.configs.all |
| 9 | +}); |
| 10 | + |
| 11 | +module.exports = [ |
| 12 | + { |
| 13 | + ignores: [ |
| 14 | + "lib/", |
| 15 | + "dev/", |
| 16 | + "node_modules/", |
| 17 | + "coverage/", |
| 18 | + "docgen/", |
| 19 | + "v1/", |
| 20 | + "v2/", |
| 21 | + "logger/", |
| 22 | + "dist/", |
| 23 | + "spec/fixtures/", |
| 24 | + "scripts/**/*.js", |
| 25 | + "protos/", |
| 26 | + ".prettierrc.js", |
| 27 | + "eslint.config.js", |
| 28 | + "scripts/bin-test/sources/esm-ext/index.mjs", |
| 29 | + ], |
| 30 | + }, |
| 31 | + ...compat.extends( |
| 32 | + "eslint:recommended", |
| 33 | + "plugin:@typescript-eslint/recommended", |
| 34 | + "plugin:@typescript-eslint/recommended-requiring-type-checking", |
| 35 | + "plugin:jsdoc/recommended", |
| 36 | + "google", |
| 37 | + "prettier" |
| 38 | + ), |
| 39 | + { |
| 40 | + languageOptions: { |
| 41 | + parser: require("@typescript-eslint/parser"), |
| 42 | + parserOptions: { |
| 43 | + project: "tsconfig.json", |
| 44 | + tsconfigRootDir: __dirname, |
| 45 | + }, |
| 46 | + ecmaVersion: 2022 |
| 47 | + }, |
| 48 | + plugins: { |
| 49 | + "prettier": require("eslint-plugin-prettier"), |
| 50 | + }, |
| 51 | + rules: { |
| 52 | + "jsdoc/newline-after-description": "off", |
| 53 | + "jsdoc/require-jsdoc": ["warn", { publicOnly: true }], |
| 54 | + "jsdoc/check-tag-names": ["warn", { definedTags: ["alpha", "remarks", "typeParam", "packageDocumentation", "hidden"] }], |
| 55 | + "no-restricted-globals": ["error", "name", "length"], |
| 56 | + "prefer-arrow-callback": "error", |
| 57 | + "prettier/prettier": "off", |
| 58 | + "require-atomic-updates": "off", // This rule is so noisy and isn't useful: https://github.com/eslint/eslint/issues/11899 |
| 59 | + "require-jsdoc": "off", // This rule is deprecated and superseded by jsdoc/require-jsdoc. |
| 60 | + "valid-jsdoc": "off", // This is deprecated but included in recommended configs. |
| 61 | + "no-prototype-builtins": "warn", |
| 62 | + "no-useless-escape": "warn", |
| 63 | + "prefer-promise-reject-errors": "warn", |
| 64 | + }, |
| 65 | + }, |
| 66 | + { |
| 67 | + files: ["**/*.ts"], |
| 68 | + rules: { |
| 69 | + "jsdoc/require-param-type": "off", |
| 70 | + "jsdoc/require-returns-type": "off", |
| 71 | + // Google style guide allows us to omit trivial parameters and returns |
| 72 | + "jsdoc/require-param": "off", |
| 73 | + "jsdoc/require-returns": "off", |
| 74 | + |
| 75 | + "@typescript-eslint/no-invalid-this": "error", |
| 76 | + "@typescript-eslint/no-unused-vars": ["error", { argsIgnorePattern: "^_", caughtErrorsIgnorePattern: "^_" }], // Unused vars should not exist. |
| 77 | + "@typescript-eslint/no-misused-promises": "warn", // rule does not work with async handlers for express. |
| 78 | + "no-invalid-this": "off", // Turned off in favor of @typescript-eslint/no-invalid-this. |
| 79 | + "no-unused-vars": "off", // Off in favor of @typescript-eslint/no-unused-vars. |
| 80 | + eqeqeq: ["error", "always", { null: "ignore" }], |
| 81 | + camelcase: ["error", { properties: "never" }], // snake_case allowed in properties iif to satisfy an external contract / style |
| 82 | + |
| 83 | + // Ideally, all these warning should be error - let's fix them in the future. |
| 84 | + "@typescript-eslint/no-unsafe-argument": "warn", |
| 85 | + "@typescript-eslint/no-unsafe-assignment": "warn", |
| 86 | + "@typescript-eslint/no-unsafe-call": "warn", |
| 87 | + "@typescript-eslint/no-unsafe-member-access": "warn", |
| 88 | + "@typescript-eslint/no-unsafe-return": "warn", |
| 89 | + "@typescript-eslint/restrict-template-expressions": "warn", |
| 90 | + "@typescript-eslint/no-explicit-any": "warn", |
| 91 | + "@typescript-eslint/no-redundant-type-constituents": "warn", |
| 92 | + "@typescript-eslint/no-base-to-string": "warn", |
| 93 | + "@typescript-eslint/no-duplicate-type-constituents": "warn", |
| 94 | + "@typescript-eslint/no-require-imports": "warn", |
| 95 | + "@typescript-eslint/no-empty-object-type": "warn", |
| 96 | + "@typescript-eslint/prefer-promise-reject-errors": "warn", |
| 97 | + }, |
| 98 | + }, |
| 99 | + { |
| 100 | + files: ["**/*.spec.ts", "**/*.spec.js", "spec/helper.ts", "scripts/bin-test/**/*.ts", "integration_test/**/*.ts"], |
| 101 | + languageOptions: { |
| 102 | + globals: { |
| 103 | + mocha: true, |
| 104 | + }, |
| 105 | + }, |
| 106 | + rules: { |
| 107 | + "@typescript-eslint/no-unused-expressions": "off", |
| 108 | + } |
| 109 | + }, |
| 110 | +]; |
0 commit comments