/
eslint.config.js
154 lines (152 loc) · 4.87 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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
// @ts-expect-error There are no types
import js from "@eslint/js";
// @ts-expect-error There are no types
import prettierConfig from "eslint-config-prettier";
// @ts-expect-error There are no types
import arrayFuncPlugin from "eslint-plugin-array-func";
import nodePlugin from "eslint-plugin-n";
// @ts-expect-error There are no types
import perfectionistNatural from "eslint-plugin-perfectionist/configs/recommended-natural";
import * as regexpPlugin from "eslint-plugin-regexp";
// @ts-expect-error There are no types, Security works the eslint 9
import securityPlugin from "eslint-plugin-security";
// @ts-expect-error There are no types
import unicornPlugin from "eslint-plugin-unicorn";
import vitest from "eslint-plugin-vitest";
import globals from "globals";
import tseslint from "typescript-eslint";
/**
* Plugins to re-implement when they support Flat Config
* "eslint-plugin-deprecation": https://github.com/gund/eslint-plugin-deprecation/pull/79,
* "eslint-plugin-eslint-comments": https://github.com/eslint-community/eslint-plugin-eslint-comments/pull/200
* "eslint-plugin-no-unsanitized": https://github.com/mozilla/eslint-plugin-no-unsanitized/issues/234,
* "eslint-plugin-promise": https://github.com/eslint-community/eslint-plugin-promise/issues/449
* "eslint-plugin-sonarjs": https://github.com/SonarSource/eslint-plugin-sonarjs/issues/454
*
* Import will eventually come back
*/
export default tseslint.config(
js.configs.recommended,
...tseslint.configs.strictTypeChecked,
...tseslint.configs.stylisticTypeChecked,
nodePlugin.configs["flat/recommended"],
unicornPlugin.configs["flat/recommended"],
arrayFuncPlugin.configs.recommended,
// @ts-expect-error This is the correct type
regexpPlugin.configs["flat/recommended"],
securityPlugin.configs.recommended,
perfectionistNatural,
prettierConfig,
{
languageOptions: {
globals: {
...globals.node,
},
parserOptions: {
project: true,
},
},
linterOptions: {
reportUnusedDisableDirectives: "warn",
},
rules: {
// Disable import/extensions because Typescript handles this now
// "import/extensions": "off",
/* Disable @typescript-eslint/member-ordering because of perfectionist */
"@typescript-eslint/member-ordering": "off",
"@typescript-eslint/no-unused-vars": "warn",
/* Array Func prefers array.from, however, Unicorn prefers spread. Spread is better */
"array-func/prefer-array-from": "off",
/* Dot notation is disabled via typescript, so disable it here */
// https://typescript-eslint.io/rules/dot-notation/
"dot-notation": "off",
// "eslint-comments/disable-enable-pair": "off",
// Don't prefer the default export
// "import/prefer-default-export": ["off"],
/* Typescript eslint has it's own @typescript-eslint/no-shadow rule */
"no-shadow": "off",
/* Disable no-unused-vars because of @typescript-eslint/no-unused-vars */
"no-unused-vars": "off",
/* Make sure nulls are last in types */
"perfectionist/sort-union-types": [
"error",
{
"nullable-last": true,
},
],
/* Disable @typescript-eslint/member-ordering because of perfectionist */
"sort-keys": "off",
/* I want to use named imports for path */
"unicorn/import-style": [
"error",
{
styles: {
"node:path": {
named: true,
},
},
},
],
/* For database stuff, I need nulls */
"unicorn/no-null": "off",
/* Disable switch curly braces */
"unicorn/switch-case-braces": "off",
},
settings: {
/*
"import/parsers": {
"@typescript-eslint/parser": [".ts", ".tsx"],
},
"import/resolver": {
// user <root>/tsconfig.json
node: true,
typescript: true,
},
*/
node: {
// Make sure we are looking for Typescript files as well
tryExtensions: [
".js",
".jsx",
".mjs",
".cjs",
".ts",
".tsx",
".json",
".d.ts",
],
},
},
},
{
extends: [vitest.configs.recommended],
files: ["tests/**", "test/**"],
languageOptions: {
globals: {
...vitest.environments.env.globals,
},
},
rules: {
/* Don't require items to be published for tests */
"n/no-unpublished-import": "off",
},
settings: {
vitest: {
typecheck: true,
},
},
},
{
// Disable typechecking for Javascript files
extends: [tseslint.configs.disableTypeChecked],
files: ["**/*.js"],
},
{
extends: [tseslint.configs.disableTypeChecked],
files: ["eslint.config.js", "vitest.config.ts"],
rules: {
// Everything should be included in @sparticuz/eslint-config's dependencies.
"n/no-unpublished-import": "off",
},
},
);