Skip to content

Commit

Permalink
feat: add eslint-plugin-n
Browse files Browse the repository at this point in the history
  • Loading branch information
sxzz committed Feb 19, 2024
1 parent 38b562f commit a2ec44f
Show file tree
Hide file tree
Showing 7 changed files with 78 additions and 9 deletions.
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -46,6 +46,7 @@
"eslint-plugin-i": "^2.29.1",
"eslint-plugin-jsonc": "^2.13.0",
"eslint-plugin-markdown": "^3.0.1",
"eslint-plugin-n": "^16.6.2",
"eslint-plugin-prettier": "^5.1.3",
"eslint-plugin-sort-keys": "^2.3.5",
"eslint-plugin-unicorn": "^51.0.1",
Expand Down
50 changes: 50 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/configs/index.ts
Expand Up @@ -4,6 +4,7 @@ export * from './imports'
export * from './javascript'
export * from './jsonc'
export * from './markdown'
export * from './node'
export * from './prettier'
export * from './sort-keys'
export * from './sort'
Expand Down
21 changes: 21 additions & 0 deletions src/configs/node.ts
@@ -0,0 +1,21 @@
import { pluginNode } from '../plugins'
import type { FlatESLintConfigItem } from 'eslint-define-config'

export const node: FlatESLintConfigItem[] = [
{
plugins: {
node: pluginNode,
},
rules: {
'node/handle-callback-err': ['error', '^(err|error)$'],
'node/no-deprecated-api': 'error',
'node/no-exports-assign': 'error',
'node/no-new-require': 'error',
'node/no-path-concat': 'error',
'node/no-unsupported-features/es-builtins': 'error',
'node/prefer-global/buffer': ['error', 'never'],
'node/prefer-global/process': ['error', 'never'],
'node/process-exit-as-throw': 'error',
},
},
]
1 change: 1 addition & 0 deletions src/configs/vue.ts
@@ -1,3 +1,4 @@
import process from 'node:process'
import { getPackageInfoSync } from 'local-pkg'
import { GLOB_VUE } from '../globs'
import { parserVue, pluginVue, tseslint } from '../plugins'
Expand Down
11 changes: 2 additions & 9 deletions src/plugins.ts
@@ -1,4 +1,5 @@
/* eslint-disable import/first */
// @ts-nocheck

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

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

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

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

import tseslint from 'typescript-eslint'
export { tseslint }

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

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

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

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

// @ts-expect-error missing types
export * as pluginImport from 'eslint-plugin-i'
export * as pluginJsonc from 'eslint-plugin-jsonc'
// @ts-expect-error missing types
export * as pluginUnusedImports from 'eslint-plugin-unused-imports'
// @ts-expect-error missing types
export * as pluginYml from 'eslint-plugin-yml'
// @ts-expect-error missing types
export * as pluginSortKeys from 'eslint-plugin-sort-keys'
export * as pluginNode from 'eslint-plugin-n'

export * as parserVue from 'vue-eslint-parser'
export * as parserYml from 'yaml-eslint-parser'
Expand Down
2 changes: 2 additions & 0 deletions src/presets.ts
Expand Up @@ -6,6 +6,7 @@ import {
javascript,
jsonc,
markdown,
node,
prettier,
sortKeys,
sortPackageJson,
Expand All @@ -25,6 +26,7 @@ export const presetJavaScript = [
...comments,
...imports,
...unicorn,
...node,
]
/** Includes basic json(c) file support and sorting json keys */
export const presetJsonc = [...jsonc, ...sortPackageJson, ...sortTsconfig]
Expand Down

0 comments on commit a2ec44f

Please sign in to comment.