Skip to content
This repository was archived by the owner on Mar 7, 2025. It is now read-only.

Commit 122f70b

Browse files
committed
Generate definitions for eslint-plugin-node
1 parent bf3110b commit 122f70b

35 files changed

+1452
-255
lines changed

CHANGELOG.md

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
# Next
22

3-
[diff](https://github.com/Shinigami92/eslint-define-config/compare/1.1.0...main)
3+
[diff](https://github.com/Shinigami92/eslint-define-config/compare/1.1.1...main)
4+
5+
# 1.1.1
6+
7+
[diff](https://github.com/Shinigami92/eslint-define-config/compare/1.1.0...1.1.1)
8+
9+
- Automatically generate rule definitions for `node`
10+
- Fix rules JSDoc hovering
411

512
# 1.1.0
613

@@ -11,6 +18,7 @@
1118
- `@typescript-eslint`
1219
- `jsdoc`
1320
- `spellcheck`
21+
- `unicorn`
1422
- `vue`
1523

1624
[#69]: https://github.com/Shinigami92/eslint-define-config/pull/69

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "eslint-define-config",
3-
"version": "1.1.0",
3+
"version": "1.1.1",
44
"description": "Provide a defineConfig function for .eslintrc.js files",
55
"main": "src/index.js",
66
"scripts": {
@@ -49,6 +49,7 @@
4949
"eslint-config-prettier": "~8.3.0",
5050
"eslint-plugin-inclusive-language": "~2.1.1",
5151
"eslint-plugin-jsdoc": "~36.1.0",
52+
"eslint-plugin-node": "~11.1.0",
5253
"eslint-plugin-prettier": "~4.0.0",
5354
"eslint-plugin-spellcheck": "~0.0.19",
5455
"eslint-plugin-unicorn": "~36.0.0",

pnpm-lock.yaml

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

scripts/generate-rule-files.ts

+6
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import * as eslint from 'eslint';
66
// @ts-expect-error
77
import eslintPluginJSDoc from 'eslint-plugin-jsdoc';
88
// @ts-expect-error
9+
import eslintPluginNode from 'eslint-plugin-node';
10+
// @ts-expect-error
911
import eslintPluginSpellcheck from 'eslint-plugin-spellcheck';
1012
// @ts-expect-error
1113
import eslintPluginUnicorn from 'eslint-plugin-unicorn';
@@ -51,6 +53,10 @@ const generationMap: Record<string, Plugin> = {
5153
name: 'JSDoc',
5254
rules: (eslintPluginJSDoc as Plugin).rules
5355
},
56+
node: {
57+
name: 'Node',
58+
rules: (eslintPluginNode as Plugin).rules
59+
},
5460
spellcheck: {
5561
name: 'Spellcheck',
5662
rules: (eslintPluginSpellcheck as Plugin).rules

src/rules/node/callback-return.d.ts

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import type { RuleConfig } from '../rule-config';
2+
3+
/**
4+
* Option.
5+
*/
6+
export type CallbackReturnOption = string[];
7+
8+
/**
9+
* Options.
10+
*/
11+
export type CallbackReturnOptions = [CallbackReturnOption?];
12+
13+
/**
14+
* Require `return` statements after callbacks.
15+
*
16+
* @see [callback-return](https://github.com/mysticatea/eslint-plugin-node/blob/v11.1.0/docs/rules/callback-return.md)
17+
*/
18+
export type CallbackReturnRuleConfig = RuleConfig<CallbackReturnOptions>;
19+
20+
/**
21+
* Require `return` statements after callbacks.
22+
*
23+
* @see [callback-return](https://github.com/mysticatea/eslint-plugin-node/blob/v11.1.0/docs/rules/callback-return.md)
24+
*/
25+
export interface CallbackReturnRule {
26+
/**
27+
* Require `return` statements after callbacks.
28+
*
29+
* @see [callback-return](https://github.com/mysticatea/eslint-plugin-node/blob/v11.1.0/docs/rules/callback-return.md)
30+
*/
31+
'node/callback-return': CallbackReturnRuleConfig;
32+
}

src/rules/node/exports-style.d.ts

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import type { RuleConfig } from '../rule-config';
2+
3+
/**
4+
* Config.
5+
*/
6+
export interface ExportsStyleConfig {
7+
allowBatchAssign?: boolean;
8+
}
9+
10+
/**
11+
* Option.
12+
*/
13+
export type ExportsStyleOption = 'module.exports' | 'exports';
14+
15+
/**
16+
* Options.
17+
*/
18+
export type ExportsStyleOptions = [ExportsStyleOption?, ExportsStyleConfig?];
19+
20+
/**
21+
* Enforce either `module.exports` or `exports`.
22+
*
23+
* @see [exports-style](https://github.com/mysticatea/eslint-plugin-node/blob/v11.1.0/docs/rules/exports-style.md)
24+
*/
25+
export type ExportsStyleRuleConfig = RuleConfig<ExportsStyleOptions>;
26+
27+
/**
28+
* Enforce either `module.exports` or `exports`.
29+
*
30+
* @see [exports-style](https://github.com/mysticatea/eslint-plugin-node/blob/v11.1.0/docs/rules/exports-style.md)
31+
*/
32+
export interface ExportsStyleRule {
33+
/**
34+
* Enforce either `module.exports` or `exports`.
35+
*
36+
* @see [exports-style](https://github.com/mysticatea/eslint-plugin-node/blob/v11.1.0/docs/rules/exports-style.md)
37+
*/
38+
'node/exports-style': ExportsStyleRuleConfig;
39+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import type { RuleConfig } from '../rule-config';
2+
3+
/**
4+
* Config.
5+
*/
6+
export type FileExtensionInImportConfig =
7+
| {
8+
tryExtensions?: string[];
9+
}
10+
| {
11+
[k: string]: 'always' | 'never';
12+
};
13+
14+
/**
15+
* Option.
16+
*/
17+
export type FileExtensionInImportOption = 'always' | 'never';
18+
19+
/**
20+
* Options.
21+
*/
22+
export type FileExtensionInImportOptions = [FileExtensionInImportOption?, FileExtensionInImportConfig?];
23+
24+
/**
25+
* Enforce the style of file extensions in `import` declarations.
26+
*
27+
* @see [file-extension-in-import](https://github.com/mysticatea/eslint-plugin-node/blob/v11.1.0/docs/rules/file-extension-in-import.md)
28+
*/
29+
export type FileExtensionInImportRuleConfig = RuleConfig<FileExtensionInImportOptions>;
30+
31+
/**
32+
* Enforce the style of file extensions in `import` declarations.
33+
*
34+
* @see [file-extension-in-import](https://github.com/mysticatea/eslint-plugin-node/blob/v11.1.0/docs/rules/file-extension-in-import.md)
35+
*/
36+
export interface FileExtensionInImportRule {
37+
/**
38+
* Enforce the style of file extensions in `import` declarations.
39+
*
40+
* @see [file-extension-in-import](https://github.com/mysticatea/eslint-plugin-node/blob/v11.1.0/docs/rules/file-extension-in-import.md)
41+
*/
42+
'node/file-extension-in-import': FileExtensionInImportRuleConfig;
43+
}

src/rules/node/global-require.d.ts

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import type { RuleConfig } from '../rule-config';
2+
3+
/**
4+
* Require `require()` calls to be placed at top-level module scope.
5+
*
6+
* @see [global-require](https://github.com/mysticatea/eslint-plugin-node/blob/v11.1.0/docs/rules/global-require.md)
7+
*/
8+
export type GlobalRequireRuleConfig = RuleConfig<[]>;
9+
10+
/**
11+
* Require `require()` calls to be placed at top-level module scope.
12+
*
13+
* @see [global-require](https://github.com/mysticatea/eslint-plugin-node/blob/v11.1.0/docs/rules/global-require.md)
14+
*/
15+
export interface GlobalRequireRule {
16+
/**
17+
* Require `require()` calls to be placed at top-level module scope.
18+
*
19+
* @see [global-require](https://github.com/mysticatea/eslint-plugin-node/blob/v11.1.0/docs/rules/global-require.md)
20+
*/
21+
'node/global-require': GlobalRequireRuleConfig;
22+
}
+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import type { RuleConfig } from '../rule-config';
2+
3+
/**
4+
* Option.
5+
*/
6+
export type HandleCallbackErrOption = string;
7+
8+
/**
9+
* Options.
10+
*/
11+
export type HandleCallbackErrOptions = [HandleCallbackErrOption?];
12+
13+
/**
14+
* Require error handling in callbacks.
15+
*
16+
* @see [handle-callback-err](https://github.com/mysticatea/eslint-plugin-node/blob/v11.1.0/docs/rules/handle-callback-err.md)
17+
*/
18+
export type HandleCallbackErrRuleConfig = RuleConfig<HandleCallbackErrOptions>;
19+
20+
/**
21+
* Require error handling in callbacks.
22+
*
23+
* @see [handle-callback-err](https://github.com/mysticatea/eslint-plugin-node/blob/v11.1.0/docs/rules/handle-callback-err.md)
24+
*/
25+
export interface HandleCallbackErrRule {
26+
/**
27+
* Require error handling in callbacks.
28+
*
29+
* @see [handle-callback-err](https://github.com/mysticatea/eslint-plugin-node/blob/v11.1.0/docs/rules/handle-callback-err.md)
30+
*/
31+
'node/handle-callback-err': HandleCallbackErrRuleConfig;
32+
}

src/rules/node/index.d.ts

+45-5
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,64 @@
1+
import type { CallbackReturnRule } from './callback-return';
2+
import type { ExportsStyleRule } from './exports-style';
3+
import type { FileExtensionInImportRule } from './file-extension-in-import';
4+
import type { GlobalRequireRule } from './global-require';
5+
import type { HandleCallbackErrRule } from './handle-callback-err';
6+
import type { NoCallbackLiteralRule } from './no-callback-literal';
17
import type { NoDeprecatedApiRule } from './no-deprecated-api';
8+
import type { NoExportsAssignRule } from './no-exports-assign';
29
import type { NoExtraneousImportRule } from './no-extraneous-import';
310
import type { NoExtraneousRequireRule } from './no-extraneous-require';
411
import type { NoMissingImportRule } from './no-missing-import';
512
import type { NoMissingRequireRule } from './no-missing-require';
6-
import type { NoProcessExitRuleConfig } from './no-process-exit';
13+
import type { NoMixedRequiresRule } from './no-mixed-requires';
14+
import type { NoNewRequireRule } from './no-new-require';
15+
import type { NoPathConcatRule } from './no-path-concat';
16+
import type { NoProcessEnvRule } from './no-process-env';
17+
import type { NoProcessExitRule } from './no-process-exit';
18+
import type { NoRestrictedImportRule } from './no-restricted-import';
719
import type { NoRestrictedRequireRule } from './no-restricted-require';
20+
import type { NoSyncRule } from './no-sync';
21+
import type { NoUnpublishedBinRule } from './no-unpublished-bin';
822
import type { NoUnpublishedImportRule } from './no-unpublished-import';
923
import type { NoUnpublishedRequireRule } from './no-unpublished-require';
24+
import type { NoUnsupportedFeaturesEsBuiltinsRule } from './no-unsupported-features/es-builtins';
1025
import type { NoUnsupportedFeaturesEsSyntaxRule } from './no-unsupported-features/es-syntax';
26+
import type { NoUnsupportedFeaturesNodeBuiltinsRule } from './no-unsupported-features/node-builtins';
27+
import type { ProcessExitAsThrowRule } from './process-exit-as-throw';
28+
import type { ShebangRule } from './shebang';
29+
import type { NoHideCoreModulesRule } from './no-hide-core-modules';
30+
import type { NoUnsupportedFeaturesRule } from './no-unsupported-features';
1131

1232
/**
13-
* All node rules.
33+
* All Node rules.
1434
*/
15-
export type NodeRules = NoDeprecatedApiRule &
35+
export type NodeRules = CallbackReturnRule &
36+
ExportsStyleRule &
37+
FileExtensionInImportRule &
38+
GlobalRequireRule &
39+
HandleCallbackErrRule &
40+
NoCallbackLiteralRule &
41+
NoDeprecatedApiRule &
42+
NoExportsAssignRule &
1643
NoExtraneousImportRule &
1744
NoExtraneousRequireRule &
1845
NoMissingImportRule &
1946
NoMissingRequireRule &
20-
// NoProcessExitRuleConfig & // TODO: This rule breaks somehow JSDoc hovering.
47+
NoMixedRequiresRule &
48+
NoNewRequireRule &
49+
NoPathConcatRule &
50+
NoProcessEnvRule &
51+
NoProcessExitRule &
52+
NoRestrictedImportRule &
2153
NoRestrictedRequireRule &
54+
NoSyncRule &
55+
NoUnpublishedBinRule &
2256
NoUnpublishedImportRule &
2357
NoUnpublishedRequireRule &
24-
NoUnsupportedFeaturesEsSyntaxRule;
58+
NoUnsupportedFeaturesEsBuiltinsRule &
59+
NoUnsupportedFeaturesEsSyntaxRule &
60+
NoUnsupportedFeaturesNodeBuiltinsRule &
61+
ProcessExitAsThrowRule &
62+
ShebangRule &
63+
NoHideCoreModulesRule &
64+
NoUnsupportedFeaturesRule;
+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import type { RuleConfig } from '../rule-config';
2+
3+
/**
4+
* Ensure Node.js-style error-first callback pattern is followed.
5+
*
6+
* @see [no-callback-literal](https://github.com/mysticatea/eslint-plugin-node/blob/v11.1.0/docs/rules/no-callback-literal.md)
7+
*/
8+
export type NoCallbackLiteralRuleConfig = RuleConfig<[]>;
9+
10+
/**
11+
* Ensure Node.js-style error-first callback pattern is followed.
12+
*
13+
* @see [no-callback-literal](https://github.com/mysticatea/eslint-plugin-node/blob/v11.1.0/docs/rules/no-callback-literal.md)
14+
*/
15+
export interface NoCallbackLiteralRule {
16+
/**
17+
* Ensure Node.js-style error-first callback pattern is followed.
18+
*
19+
* @see [no-callback-literal](https://github.com/mysticatea/eslint-plugin-node/blob/v11.1.0/docs/rules/no-callback-literal.md)
20+
*/
21+
'node/no-callback-literal': NoCallbackLiteralRuleConfig;
22+
}

0 commit comments

Comments
 (0)