-
Notifications
You must be signed in to change notification settings - Fork 59
Expand file tree
/
Copy patheslint.config.js
More file actions
176 lines (159 loc) · 5.62 KB
/
eslint.config.js
File metadata and controls
176 lines (159 loc) · 5.62 KB
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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
import path from "node:path";
import { fileURLToPath } from "node:url";
import { fixupPluginRules } from "@eslint/compat";
import { FlatCompat } from "@eslint/eslintrc";
import js from "@eslint/js";
import stylistic from "@stylistic/eslint-plugin";
import typescriptEslint from "@typescript-eslint/eslint-plugin";
import tsParser from "@typescript-eslint/parser";
import importPlugin from "eslint-plugin-import";
import node from "eslint-plugin-node";
import globals from "globals";
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all
});
export default [{
ignores: ["Pages/**"],
}, {
files: ["**/*.ts","**/*.js"],
}, ...compat.extends("eslint:recommended", "plugin:@typescript-eslint/recommended"), {
// Jest test files configuration
files: ["**/*.test.{js,ts}", "**/*.spec.{js,ts}", "**/test/**", "**/tests/**"],
languageOptions: {
globals: {
...globals.browser,
...globals.jest,
},
},
}, {
plugins: {
"@typescript-eslint": typescriptEslint,
"@stylistic": stylistic,
node,
import: fixupPluginRules(importPlugin),
},
languageOptions: {
globals: {
...globals.browser,
// Office.js globals
Office: "readonly",
// Webpack defined globals (replaced at build time)
__AIKEY__: "readonly",
__BUILDTIME__: "readonly",
__VERSION__: "readonly",
// Node.js/TypeScript globals used in specific contexts
process: "readonly",
global: "readonly",
NodeJS: "readonly",
// DOM/Web API globals that ESLint doesn't recognize by default
EventListenerOrEventListenerObject: "readonly",
AddEventListenerOptions: "readonly",
PermissionDescriptor: "readonly",
PermissionName: "readonly",
},
parser: tsParser,
ecmaVersion: "latest",
sourceType: "module",
},
settings: {
"import/resolver": {
typescript: {
project: "./tsconfig.json",
},
},
},
rules: {
indent: ["error", 4, {
SwitchCase: 1,
}],
"linebreak-style": ["error", "windows"],
quotes: ["error", "double"],
semi: ["error", "always"],
"max-classes-per-file": ["error", 1],
"no-duplicate-imports": "error",
"no-inner-declarations": "error",
"no-unmodified-loop-condition": "error",
"block-scoped-var": "error",
"no-undef": "error", // Catch undefined variables/functions
"no-global-assign": "error", // Prevent accidental global overwrites
camelcase: ["error", {
properties: "always",
}],
"sort-imports": ["error", {
ignoreDeclarationSort: true,
}],
"@stylistic/no-multiple-empty-lines": ["error", {
max: 1,
maxEOF: 0,
maxBOF: 0,
}],
"@stylistic/no-trailing-spaces": "error",
"@typescript-eslint/no-explicit-any": "error",
"@typescript-eslint/no-inferrable-types": "error",
"@typescript-eslint/naming-convention": ["error", {
selector: "default",
format: ["camelCase"],
}, {
selector: "variableLike",
format: ["camelCase"],
filter: {
regex: "^(__filename|__dirname)$",
match: false
}
}, {
selector: "variable",
filter: {
regex: "^(__filename|__dirname)$",
match: true
},
format: null
}, {
selector: "import",
format: ["camelCase", "PascalCase"]
}, {
selector: "typeLike",
format: ["PascalCase"],
}, {
selector: "enumMember",
format: ["PascalCase"],
}, {
selector: "property",
format: ["camelCase"],
filter: {
regex: "^(@|import/|linebreak-style|max-classes-per-file|no-duplicate-imports|no-inner-declarations|no-unmodified-loop-condition|block-scoped-var|sort-imports|newlines-between|SwitchCase|no-undef|no-global-assign|Office|NodeJS|EventListenerOrEventListenerObject|AddEventListenerOptions|PermissionDescriptor|PermissionName|__[A-Z_]+__|\\^.+\\$)",
match: false
}
}, {
selector: "property",
filter: {
regex: "^(@|import/|linebreak-style|max-classes-per-file|no-duplicate-imports|no-inner-declarations|no-unmodified-loop-condition|block-scoped-var|sort-imports|newlines-between|SwitchCase|no-undef|no-global-assign|Office|NodeJS|EventListenerOrEventListenerObject|AddEventListenerOptions|PermissionDescriptor|PermissionName|__[A-Z_]+__|\\^.+\\$)",
match: true
},
format: null
}, {
selector: "method",
format: ["camelCase"],
}],
"import/no-unresolved": "error",
"import/no-named-as-default-member": "off",
"import/order": ["error", {
groups: [
"builtin",
"external",
"internal",
["sibling", "parent"],
"index",
"unknown",
],
"newlines-between": "always",
alphabetize: {
order: "asc",
caseInsensitive: true,
},
}],
},
}];