forked from cloudflare/workers-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.eslintrc.js
117 lines (115 loc) · 2.68 KB
/
.eslintrc.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
const fs = require("fs");
const path = require("path");
function* walkTsConfigs(root) {
const entries = fs.readdirSync(root, { withFileTypes: true });
for (const entry of entries) {
if (entry.name === "node_modules") continue; // Ignore `node_modules`s
const entryPath = path.join(root, entry.name);
if (entry.isDirectory()) {
yield* walkTsConfigs(entryPath);
} else if (entry.name === "tsconfig.json") {
yield entryPath;
}
}
}
module.exports = {
parser: "@typescript-eslint/parser",
parserOptions: {
ecmaVersion: 2020,
project: Array.from(walkTsConfigs(__dirname)),
sourceType: "module",
},
settings: {
react: {
version: "detect",
},
},
plugins: [
"@typescript-eslint",
"eslint-plugin-react",
"eslint-plugin-react-hooks",
"import",
"unused-imports",
],
overrides: [
{
files: ["*.ts", "*.tsx"],
extends: [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:react/recommended",
"plugin:react-hooks/recommended",
"plugin:import/typescript",
],
rules: {
"no-empty": "off",
"no-empty-function": "off",
"no-mixed-spaces-and-tabs": ["error", "smart-tabs"],
"no-shadow": "error",
"require-yield": "off",
"@typescript-eslint/consistent-type-imports": ["error"],
"@typescript-eslint/no-empty-function": "off",
"@typescript-eslint/no-explicit-any": "error",
"@typescript-eslint/no-floating-promises": "error",
"@typescript-eslint/no-unused-vars": "off",
"import/order": [
"warn",
{
groups: [
"builtin",
"external",
"internal",
"parent",
"sibling",
"index",
"object",
"type",
],
alphabetize: {
order: "asc",
},
},
],
"unused-imports/no-unused-imports": "error",
"unused-imports/no-unused-vars": [
"warn",
{
vars: "all",
varsIgnorePattern: "^_",
args: "after-used",
argsIgnorePattern: "^_",
},
],
},
},
{
files: "packages/wrangler/src/**/*.ts",
excludedFiles: "*.test.ts",
rules: {
"no-restricted-globals": [
"error",
{
name: "__dirname",
message: "Use `getBasePath()` instead.",
},
{
name: "__filename",
message: "Use `getBasePath()` instead.",
},
],
},
},
],
ignorePatterns: [
"packages/wrangler/vendor",
"packages/wrangler/*-dist",
"packages/wrangler/pages/functions/template-worker.ts",
"packages/wrangler/templates",
"packages/wrangler/emitted-types",
"examples/remix-pages-app/public",
"packages/jest-environment-wrangler/dist",
"packages/wrangler-devtools/built-devtools",
"packages/wranglerjs-compat-webpack-plugin/lib",
],
root: true,
};