diff --git a/package.json b/package.json index 1c66904..9581ebf 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index b028c71..56d21b4 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -29,6 +29,9 @@ dependencies: eslint-plugin-markdown: specifier: ^3.0.1 version: 3.0.1(eslint@8.56.0) + eslint-plugin-n: + specifier: ^16.6.2 + version: 16.6.2(eslint@8.56.0) eslint-plugin-prettier: specifier: ^5.1.3 version: 5.1.3(eslint-config-prettier@9.1.0)(eslint@8.56.0)(prettier@3.2.5) @@ -916,6 +919,12 @@ packages: engines: {node: '>=6'} dev: false + /builtins@5.0.1: + resolution: {integrity: sha512-qwVpFEHNfhYJIzNRBvd2C1kyo6jz3ZSMPyyuR47OPdiKWlbYnZNyDWuyR175qDnAJLiCo5fBBqPb3RiXgWlkOQ==} + dependencies: + semver: 7.5.4 + dev: false + /bumpp@9.3.0: resolution: {integrity: sha512-P46VikoEZadYCqx7mbClKlaJnOyvc+JfRJPRf1YwlOjwqeYmutgFe1w9hvfXe819VhpU0N0TNXtxyVAUlAgaNA==} engines: {node: '>=10'} @@ -1206,6 +1215,15 @@ packages: resolution: {integrity: sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==} engines: {node: '>=10'} + /eslint-compat-utils@0.1.2(eslint@8.56.0): + resolution: {integrity: sha512-Jia4JDldWnFNIru1Ehx1H5s9/yxiRHY/TimCuUc0jNexew3cF1gI6CYZil1ociakfWO3rRqFjl1mskBblB3RYg==} + engines: {node: '>=12'} + peerDependencies: + eslint: '>=6.0.0' + dependencies: + eslint: 8.56.0 + dev: false + /eslint-compat-utils@0.4.1(eslint@8.56.0): resolution: {integrity: sha512-5N7ZaJG5pZxUeNNJfUchurLVrunD1xJvyg5kYOIVF8kg1f3ajTikmAu/5fZ9w100omNPOoMjngRszh/Q/uFGMg==} engines: {node: '>=12'} @@ -1277,6 +1295,18 @@ packages: eslint: 8.56.0 dev: false + /eslint-plugin-es-x@7.5.0(eslint@8.56.0): + resolution: {integrity: sha512-ODswlDSO0HJDzXU0XvgZ3lF3lS3XAZEossh15Q2UHjwrJggWeBoKqqEsLTZLXl+dh5eOAozG0zRcYtuE35oTuQ==} + engines: {node: ^14.18.0 || >=16.0.0} + peerDependencies: + eslint: '>=8' + dependencies: + '@eslint-community/eslint-utils': 4.4.0(eslint@8.56.0) + '@eslint-community/regexpp': 4.10.0 + eslint: 8.56.0 + eslint-compat-utils: 0.1.2(eslint@8.56.0) + dev: false + /eslint-plugin-eslint-comments@3.2.0(eslint@8.56.0): resolution: {integrity: sha512-0jkOl0hfojIHHmEHgmNdqv4fmh7300NdpA9FFpF7zaoLvB/QeXOGNLIo86oAveJFrfB1p05kC8hpEMHM8DwWVQ==} engines: {node: '>=6.5.0'} @@ -1338,6 +1368,26 @@ packages: - supports-color dev: false + /eslint-plugin-n@16.6.2(eslint@8.56.0): + resolution: {integrity: sha512-6TyDmZ1HXoFQXnhCTUjVFULReoBPOAjpuiKELMkeP40yffI/1ZRO+d9ug/VC6fqISo2WkuIBk3cvuRPALaWlOQ==} + engines: {node: '>=16.0.0'} + peerDependencies: + eslint: '>=7.0.0' + dependencies: + '@eslint-community/eslint-utils': 4.4.0(eslint@8.56.0) + builtins: 5.0.1 + eslint: 8.56.0 + eslint-plugin-es-x: 7.5.0(eslint@8.56.0) + get-tsconfig: 4.7.2 + globals: 13.24.0 + ignore: 5.3.0 + is-builtin-module: 3.2.1 + is-core-module: 2.13.1 + minimatch: 3.1.2 + resolve: 1.22.8 + semver: 7.5.4 + dev: false + /eslint-plugin-prettier@5.1.3(eslint-config-prettier@9.1.0)(eslint@8.56.0)(prettier@3.2.5): resolution: {integrity: sha512-C9GCVAs4Eq7ZC/XFQHITLiHJxQngdtraXaM+LoUFoFp/lHNl2Zn8f3WQbe9HvTBBQ9YnKFB0/2Ajdqwo5D1EAw==} engines: {node: ^14.18.0 || >=16.0.0} diff --git a/src/configs/index.ts b/src/configs/index.ts index 3b3ed8d..071af7a 100644 --- a/src/configs/index.ts +++ b/src/configs/index.ts @@ -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' diff --git a/src/configs/node.ts b/src/configs/node.ts new file mode 100644 index 0000000..4abb23a --- /dev/null +++ b/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', + }, + }, +] diff --git a/src/configs/vue.ts b/src/configs/vue.ts index 273d3bc..8d85842 100644 --- a/src/configs/vue.ts +++ b/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' diff --git a/src/plugins.ts b/src/plugins.ts index 3e309e3..1a5c4f5 100644 --- a/src/plugins.ts +++ b/src/plugins.ts @@ -1,4 +1,5 @@ /* eslint-disable import/first */ +// @ts-nocheck export type InteropDefault = T extends { default: infer U } ? U : T @@ -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) @@ -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' diff --git a/src/presets.ts b/src/presets.ts index e48aa76..73f0dec 100644 --- a/src/presets.ts +++ b/src/presets.ts @@ -6,6 +6,7 @@ import { javascript, jsonc, markdown, + node, prettier, sortKeys, sortPackageJson, @@ -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]