Skip to content

Commit a2ec44f

Browse files
committedFeb 19, 2024
feat: add eslint-plugin-n
1 parent 38b562f commit a2ec44f

File tree

7 files changed

+78
-9
lines changed

7 files changed

+78
-9
lines changed
 

‎package.json

+1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
"eslint-plugin-i": "^2.29.1",
4747
"eslint-plugin-jsonc": "^2.13.0",
4848
"eslint-plugin-markdown": "^3.0.1",
49+
"eslint-plugin-n": "^16.6.2",
4950
"eslint-plugin-prettier": "^5.1.3",
5051
"eslint-plugin-sort-keys": "^2.3.5",
5152
"eslint-plugin-unicorn": "^51.0.1",

‎pnpm-lock.yaml

+50
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎src/configs/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ export * from './imports'
44
export * from './javascript'
55
export * from './jsonc'
66
export * from './markdown'
7+
export * from './node'
78
export * from './prettier'
89
export * from './sort-keys'
910
export * from './sort'

‎src/configs/node.ts

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { pluginNode } from '../plugins'
2+
import type { FlatESLintConfigItem } from 'eslint-define-config'
3+
4+
export const node: FlatESLintConfigItem[] = [
5+
{
6+
plugins: {
7+
node: pluginNode,
8+
},
9+
rules: {
10+
'node/handle-callback-err': ['error', '^(err|error)$'],
11+
'node/no-deprecated-api': 'error',
12+
'node/no-exports-assign': 'error',
13+
'node/no-new-require': 'error',
14+
'node/no-path-concat': 'error',
15+
'node/no-unsupported-features/es-builtins': 'error',
16+
'node/prefer-global/buffer': ['error', 'never'],
17+
'node/prefer-global/process': ['error', 'never'],
18+
'node/process-exit-as-throw': 'error',
19+
},
20+
},
21+
]

‎src/configs/vue.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import process from 'node:process'
12
import { getPackageInfoSync } from 'local-pkg'
23
import { GLOB_VUE } from '../globs'
34
import { parserVue, pluginVue, tseslint } from '../plugins'

‎src/plugins.ts

+2-9
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/* eslint-disable import/first */
2+
// @ts-nocheck
23

34
export type InteropDefault<T> = T extends { default: infer U } ? U : T
45

@@ -11,22 +12,18 @@ import * as _pluginAntfu from 'eslint-plugin-antfu'
1112
export const pluginAntfu: typeof import('eslint-plugin-antfu').default =
1213
interopDefault(_pluginAntfu)
1314

14-
// @ts-expect-error missing types
1515
import * as _pluginComments from 'eslint-plugin-eslint-comments'
1616
export const pluginComments = interopDefault(_pluginComments)
1717

18-
// @ts-expect-error missing types
1918
import * as _pluginMarkdown from 'eslint-plugin-markdown'
2019
export const pluginMarkdown = interopDefault(_pluginMarkdown)
2120

2221
import tseslint from 'typescript-eslint'
2322
export { tseslint }
2423

25-
// @ts-expect-error missing types
2624
import * as _pluginUnicorn from 'eslint-plugin-unicorn'
2725
export const pluginUnicorn = interopDefault(_pluginUnicorn)
2826

29-
// @ts-expect-error missing types
3027
import * as _pluginVue from 'eslint-plugin-vue'
3128
export const pluginVue = interopDefault(_pluginVue)
3229

@@ -37,19 +34,15 @@ export const pluginUnocss: typeof import('@unocss/eslint-plugin').default =
3734
import * as _pluginPrettier from 'eslint-plugin-prettier'
3835
export const pluginPrettier = interopDefault(_pluginPrettier)
3936

40-
// @ts-expect-error missing types
4137
import * as _configPrettier from 'eslint-config-prettier'
4238
export const configPrettier = interopDefault(_configPrettier)
4339

44-
// @ts-expect-error missing types
4540
export * as pluginImport from 'eslint-plugin-i'
4641
export * as pluginJsonc from 'eslint-plugin-jsonc'
47-
// @ts-expect-error missing types
4842
export * as pluginUnusedImports from 'eslint-plugin-unused-imports'
49-
// @ts-expect-error missing types
5043
export * as pluginYml from 'eslint-plugin-yml'
51-
// @ts-expect-error missing types
5244
export * as pluginSortKeys from 'eslint-plugin-sort-keys'
45+
export * as pluginNode from 'eslint-plugin-n'
5346

5447
export * as parserVue from 'vue-eslint-parser'
5548
export * as parserYml from 'yaml-eslint-parser'

‎src/presets.ts

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
javascript,
77
jsonc,
88
markdown,
9+
node,
910
prettier,
1011
sortKeys,
1112
sortPackageJson,
@@ -25,6 +26,7 @@ export const presetJavaScript = [
2526
...comments,
2627
...imports,
2728
...unicorn,
29+
...node,
2830
]
2931
/** Includes basic json(c) file support and sorting json keys */
3032
export const presetJsonc = [...jsonc, ...sortPackageJson, ...sortTsconfig]

0 commit comments

Comments
 (0)
Please sign in to comment.