-
Notifications
You must be signed in to change notification settings - Fork 204
/
Copy patheslint.config.js
135 lines (133 loc) · 4.31 KB
/
eslint.config.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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
/* eslint-disable n/no-extraneous-import */
import js from "@eslint/js";
import keybr from "@keybr/scripts/eslint-plugin-keybr.js";
import confusingBrowserGlobals from "confusing-browser-globals";
import formatjs from "eslint-plugin-formatjs";
import node from "eslint-plugin-n";
import react from "eslint-plugin-react";
import reactHooks from "eslint-plugin-react-hooks";
import simpleImportSort from "eslint-plugin-simple-import-sort";
import globals from "globals";
import ts from "typescript-eslint";
import pkg from "./package.json" with { type: "json" };
export default [
{
files: ["**/*.{js,ts,tsx}"],
},
{
ignores: [
"**/.types/",
"**/build/",
"**/sandbox/",
"**/tmp/",
"root/",
"packages/keybr-code/lib/parser.js",
],
},
js.configs["recommended"],
...ts.configs["recommended"],
react.configs.flat["recommended"],
react.configs.flat["jsx-runtime"],
node.configs["flat/recommended-module"],
keybr.configs["recommended"],
{
ignores: [
"packages/server/**",
"packages/server-cli/**",
"**/*.test.ts",
"**/*.test.tsx",
],
plugins: { "react-hooks": reactHooks },
rules: reactHooks.configs.recommended.rules,
},
{
plugins: {
"simple-import-sort": simpleImportSort,
"formatjs": formatjs,
},
rules: {
// configure simple-import-sort
"simple-import-sort/imports": [
"error",
{ groups: [["^\\u0000", "^node:", "^@?\\w", "^", "^\\."]] },
],
"simple-import-sort/exports": ["error"],
// configure eslint
"eqeqeq": ["error", "always", { null: "never" }],
"no-constant-condition": ["error", { checkLoops: false }],
"no-implicit-coercion": "error",
"no-restricted-globals": ["error", ...confusingBrowserGlobals],
"prefer-const": "off",
// configure @typescript-eslint
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-inferrable-types": [
"error",
{ ignoreParameters: true, ignoreProperties: true },
],
"@typescript-eslint/no-namespace": "off",
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/no-unused-vars": "off",
"@typescript-eslint/consistent-type-definitions": ["error", "type"],
"@typescript-eslint/consistent-type-imports": [
"error",
{ prefer: "type-imports", fixStyle: "inline-type-imports" },
],
// configure react
"react/jsx-boolean-value": ["error", "always"],
"react/jsx-curly-brace-presence": ["error", "never"],
"react/jsx-fragments": ["error", "syntax"],
"react/jsx-handler-names": ["error", {}],
"react/no-unknown-property": ["error", { ignore: ["prefix"] }],
// configure formatjs
"formatjs/enforce-id": "error",
"formatjs/enforce-default-message": ["error", "literal"],
"formatjs/enforce-placeholders": [
"error",
{ ignoreList: "h1,h2,h3,p,ol,ul,li,dl,dt,dd,em,strong,br".split(/,/g) },
],
"formatjs/no-invalid-icu": "error",
"formatjs/no-multiple-whitespaces": "error",
// configure node
"n/file-extension-in-import": ["error", "always"],
"n/hashbang": "off",
"n/no-process-exit": "off",
"n/no-unsupported-features/node-builtins": "off",
"n/prefer-global/buffer": ["error", "always"],
"n/prefer-global/console": ["error", "always"],
"n/prefer-global/process": ["error", "always"],
"n/prefer-global/text-decoder": ["error", "always"],
"n/prefer-global/text-encoder": ["error", "always"],
"n/prefer-global/url": ["error", "always"],
"n/prefer-global/url-search-params": ["error", "always"],
"n/prefer-node-protocol": "error",
"n/prefer-promises/dns": "error",
"n/prefer-promises/fs": "error",
},
languageOptions: {
globals: {
...globals.browser,
...globals.node,
},
parserOptions: {
experimentalDecorators: true,
emitDecoratorMetadata: true,
},
},
settings: {
react: {
version: "detect",
},
node: {
version: ">=22",
allowModules: [
...Object.keys(pkg.dependencies),
...Object.keys(pkg.devDependencies),
],
typescriptExtensionMap: [
[".ts", ".ts"],
[".tsx", ".tsx"],
],
},
},
},
];