-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy patheslint.config.mjs
More file actions
166 lines (164 loc) · 4.25 KB
/
eslint.config.mjs
File metadata and controls
166 lines (164 loc) · 4.25 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
import js from "@eslint/js";
import { defineConfig, globalIgnores } from "eslint/config";
import eslintConfigPrettier from "eslint-config-prettier/flat";
import mozilla from "eslint-plugin-mozilla";
import importPlugin from "eslint-plugin-import";
import react from "eslint-plugin-react";
import reactHooks from "eslint-plugin-react-hooks";
import globals from "globals";
import ts from "typescript-eslint";
export default defineConfig([
globalIgnores(["dist/**/*", "**/eslint.config.mjs"]),
js.configs.recommended,
importPlugin.flatConfigs.recommended,
{
name: "nimbus-devtools/rules",
rules: {
curly: ["error", "all"],
"import/order": [
"error",
{
"newlines-between": "always",
groups: [
"builtin",
"external",
["index", "sibling", "parent", "internal"],
"object",
"type",
],
pathGroups: [
{
pattern: "src/**",
group: "internal",
},
],
},
],
},
},
{
name: "nimbus-devtools/node",
files: ["./bin/**.mjs"],
languageOptions: {
ecmaVersion: 2023,
sourceType: "module",
globals: {
...globals.node,
},
},
settings: {
"import/resolver": {
node: {
extensions: [".js", ".cjs", ".mjs"],
},
},
},
},
{
name: "nimbus-devtools/webext/background",
files: ["./src/background/**/*.js", "./src/contentScripts/**/*.js"],
languageOptions: {
ecmaVersion: 2023,
globals: {
...globals.browser,
...globals.webextensions,
},
},
},
{
name: "nimbus-devtools/webext/api",
files: ["./src/apis/**/*.js"],
extends: [
mozilla.configs["flat/recommended"],
// The mozilla/recommended/system-modules configuration only applies to
// sys.mjs files in mozilla-firefox/firefox, but it provides
// languageOptions and rules that we care about for privileged web
// extensions.
(function () {
const systemModules = mozilla.configs["flat/recommended"].find(
(rule) => rule.name === "mozilla/recommended/system-modules",
);
return {
rules: systemModules.rules,
languageOptions: systemModules.languageOptions,
};
})(),
],
languageOptions: {
globals: {
...globals.browser,
Cu: true,
ExtensionAPI: true,
ExtensionUtils: true,
},
},
rules: {
// WebIDL interfaces are not exposed to WebExtension APIs by default.
"mozilla/reject-importGlobalProperties": "off",
// Using let/const in global scope leads to redefinition errors.
"mozilla/lazy-getter-object-name": "off",
},
},
{
name: "nimbus-devtools/webext/api/nimbus",
files: ["./src/apis/nimbus.js"],
rules: {
"no-unused-vars": ["error", { varsIgnorePattern: "nimbus" }],
},
},
{
name: "nimbus-devtools/webext/api/messagingSystem",
files: ["./src/apis/messagingSystem.js"],
rules: {
"no-unused-vars": ["error", { varsIgnorePattern: "messagingSystem" }],
},
},
{
name: "nimbus-devtools/webext/ui",
files: ["./src/types/**/*.d.ts", "./src/ui/**/*.{ts,tsx}"],
languageOptions: {
parserOptions: {
ecmaFeatures: {
jsx: true,
},
projectService: true,
},
globals: {
...globals.browser,
},
},
extends: [
ts.configs.recommendedTypeChecked,
// ts.configs.stylisticTypeChecked,
importPlugin.flatConfigs.typescript,
react.configs.flat.recommended,
react.configs.flat["jsx-runtime"],
reactHooks.configs.flat.recommended,
],
settings: {
"import/resolver": {
typescript: true,
},
react: {
version: "18.3.27",
},
},
rules: {
"@typescript-eslint/no-misused-promises": [
"error",
{
checksVoidReturn: false,
},
],
"@typescript-eslint/no-explicit-any": [
"error",
{
ignoreRestArgs: true,
},
],
"@typescript-eslint/consistent-type-definitions": ["error", "type"],
"react-hooks/exhaustive-deps": "error",
},
},
eslintConfigPrettier,
]);