eslint-plugin-ts-type-forge 0.8.10 → 0.8.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,3 @@
1
- import type { TSESLint } from '@typescript-eslint/utils';
2
- type Options = readonly [];
3
- type MessageIds = 'removeSideEffectImport';
4
1
  /**
5
2
  * `import 'ts-type-forge';` binds nothing, and there is nothing for it to run:
6
3
  * the package ships declarations only, and its `exports` map offers no runtime
@@ -11,9 +8,7 @@ type MessageIds = 'removeSideEffectImport';
11
8
  *
12
9
  * The ambient globals are a separate entry point, `ts-type-forge/global`,
13
10
  * usually brought in through `compilerOptions.types` or a triple-slash
14
- * reference. This rule matches the bare specifier exactly, so that subpath is
15
- * left alone.
11
+ * reference, which the rule leaves alone.
16
12
  */
17
- export declare const noSideEffectImport: TSESLint.RuleModule<MessageIds, Options>;
18
- export {};
13
+ export declare const noSideEffectImport: import("@typescript-eslint/utils/ts-eslint").RuleModule<"removeSideEffectImport", readonly [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
19
14
  //# sourceMappingURL=no-side-effect-import.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"no-side-effect-import.d.mts","sourceRoot":"","sources":["../../src/rules/no-side-effect-import.mts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAY,MAAM,0BAA0B,CAAC;AAInE,KAAK,OAAO,GAAG,SAAS,EAAE,CAAC;AAE3B,KAAK,UAAU,GAAG,wBAAwB,CAAC;AAE3C;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,kBAAkB,EAAE,QAAQ,CAAC,UAAU,CAAC,UAAU,EAAE,OAAO,CA8B9D,CAAC"}
1
+ {"version":3,"file":"no-side-effect-import.d.mts","sourceRoot":"","sources":["../../src/rules/no-side-effect-import.mts"],"names":[],"mappings":"AAGA;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,kBAAkB,oKAK7B,CAAC"}
@@ -1,4 +1,4 @@
1
- import { Arr } from 'ts-data-forge';
1
+ import { createNoSideEffectImport } from 'eslint-rule-forge';
2
2
  import { TS_TYPE_FORGE_MODULE } from './constants.mjs';
3
3
 
4
4
 
@@ -12,44 +12,10 @@ import { TS_TYPE_FORGE_MODULE } from './constants.mjs';
12
12
 
13
13
 
14
14
 
15
-
16
- export const noSideEffectImport = {
17
- meta: {
18
- type: 'problem',
19
- docs: {
20
- description: `Remove a side-effect-only \`import '${TS_TYPE_FORGE_MODULE}';\`, which binds no name and has no runtime entry point to resolve to. \`${TS_TYPE_FORGE_MODULE}/global\` is left alone.`,
21
- },
22
- fixable: 'code',
23
- schema: [],
24
- messages: {
25
- removeSideEffectImport: `\`import '${TS_TYPE_FORGE_MODULE}';\` binds no name, and \`${TS_TYPE_FORGE_MODULE}\` ships types only — it has no runtime entry point, so the import throws when the module is loaded. Remove it; the ambient globals come from \`${TS_TYPE_FORGE_MODULE}/global\`, not from this.`,
26
- },
27
- },
28
- create: (context) => ({
29
- ImportDeclaration: (node) => {
30
- if (node.source.value !== TS_TYPE_FORGE_MODULE ||
31
- !Arr.isEmpty(node.specifiers)) {
32
- return;
33
- }
34
- context.report({
35
- node,
36
- messageId: 'removeSideEffectImport',
37
- fix: (fixer) => removeStatement(fixer, context.sourceCode, node),
38
- });
39
- },
40
- }),
41
- defaultOptions: [],
42
- };
43
-
44
-
45
-
46
-
47
-
48
- const removeStatement = (fixer, sourceCode, node) => {
49
- const restOfLine = /^[^\S\n]*\n/u.exec(sourceCode.getText().slice(node.range[1]));
50
- return fixer.removeRange([
51
- node.range[0],
52
- node.range[1] + (restOfLine?.[0].length ?? 0),
53
- ]);
54
- };
15
+ export const noSideEffectImport = createNoSideEffectImport({
16
+ moduleName: TS_TYPE_FORGE_MODULE,
17
+ type: 'problem',
18
+ description: `Remove a side-effect-only \`import '${TS_TYPE_FORGE_MODULE}';\`, which binds no name and has no runtime entry point to resolve to. \`${TS_TYPE_FORGE_MODULE}/global\` is left alone.`,
19
+ message: `\`import '${TS_TYPE_FORGE_MODULE}';\` binds no name, and \`${TS_TYPE_FORGE_MODULE}\` ships types only — it has no runtime entry point, so the import throws when the module is loaded. Remove it; the ambient globals come from \`${TS_TYPE_FORGE_MODULE}/global\`, not from this.`,
20
+ });
55
21
  //# sourceMappingURL=no-side-effect-import.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"no-side-effect-import.mjs","sourceRoot":"","sources":["../../src/rules/no-side-effect-import.mts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AACpC,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAMvD;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAA6C;IAC1E,IAAI,EAAE;QACJ,IAAI,EAAE,SAAS;QACf,IAAI,EAAE;YACJ,WAAW,EAAE,uCAAuC,oBAAoB,6EAA6E,oBAAoB,0BAA0B;SACpM;QACD,OAAO,EAAE,MAAM;QACf,MAAM,EAAE,EAAE;QACV,QAAQ,EAAE;YACR,sBAAsB,EAAE,aAAa,oBAAoB,6BAA6B,oBAAoB,mJAAmJ,oBAAoB,2BAA2B;SAC7S;KACF;IAED,MAAM,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;QACpB,iBAAiB,EAAE,CAAC,IAAI,EAAE,EAAE;YAC1B,IACE,IAAI,CAAC,MAAM,CAAC,KAAK,KAAK,oBAAoB;gBAC1C,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,EAC7B,CAAC;gBACD,OAAO;YACT,CAAC;YAED,OAAO,CAAC,MAAM,CAAC;gBACb,IAAI;gBACJ,SAAS,EAAE,wBAAwB;gBACnC,GAAG,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,eAAe,CAAC,KAAK,EAAE,OAAO,CAAC,UAAU,EAAE,IAAI,CAAC;aACjE,CAAC,CAAC;QACL,CAAC;KACF,CAAC;IACF,cAAc,EAAE,EAAE;CACV,CAAC;AAEX,uEAAuE;AAEvE;;;GAGG;AACH,MAAM,eAAe,GAAG,CACtB,KAAyB,EACzB,UAA+B,EAC/B,IAAmB,EACD,EAAE;IACpB,MAAM,UAAU,GAAG,cAAc,CAAC,IAAI,CACpC,UAAU,CAAC,OAAO,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAC1C,CAAC;IAEF,OAAO,KAAK,CAAC,WAAW,CAAC;QACvB,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;QACb,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC;KAC9C,CAAC,CAAC;AACL,CAAC,CAAC"}
1
+ {"version":3,"file":"no-side-effect-import.mjs","sourceRoot":"","sources":["../../src/rules/no-side-effect-import.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAEvD;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,wBAAwB,CAAC;IACzD,UAAU,EAAE,oBAAoB;IAChC,IAAI,EAAE,SAAS;IACf,WAAW,EAAE,uCAAuC,oBAAoB,6EAA6E,oBAAoB,0BAA0B;IACnM,OAAO,EAAE,aAAa,oBAAoB,6BAA6B,oBAAoB,mJAAmJ,oBAAoB,2BAA2B;CAC9R,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-ts-type-forge",
3
- "version": "0.8.10",
3
+ "version": "0.8.11",
4
4
  "private": false,
5
5
  "description": "ESLint rules that steer type declarations toward ts-type-forge idioms.",
6
6
  "keywords": [
@@ -36,7 +36,7 @@
36
36
  ],
37
37
  "dependencies": {
38
38
  "@typescript-eslint/utils": "~8.71.1",
39
- "eslint-rule-forge": "^0.2.0",
39
+ "eslint-rule-forge": "^0.3.0",
40
40
  "ts-data-forge": "~14.9.0",
41
41
  "ts-type-forge": "9.2.2"
42
42
  },
@@ -44,9 +44,9 @@
44
44
  "@typescript-eslint/parser": "8.71.1",
45
45
  "@typescript-eslint/rule-tester": "8.71.1",
46
46
  "dedent": "1.7.2",
47
- "eslint-config-typed": "5.19.0",
48
- "eslint-plugin-ts-data-forge": "0.10.0",
49
- "eslint-plugin-ts-fortress": "1.3.5",
47
+ "eslint-config-typed": "5.19.1",
48
+ "eslint-plugin-ts-data-forge": "0.10.1",
49
+ "eslint-plugin-ts-fortress": "1.3.6",
50
50
  "prettier": "3.9.9",
51
51
  "prettier-plugin-organize-imports": "4.3.0",
52
52
  "prettier-plugin-packagejson": "3.0.2",
@@ -1,11 +1,6 @@
1
- import type { TSESLint, TSESTree } from '@typescript-eslint/utils';
2
- import { Arr } from 'ts-data-forge';
1
+ import { createNoSideEffectImport } from 'eslint-rule-forge';
3
2
  import { TS_TYPE_FORGE_MODULE } from './constants.mjs';
4
3
 
5
- type Options = readonly [];
6
-
7
- type MessageIds = 'removeSideEffectImport';
8
-
9
4
  /**
10
5
  * `import 'ts-type-forge';` binds nothing, and there is nothing for it to run:
11
6
  * the package ships declarations only, and its `exports` map offers no runtime
@@ -16,58 +11,11 @@ type MessageIds = 'removeSideEffectImport';
16
11
  *
17
12
  * The ambient globals are a separate entry point, `ts-type-forge/global`,
18
13
  * usually brought in through `compilerOptions.types` or a triple-slash
19
- * reference. This rule matches the bare specifier exactly, so that subpath is
20
- * left alone.
14
+ * reference, which the rule leaves alone.
21
15
  */
22
- export const noSideEffectImport: TSESLint.RuleModule<MessageIds, Options> = {
23
- meta: {
24
- type: 'problem',
25
- docs: {
26
- description: `Remove a side-effect-only \`import '${TS_TYPE_FORGE_MODULE}';\`, which binds no name and has no runtime entry point to resolve to. \`${TS_TYPE_FORGE_MODULE}/global\` is left alone.`,
27
- },
28
- fixable: 'code',
29
- schema: [],
30
- messages: {
31
- removeSideEffectImport: `\`import '${TS_TYPE_FORGE_MODULE}';\` binds no name, and \`${TS_TYPE_FORGE_MODULE}\` ships types only — it has no runtime entry point, so the import throws when the module is loaded. Remove it; the ambient globals come from \`${TS_TYPE_FORGE_MODULE}/global\`, not from this.`,
32
- },
33
- },
34
-
35
- create: (context) => ({
36
- ImportDeclaration: (node) => {
37
- if (
38
- node.source.value !== TS_TYPE_FORGE_MODULE ||
39
- !Arr.isEmpty(node.specifiers)
40
- ) {
41
- return;
42
- }
43
-
44
- context.report({
45
- node,
46
- messageId: 'removeSideEffectImport',
47
- fix: (fixer) => removeStatement(fixer, context.sourceCode, node),
48
- });
49
- },
50
- }),
51
- defaultOptions: [],
52
- } as const;
53
-
54
- /* eslint-disable @typescript-eslint/prefer-readonly-parameter-types */
55
-
56
- /**
57
- * Removes a statement along with the rest of its line, so that deleting it does
58
- * not leave a blank line where it was.
59
- */
60
- const removeStatement = (
61
- fixer: TSESLint.RuleFixer,
62
- sourceCode: TSESLint.SourceCode,
63
- node: TSESTree.Node,
64
- ): TSESLint.RuleFix => {
65
- const restOfLine = /^[^\S\n]*\n/u.exec(
66
- sourceCode.getText().slice(node.range[1]),
67
- );
68
-
69
- return fixer.removeRange([
70
- node.range[0],
71
- node.range[1] + (restOfLine?.[0].length ?? 0),
72
- ]);
73
- };
16
+ export const noSideEffectImport = createNoSideEffectImport({
17
+ moduleName: TS_TYPE_FORGE_MODULE,
18
+ type: 'problem',
19
+ description: `Remove a side-effect-only \`import '${TS_TYPE_FORGE_MODULE}';\`, which binds no name and has no runtime entry point to resolve to. \`${TS_TYPE_FORGE_MODULE}/global\` is left alone.`,
20
+ message: `\`import '${TS_TYPE_FORGE_MODULE}';\` binds no name, and \`${TS_TYPE_FORGE_MODULE}\` ships types only — it has no runtime entry point, so the import throws when the module is loaded. Remove it; the ambient globals come from \`${TS_TYPE_FORGE_MODULE}/global\`, not from this.`,
21
+ });