Skip to content

Commit a4dfd73

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

File tree

9 files changed

+782
-593
lines changed

9 files changed

+782
-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: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
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+
"@typescript-eslint": require("@typescript-eslint/eslint-plugin"),
51+
"jsdoc": require("eslint-plugin-jsdoc"),
52+
"prettier": require("eslint-plugin-prettier"),
53+
},
54+
rules: {
55+
"jsdoc/newline-after-description": "off",
56+
"jsdoc/require-jsdoc": ["warn", { publicOnly: true }],
57+
"jsdoc/check-tag-names": ["warn", { definedTags: ["alpha", "remarks", "typeParam", "packageDocumentation", "hidden"] }],
58+
"no-restricted-globals": ["error", "name", "length"],
59+
"prefer-arrow-callback": "error",
60+
"prettier/prettier": "error",
61+
"require-atomic-updates": "off",
62+
"require-jsdoc": "off",
63+
"valid-jsdoc": "off",
64+
"no-prototype-builtins": "warn",
65+
"no-useless-escape": "warn",
66+
"prefer-promise-reject-errors": "warn",
67+
},
68+
},
69+
{
70+
files: ["**/*.ts"],
71+
rules: {
72+
"jsdoc/require-param-type": "off",
73+
"jsdoc/require-returns-type": "off",
74+
"jsdoc/require-param": "off",
75+
"jsdoc/require-returns": "off",
76+
"@typescript-eslint/no-invalid-this": "error",
77+
"@typescript-eslint/no-unused-vars": ["error", { argsIgnorePattern: "^_", caughtErrorsIgnorePattern: "^_" }],
78+
"@typescript-eslint/no-misused-promises": "warn",
79+
"no-invalid-this": "off",
80+
"no-unused-vars": "off",
81+
eqeqeq: ["error", "always", { null: "ignore" }],
82+
camelcase: ["error", { properties: "never" }],
83+
"@typescript-eslint/no-unsafe-argument": "warn",
84+
"@typescript-eslint/no-unsafe-assignment": "warn",
85+
"@typescript-eslint/no-unsafe-call": "warn",
86+
"@typescript-eslint/no-unsafe-member-access": "warn",
87+
"@typescript-eslint/no-unsafe-return": "warn",
88+
"@typescript-eslint/restrict-template-expressions": "warn",
89+
"@typescript-eslint/no-explicit-any": "warn",
90+
"@typescript-eslint/no-redundant-type-constituents": "warn",
91+
"@typescript-eslint/no-base-to-string": "warn",
92+
"@typescript-eslint/no-duplicate-type-constituents": "warn",
93+
"@typescript-eslint/no-require-imports": "warn",
94+
"@typescript-eslint/no-empty-object-type": "warn",
95+
"@typescript-eslint/prefer-promise-reject-errors": "warn",
96+
},
97+
},
98+
{
99+
files: ["**/*.spec.ts", "**/*.spec.js", "spec/helper.ts", "scripts/bin-test/**/*.ts", "integration_test/**/*.ts"],
100+
languageOptions: {
101+
globals: {
102+
mocha: true,
103+
},
104+
},
105+
rules: {
106+
"@typescript-eslint/no-unused-expressions": "off",
107+
}
108+
},
109+
];

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+
res.status(200).send();
1818
}
1919

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

0 commit comments

Comments
 (0)