1
- import globals from "globals" ; // eslint-disable-line allowed/dependencies -- comes with eslint
2
- import jsPlugin from "@eslint/js" ; // eslint-disable-line allowed/dependencies -- comes with eslint
1
+ import globals from "globals" ;
2
+ import jsPlugin from "@eslint/js" ;
3
3
import tsPlugin from "typescript-eslint" ;
4
4
import prettierOverrides from "eslint-config-prettier" ;
5
5
import prettierRules from "eslint-plugin-prettier/recommended" ;
6
6
import allowedDepsPlugin from "eslint-plugin-allowed-dependencies" ;
7
7
import { fileURLToPath } from "node:url" ;
8
8
import { dirname , join } from "node:path" ;
9
+ import { builtinModules } from "node:module" ;
9
10
10
- const root = dirname ( fileURLToPath ( import . meta. url ) ) ;
11
- const releaseDir = join ( root , "express-zod-api" ) ;
12
- const exampleDir = join ( root , "example" ) ;
11
+ const releaseDir = join (
12
+ dirname ( fileURLToPath ( import . meta. url ) ) ,
13
+ "express-zod-api" ,
14
+ ) ;
15
+
16
+ const importConcerns = [
17
+ {
18
+ selector :
19
+ "ImportDeclaration[source.value='ramda'] > ImportSpecifier, " +
20
+ "ImportDeclaration[source.value='ramda'] > ImportDefaultSpecifier" ,
21
+ message : "use import * as R from 'ramda'" ,
22
+ } ,
23
+ ...builtinModules . map ( ( mod ) => ( {
24
+ selector : `ImportDeclaration[source.value='${ mod } ']` ,
25
+ message : `use node:${ mod } for the built-in module` ,
26
+ } ) ) ,
27
+ ] ;
13
28
14
29
const performanceConcerns = [
15
30
{
@@ -20,12 +35,6 @@ const performanceConcerns = [
20
35
selector : "MemberExpression[object.name='process'][property.name='env']" , // #2144
21
36
message : "Reading process.env is slow and must be memoized" ,
22
37
} ,
23
- {
24
- selector :
25
- "ImportDeclaration[source.value='ramda'] > ImportSpecifier, " +
26
- "ImportDeclaration[source.value='ramda'] > ImportDefaultSpecifier" ,
27
- message : "use import * as R from 'ramda'" ,
28
- } ,
29
38
{
30
39
selector : "MemberExpression[object.name='R'] > Identifier[name='toPairs']" , // #2168
31
40
message : "R.toPairs() is 1.1x slower than Object.entries()" ,
@@ -173,20 +182,19 @@ export default tsPlugin.config(
173
182
rules : {
174
183
curly : [ "warn" , "multi-or-nest" , "consistent" ] ,
175
184
"@typescript-eslint/no-shadow" : "warn" ,
176
- "allowed/dependencies" : [
177
- "error" ,
178
- { development : true , ignore : [ "express-zod-api" ] , packageDir : root } ,
179
- { development : true , packageDir : releaseDir } ,
180
- { packageDir : exampleDir } ,
181
- ] ,
185
+ "no-restricted-syntax" : [ "warn" , ...importConcerns ] ,
182
186
} ,
183
187
} ,
184
188
{
185
189
name : "source/all" ,
186
190
files : [ "express-zod-api/src/*.ts" ] ,
187
191
rules : {
188
192
"allowed/dependencies" : [ "error" , { packageDir : releaseDir } ] ,
189
- "no-restricted-syntax" : [ "warn" , ...performanceConcerns ] ,
193
+ "no-restricted-syntax" : [
194
+ "warn" ,
195
+ ...importConcerns ,
196
+ ...performanceConcerns ,
197
+ ] ,
190
198
} ,
191
199
} ,
192
200
{
@@ -206,24 +214,12 @@ export default tsPlugin.config(
206
214
rules : {
207
215
"no-restricted-syntax" : [
208
216
"warn" ,
217
+ ...importConcerns ,
209
218
...performanceConcerns ,
210
219
...tsFactoryConcerns ,
211
220
] ,
212
221
} ,
213
222
} ,
214
- {
215
- name : "source/migration" ,
216
- files : [
217
- "express-zod-api/src/migration.ts" ,
218
- "express-zod-api/tests/migration.spec.ts" ,
219
- ] ,
220
- rules : {
221
- "allowed/dependencies" : [
222
- "error" ,
223
- { ignore : [ "^@typescript-eslint" , "^\\." ] , packageDir : releaseDir } ,
224
- ] ,
225
- } ,
226
- } ,
227
223
{
228
224
name : "tests/all" ,
229
225
files : [ "express-zod-api/tests/*.ts" , "express-zod-api/vitest.setup.ts" ] ,
0 commit comments