Skip to content

Commit 2854007

Browse files
committed
chore: migrate to ESLint v9 and Flat Config
1 parent dece9a9 commit 2854007

File tree

9 files changed

+784
-593
lines changed

9 files changed

+784
-593
lines changed

.eslintignore

Lines changed: 0 additions & 12 deletions
This file was deleted.

.eslintrc.js

Lines changed: 0 additions & 70 deletions
This file was deleted.

eslint.config.js

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
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: 2018,
47+
sourceType: "module",
48+
},
49+
plugins: {
50+
"prettier": require("eslint-plugin-prettier"),
51+
},
52+
rules: {
53+
"jsdoc/newline-after-description": "off",
54+
"jsdoc/require-jsdoc": ["warn", { publicOnly: true }],
55+
"jsdoc/check-tag-names": ["warn", { definedTags: ["alpha", "remarks", "typeParam", "packageDocumentation", "hidden"] }],
56+
"no-restricted-globals": ["error", "name", "length"],
57+
"prefer-arrow-callback": "error",
58+
"prettier/prettier": "off",
59+
"require-atomic-updates": "off", // This rule is so noisy and isn't useful: https://github.com/eslint/eslint/issues/11899
60+
"require-jsdoc": "off", // This rule is deprecated and superseded by jsdoc/require-jsdoc.
61+
"valid-jsdoc": "off", // This is deprecated but included in recommended configs.
62+
"no-prototype-builtins": "warn",
63+
"no-useless-escape": "warn",
64+
"prefer-promise-reject-errors": "warn",
65+
},
66+
},
67+
{
68+
files: ["**/*.ts"],
69+
rules: {
70+
"jsdoc/require-param-type": "off",
71+
"jsdoc/require-returns-type": "off",
72+
// Google style guide allows us to omit trivial parameters and returns
73+
"jsdoc/require-param": "off",
74+
"jsdoc/require-returns": "off",
75+
76+
"@typescript-eslint/no-invalid-this": "error",
77+
"@typescript-eslint/no-unused-vars": ["error", { argsIgnorePattern: "^_", caughtErrorsIgnorePattern: "^_" }], // Unused vars should not exist.
78+
"@typescript-eslint/no-misused-promises": "warn", // rule does not work with async handlers for express.
79+
"no-invalid-this": "off", // Turned off in favor of @typescript-eslint/no-invalid-this.
80+
"no-unused-vars": "off", // Off in favor of @typescript-eslint/no-unused-vars.
81+
eqeqeq: ["error", "always", { null: "ignore" }],
82+
camelcase: ["error", { properties: "never" }], // snake_case allowed in properties iif to satisfy an external contract / style
83+
84+
// Ideally, all these warning should be error - let's fix them in the future.
85+
"@typescript-eslint/no-unsafe-argument": "warn",
86+
"@typescript-eslint/no-unsafe-assignment": "warn",
87+
"@typescript-eslint/no-unsafe-call": "warn",
88+
"@typescript-eslint/no-unsafe-member-access": "warn",
89+
"@typescript-eslint/no-unsafe-return": "warn",
90+
"@typescript-eslint/restrict-template-expressions": "warn",
91+
"@typescript-eslint/no-explicit-any": "warn",
92+
"@typescript-eslint/no-redundant-type-constituents": "warn",
93+
"@typescript-eslint/no-base-to-string": "warn",
94+
"@typescript-eslint/no-duplicate-type-constituents": "warn",
95+
"@typescript-eslint/no-require-imports": "warn",
96+
"@typescript-eslint/no-empty-object-type": "warn",
97+
"@typescript-eslint/prefer-promise-reject-errors": "warn",
98+
},
99+
},
100+
{
101+
files: ["**/*.spec.ts", "**/*.spec.js", "spec/helper.ts", "scripts/bin-test/**/*.ts", "integration_test/**/*.ts"],
102+
languageOptions: {
103+
globals: {
104+
mocha: true,
105+
},
106+
},
107+
rules: {
108+
"@typescript-eslint/no-unused-expressions": "off",
109+
}
110+
},
111+
];

integration_test/functions/src/v1/pubsub-tests.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ export const pubsubTests: any = functions
1313
let testId: string;
1414
try {
1515
testId = m.json.testId;
16-
} catch (e) {
17-
/* Ignored. Covered in another test case that `event.data.json` works. */
16+
} catch (_e) {
17+
// Ignored. Covered in another test case that `event.data.json` works.
1818
}
1919

2020
return new TestSuite<PubsubMessage>("pubsub onPublish")

0 commit comments

Comments
 (0)