@kristijorgji/eslint-plugin 0.1.0

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.
Files changed (67) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +195 -0
  3. package/dist/configs/component-extraction.d.ts +24 -0
  4. package/dist/configs/component-extraction.d.ts.map +1 -0
  5. package/dist/configs/component-extraction.js +51 -0
  6. package/dist/configs/component-extraction.js.map +1 -0
  7. package/dist/configs/recommended.d.ts +12 -0
  8. package/dist/configs/recommended.d.ts.map +1 -0
  9. package/dist/configs/recommended.js +22 -0
  10. package/dist/configs/recommended.js.map +1 -0
  11. package/dist/configs/typed.d.ts +13 -0
  12. package/dist/configs/typed.d.ts.map +1 -0
  13. package/dist/configs/typed.js +25 -0
  14. package/dist/configs/typed.js.map +1 -0
  15. package/dist/index.d.ts +17 -0
  16. package/dist/index.d.ts.map +1 -0
  17. package/dist/index.js +11 -0
  18. package/dist/index.js.map +1 -0
  19. package/dist/plugin.d.ts +4 -0
  20. package/dist/plugin.d.ts.map +1 -0
  21. package/dist/plugin.js +31 -0
  22. package/dist/plugin.js.map +1 -0
  23. package/dist/rules/jsx-leading-prop-order.d.ts +16 -0
  24. package/dist/rules/jsx-leading-prop-order.d.ts.map +1 -0
  25. package/dist/rules/jsx-leading-prop-order.js +143 -0
  26. package/dist/rules/jsx-leading-prop-order.js.map +1 -0
  27. package/dist/rules/no-barrel.d.ts +13 -0
  28. package/dist/rules/no-barrel.d.ts.map +1 -0
  29. package/dist/rules/no-barrel.js +45 -0
  30. package/dist/rules/no-barrel.js.map +1 -0
  31. package/dist/rules/no-multi-comp.d.ts +16 -0
  32. package/dist/rules/no-multi-comp.d.ts.map +1 -0
  33. package/dist/rules/no-multi-comp.js +81 -0
  34. package/dist/rules/no-multi-comp.js.map +1 -0
  35. package/dist/rules/no-pure-type-alias.d.ts +14 -0
  36. package/dist/rules/no-pure-type-alias.d.ts.map +1 -0
  37. package/dist/rules/no-pure-type-alias.js +52 -0
  38. package/dist/rules/no-pure-type-alias.js.map +1 -0
  39. package/dist/rules/no-single-export-barrel.d.ts +10 -0
  40. package/dist/rules/no-single-export-barrel.d.ts.map +1 -0
  41. package/dist/rules/no-single-export-barrel.js +89 -0
  42. package/dist/rules/no-single-export-barrel.js.map +1 -0
  43. package/dist/rules/no-weak-typeof-satisfies.d.ts +15 -0
  44. package/dist/rules/no-weak-typeof-satisfies.d.ts.map +1 -0
  45. package/dist/rules/no-weak-typeof-satisfies.js +93 -0
  46. package/dist/rules/no-weak-typeof-satisfies.js.map +1 -0
  47. package/dist/selectors/mock-body-satisfies.d.ts +7 -0
  48. package/dist/selectors/mock-body-satisfies.d.ts.map +1 -0
  49. package/dist/selectors/mock-body-satisfies.js +31 -0
  50. package/dist/selectors/mock-body-satisfies.js.map +1 -0
  51. package/dist/selectors/object-literal-typing.d.ts +7 -0
  52. package/dist/selectors/object-literal-typing.d.ts.map +1 -0
  53. package/dist/selectors/object-literal-typing.js +23 -0
  54. package/dist/selectors/object-literal-typing.js.map +1 -0
  55. package/dist/selectors/restricted-syntax.d.ts +20 -0
  56. package/dist/selectors/restricted-syntax.d.ts.map +1 -0
  57. package/dist/selectors/restricted-syntax.js +28 -0
  58. package/dist/selectors/restricted-syntax.js.map +1 -0
  59. package/dist/selectors/types.d.ts +5 -0
  60. package/dist/selectors/types.d.ts.map +1 -0
  61. package/dist/selectors/types.js +2 -0
  62. package/dist/selectors/types.js.map +1 -0
  63. package/dist/utils/create-rule.d.ts +9 -0
  64. package/dist/utils/create-rule.d.ts.map +1 -0
  65. package/dist/utils/create-rule.js +7 -0
  66. package/dist/utils/create-rule.js.map +1 -0
  67. package/package.json +53 -0
@@ -0,0 +1,13 @@
1
+ export interface NoBarrelOptions {
2
+ /** The package name whose barrel import is disallowed, e.g. `@repo/utils`. */
3
+ packageName: string;
4
+ /** An example subpath import to suggest instead, e.g. `@repo/utils/media`. */
5
+ exampleSubpath: string;
6
+ }
7
+ type Options = [NoBarrelOptions];
8
+ /** Disallow workspace package barrel imports — use domain subpaths instead. */
9
+ export declare const noBarrel: import("@typescript-eslint/utils/ts-eslint").RuleModule<"noBarrel", Options, unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
10
+ name: string;
11
+ };
12
+ export {};
13
+ //# sourceMappingURL=no-barrel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-barrel.d.ts","sourceRoot":"","sources":["../../src/rules/no-barrel.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,eAAe;IAC9B,8EAA8E;IAC9E,WAAW,EAAE,MAAM,CAAC;IACpB,8EAA8E;IAC9E,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,KAAK,OAAO,GAAG,CAAC,eAAe,CAAC,CAAC;AAQjC,+EAA+E;AAC/E,eAAO,MAAM,QAAQ;;CAyCnB,CAAC"}
@@ -0,0 +1,45 @@
1
+ import { TSESTree } from '@typescript-eslint/utils';
2
+ import { createRule } from '../utils/create-rule.js';
3
+ /** Disallow workspace package barrel imports — use domain subpaths instead. */
4
+ export const noBarrel = createRule({
5
+ name: 'no-barrel',
6
+ meta: {
7
+ type: 'problem',
8
+ docs: {
9
+ description: 'Disallow package barrel imports; require domain subpath imports instead.',
10
+ },
11
+ schema: [
12
+ {
13
+ type: 'object',
14
+ properties: {
15
+ packageName: { type: 'string' },
16
+ exampleSubpath: { type: 'string' },
17
+ },
18
+ required: ['packageName', 'exampleSubpath'],
19
+ additionalProperties: false,
20
+ },
21
+ ],
22
+ messages: {
23
+ noBarrel: 'Import from {{packageName}} subpaths (e.g. {{exampleSubpath}}), not the package barrel.',
24
+ },
25
+ },
26
+ defaultOptions: [{ packageName: '', exampleSubpath: '' }],
27
+ create(context, [options]) {
28
+ const { packageName, exampleSubpath } = options;
29
+ function reportBarrel(node) {
30
+ if (node.source?.value !== packageName)
31
+ return;
32
+ context.report({
33
+ node: node.source,
34
+ messageId: 'noBarrel',
35
+ data: { packageName, exampleSubpath },
36
+ });
37
+ }
38
+ return {
39
+ ImportDeclaration: reportBarrel,
40
+ ExportNamedDeclaration: reportBarrel,
41
+ ExportAllDeclaration: reportBarrel,
42
+ };
43
+ },
44
+ });
45
+ //# sourceMappingURL=no-barrel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-barrel.js","sourceRoot":"","sources":["../../src/rules/no-barrel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAEpD,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAiBrD,+EAA+E;AAC/E,MAAM,CAAC,MAAM,QAAQ,GAAG,UAAU,CAAsB;IACtD,IAAI,EAAE,WAAW;IACjB,IAAI,EAAE;QACJ,IAAI,EAAE,SAAS;QACf,IAAI,EAAE;YACJ,WAAW,EAAE,0EAA0E;SACxF;QACD,MAAM,EAAE;YACN;gBACE,IAAI,EAAE,QAAQ;gBACd,UAAU,EAAE;oBACV,WAAW,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;oBAC/B,cAAc,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;iBACnC;gBACD,QAAQ,EAAE,CAAC,aAAa,EAAE,gBAAgB,CAAC;gBAC3C,oBAAoB,EAAE,KAAK;aAC5B;SACF;QACD,QAAQ,EAAE;YACR,QAAQ,EAAE,yFAAyF;SACpG;KACF;IACD,cAAc,EAAE,CAAC,EAAE,WAAW,EAAE,EAAE,EAAE,cAAc,EAAE,EAAE,EAAE,CAAC;IACzD,MAAM,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC;QACvB,MAAM,EAAE,WAAW,EAAE,cAAc,EAAE,GAAG,OAAO,CAAC;QAEhD,SAAS,YAAY,CAAC,IAAuB;YAC3C,IAAI,IAAI,CAAC,MAAM,EAAE,KAAK,KAAK,WAAW;gBAAE,OAAO;YAC/C,OAAO,CAAC,MAAM,CAAC;gBACb,IAAI,EAAE,IAAI,CAAC,MAAM;gBACjB,SAAS,EAAE,UAAU;gBACrB,IAAI,EAAE,EAAE,WAAW,EAAE,cAAc,EAAE;aACtC,CAAC,CAAC;QACL,CAAC;QAED,OAAO;YACL,iBAAiB,EAAE,YAAY;YAC/B,sBAAsB,EAAE,YAAY;YACpC,oBAAoB,EAAE,YAAY;SACnC,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
@@ -0,0 +1,16 @@
1
+ export interface NoMultiCompOptions {
2
+ /** Maximum number of components allowed per file. Defaults to 1. */
3
+ max?: number;
4
+ /** When true, only class components count towards the limit. Defaults to false. */
5
+ ignoreStateless?: boolean;
6
+ }
7
+ type Options = [NoMultiCompOptions];
8
+ /**
9
+ * Warn when a file declares more than the configured number of PascalCase React
10
+ * components. Replaces eslint-plugin-react's `react/no-multi-comp`.
11
+ */
12
+ export declare const noMultiComp: import("@typescript-eslint/utils/ts-eslint").RuleModule<"tooMany", Options, unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
13
+ name: string;
14
+ };
15
+ export {};
16
+ //# sourceMappingURL=no-multi-comp.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-multi-comp.d.ts","sourceRoot":"","sources":["../../src/rules/no-multi-comp.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,kBAAkB;IACjC,oEAAoE;IACpE,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,mFAAmF;IACnF,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED,KAAK,OAAO,GAAG,CAAC,kBAAkB,CAAC,CAAC;AAgBpC;;;GAGG;AACH,eAAO,MAAM,WAAW;;CAoEtB,CAAC"}
@@ -0,0 +1,81 @@
1
+ import { TSESTree } from '@typescript-eslint/utils';
2
+ import { createRule } from '../utils/create-rule.js';
3
+ function isComponentName(name) {
4
+ return typeof name === 'string' && /^[A-Z]/.test(name);
5
+ }
6
+ function isFunctionLike(node) {
7
+ return (node != null &&
8
+ (node.type === TSESTree.AST_NODE_TYPES.FunctionExpression ||
9
+ node.type === TSESTree.AST_NODE_TYPES.ArrowFunctionExpression ||
10
+ node.type === TSESTree.AST_NODE_TYPES.FunctionDeclaration));
11
+ }
12
+ /**
13
+ * Warn when a file declares more than the configured number of PascalCase React
14
+ * components. Replaces eslint-plugin-react's `react/no-multi-comp`.
15
+ */
16
+ export const noMultiComp = createRule({
17
+ name: 'no-multi-comp',
18
+ meta: {
19
+ type: 'suggestion',
20
+ docs: {
21
+ description: 'Disallow multiple React components in a single file',
22
+ },
23
+ schema: [
24
+ {
25
+ type: 'object',
26
+ properties: {
27
+ max: { type: 'number', minimum: 1 },
28
+ ignoreStateless: { type: 'boolean' },
29
+ },
30
+ additionalProperties: false,
31
+ },
32
+ ],
33
+ messages: {
34
+ tooMany: 'Declare only one React component per file (found {{count}}). Extract extras into their own modules.',
35
+ },
36
+ },
37
+ defaultOptions: [{ max: 1, ignoreStateless: false }],
38
+ create(context, [options]) {
39
+ const max = options.max ?? 1;
40
+ const ignoreStateless = options.ignoreStateless ?? false;
41
+ const components = [];
42
+ return {
43
+ FunctionDeclaration(node) {
44
+ if (ignoreStateless) {
45
+ return;
46
+ }
47
+ if (isComponentName(node.id?.name)) {
48
+ components.push(node);
49
+ }
50
+ },
51
+ VariableDeclarator(node) {
52
+ if (ignoreStateless) {
53
+ return;
54
+ }
55
+ if (node.id.type === TSESTree.AST_NODE_TYPES.Identifier &&
56
+ isComponentName(node.id.name) &&
57
+ isFunctionLike(node.init)) {
58
+ components.push(node);
59
+ }
60
+ },
61
+ ClassDeclaration(node) {
62
+ if (isComponentName(node.id?.name)) {
63
+ components.push(node);
64
+ }
65
+ },
66
+ 'Program:exit'() {
67
+ if (components.length <= max) {
68
+ return;
69
+ }
70
+ for (const node of components.slice(max)) {
71
+ context.report({
72
+ node,
73
+ messageId: 'tooMany',
74
+ data: { count: String(components.length) },
75
+ });
76
+ }
77
+ },
78
+ };
79
+ },
80
+ });
81
+ //# sourceMappingURL=no-multi-comp.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-multi-comp.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AAC;IACJ,CAAC;CACF,CAAC,CAAC"}
@@ -0,0 +1,14 @@
1
+ export interface NoPureTypeAliasOptions {
2
+ /** Regex pattern strings; alias names matching any of them are allowed. */
3
+ allowPatterns?: string[];
4
+ }
5
+ type Options = [NoPureTypeAliasOptions];
6
+ /**
7
+ * Discourage pure re-alias declarations like `type A = B;` (identifier alias, no
8
+ * generics/indexing). Use the original type directly instead.
9
+ */
10
+ export declare const noPureTypeAlias: import("@typescript-eslint/utils/ts-eslint").RuleModule<"pureAlias", Options, unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
11
+ name: string;
12
+ };
13
+ export {};
14
+ //# sourceMappingURL=no-pure-type-alias.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-pure-type-alias.d.ts","sourceRoot":"","sources":["../../src/rules/no-pure-type-alias.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,sBAAsB;IACrC,2EAA2E;IAC3E,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;CAC1B;AAED,KAAK,OAAO,GAAG,CAAC,sBAAsB,CAAC,CAAC;AAGxC;;;GAGG;AACH,eAAO,MAAM,eAAe;;CA+C1B,CAAC"}
@@ -0,0 +1,52 @@
1
+ import { AST_NODE_TYPES } from '@typescript-eslint/utils';
2
+ import { createRule } from '../utils/create-rule.js';
3
+ /**
4
+ * Discourage pure re-alias declarations like `type A = B;` (identifier alias, no
5
+ * generics/indexing). Use the original type directly instead.
6
+ */
7
+ export const noPureTypeAlias = createRule({
8
+ name: 'no-pure-type-alias',
9
+ meta: {
10
+ type: 'suggestion',
11
+ docs: {
12
+ description: 'Discourage pure type aliases; use the original type directly.',
13
+ },
14
+ schema: [
15
+ {
16
+ type: 'object',
17
+ properties: {
18
+ allowPatterns: {
19
+ type: 'array',
20
+ items: { type: 'string' },
21
+ },
22
+ },
23
+ additionalProperties: false,
24
+ },
25
+ ],
26
+ messages: {
27
+ pureAlias: 'Avoid pure type aliases (`type {{name}} = {{target}}`). Prefer the original type directly. If intentional, add an eslint-disable-next-line with a reason.',
28
+ },
29
+ },
30
+ defaultOptions: [{ allowPatterns: [] }],
31
+ create(context, [options]) {
32
+ const allowPatterns = (options.allowPatterns ?? []).map((pattern) => new RegExp(pattern));
33
+ return {
34
+ TSTypeAliasDeclaration(node) {
35
+ const ann = node.typeAnnotation;
36
+ // Only flag `type A = SomeType` / `type A = Ns.Sub` with NO type arguments (a bare re-alias).
37
+ if (ann.type !== AST_NODE_TYPES.TSTypeReference)
38
+ return;
39
+ if (ann.typeArguments)
40
+ return;
41
+ if (allowPatterns.some((pattern) => pattern.test(node.id.name))) {
42
+ return;
43
+ }
44
+ const target = ann.typeName.type === AST_NODE_TYPES.Identifier
45
+ ? ann.typeName.name
46
+ : context.sourceCode.getText(ann.typeName);
47
+ context.report({ node, messageId: 'pureAlias', data: { name: node.id.name, target } });
48
+ },
49
+ };
50
+ },
51
+ });
52
+ //# sourceMappingURL=no-pure-type-alias.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-pure-type-alias.js","sourceRoot":"","sources":["../../src/rules/no-pure-type-alias.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAE1D,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAUrD;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,UAAU,CAAsB;IAC7D,IAAI,EAAE,oBAAoB;IAC1B,IAAI,EAAE;QACJ,IAAI,EAAE,YAAY;QAClB,IAAI,EAAE;YACJ,WAAW,EAAE,+DAA+D;SAC7E;QACD,MAAM,EAAE;YACN;gBACE,IAAI,EAAE,QAAQ;gBACd,UAAU,EAAE;oBACV,aAAa,EAAE;wBACb,IAAI,EAAE,OAAO;wBACb,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;qBAC1B;iBACF;gBACD,oBAAoB,EAAE,KAAK;aAC5B;SACF;QACD,QAAQ,EAAE;YACR,SAAS,EACP,2JAA2J;SAC9J;KACF;IACD,cAAc,EAAE,CAAC,EAAE,aAAa,EAAE,EAAE,EAAE,CAAC;IACvC,MAAM,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC;QACvB,MAAM,aAAa,GAAG,CAAC,OAAO,CAAC,aAAa,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC;QAE1F,OAAO;YACL,sBAAsB,CAAC,IAAI;gBACzB,MAAM,GAAG,GAAG,IAAI,CAAC,cAAc,CAAC;gBAChC,8FAA8F;gBAC9F,IAAI,GAAG,CAAC,IAAI,KAAK,cAAc,CAAC,eAAe;oBAAE,OAAO;gBACxD,IAAI,GAAG,CAAC,aAAa;oBAAE,OAAO;gBAE9B,IAAI,aAAa,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC;oBAChE,OAAO;gBACT,CAAC;gBAED,MAAM,MAAM,GACV,GAAG,CAAC,QAAQ,CAAC,IAAI,KAAK,cAAc,CAAC,UAAU;oBAC7C,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI;oBACnB,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;gBAC/C,OAAO,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,CAAC,CAAC;YACzF,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
@@ -0,0 +1,10 @@
1
+ export interface NoSingleExportBarrelOptions {
2
+ /** Regex pattern (as a string) that qualifying export names must match. Defaults to `^[A-Z]`. */
3
+ exportNamePattern?: string;
4
+ }
5
+ type Options = [NoSingleExportBarrelOptions];
6
+ export declare const noSingleExportBarrel: import("@typescript-eslint/utils/ts-eslint").RuleModule<"noSingleExportBarrel", Options, unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
7
+ name: string;
8
+ };
9
+ export {};
10
+ //# sourceMappingURL=no-single-export-barrel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-single-export-barrel.d.ts","sourceRoot":"","sources":["../../src/rules/no-single-export-barrel.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,2BAA2B;IAC1C,iGAAiG;IACjG,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED,KAAK,OAAO,GAAG,CAAC,2BAA2B,CAAC,CAAC;AAqD7C,eAAO,MAAM,oBAAoB;;CAgD/B,CAAC"}
@@ -0,0 +1,89 @@
1
+ import { AST_NODE_TYPES, TSESTree } from '@typescript-eslint/utils';
2
+ import { createRule } from '../utils/create-rule.js';
3
+ /**
4
+ * Ban thin `index.ts` barrels that only re-export a single symbol (usually a React
5
+ * component) from a sibling path — import the module file directly instead.
6
+ * Allows multi-export domain/index barrels.
7
+ */
8
+ function getSingleReExport(program) {
9
+ const reExports = [];
10
+ for (const statement of program.body) {
11
+ if (statement.type === AST_NODE_TYPES.ExportNamedDeclaration && statement.source) {
12
+ reExports.push(statement);
13
+ continue;
14
+ }
15
+ // Anything else (imports, declarations, export *) disqualifies the thin-barrel pattern.
16
+ return null;
17
+ }
18
+ if (reExports.length === 0) {
19
+ return null;
20
+ }
21
+ const specs = [];
22
+ for (const decl of reExports) {
23
+ const source = typeof decl.source?.value === 'string' ? decl.source.value : null;
24
+ if (!source) {
25
+ return null;
26
+ }
27
+ for (const spec of decl.specifiers) {
28
+ if (spec.type !== AST_NODE_TYPES.ExportSpecifier) {
29
+ return null;
30
+ }
31
+ const exportName = spec.exported.type === AST_NODE_TYPES.Identifier ? spec.exported.name : null;
32
+ if (!exportName) {
33
+ return null;
34
+ }
35
+ specs.push({ node: decl, exportName, source });
36
+ }
37
+ }
38
+ if (specs.length !== 1) {
39
+ return null;
40
+ }
41
+ return specs[0] ?? null;
42
+ }
43
+ export const noSingleExportBarrel = createRule({
44
+ name: 'no-single-export-barrel',
45
+ meta: {
46
+ type: 'problem',
47
+ docs: {
48
+ description: 'Disallow index.ts barrels that only re-export a single symbol from a sibling module',
49
+ },
50
+ schema: [
51
+ {
52
+ type: 'object',
53
+ properties: {
54
+ exportNamePattern: { type: 'string' },
55
+ },
56
+ additionalProperties: false,
57
+ },
58
+ ],
59
+ messages: {
60
+ noSingleExportBarrel: "Avoid a single-export index barrel (`export { {{name}} } from '{{source}}'`). Import `{{source}}` directly and delete this file.",
61
+ },
62
+ },
63
+ defaultOptions: [{ exportNamePattern: '^[A-Z]' }],
64
+ create(context, [options]) {
65
+ const filename = context.filename.replace(/\\/g, '/');
66
+ if (!/(^|\/)index\.tsx?$/.test(filename)) {
67
+ return {};
68
+ }
69
+ const exportNamePattern = new RegExp(options.exportNamePattern ?? '^[A-Z]');
70
+ return {
71
+ Program(node) {
72
+ const single = getSingleReExport(node);
73
+ if (!single) {
74
+ return;
75
+ }
76
+ // Component-style (PascalCase, by default) or obvious UI modules only.
77
+ if (!exportNamePattern.test(single.exportName)) {
78
+ return;
79
+ }
80
+ context.report({
81
+ node: single.node,
82
+ messageId: 'noSingleExportBarrel',
83
+ data: { name: single.exportName, source: single.source },
84
+ });
85
+ },
86
+ };
87
+ },
88
+ });
89
+ //# sourceMappingURL=no-single-export-barrel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-single-export-barrel.js","sourceRoot":"","sources":["../../src/rules/no-single-export-barrel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAEpE,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAgBrD;;;;GAIG;AACH,SAAS,iBAAiB,CAAC,OAAyB;IAClD,MAAM,SAA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AE,MAAM,CAAC,IAAI;oBACjB,SAAS,EAAE,sBAAsB;oBACjC,IAAI,EAAE,EAAE,IAAI,EAAE,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE;iBACzD,CAAC,CAAC;YACL,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
@@ -0,0 +1,15 @@
1
+ import { ESLintUtils } from '@typescript-eslint/utils';
2
+ export interface NoWeakTypeofSatisfiesOptions {
3
+ /** When true, only flag `any`, not `unknown`. Defaults to false. */
4
+ allowUnknown?: boolean;
5
+ }
6
+ type Options = [NoWeakTypeofSatisfiesOptions];
7
+ /**
8
+ * Flags `typeof expr` inside `satisfies` when `expr` resolves to `any` or `unknown`.
9
+ * Catches untyped `await res.json()` bodies and similar weak expectation typing.
10
+ */
11
+ export declare const noWeakTypeofSatisfies: ESLintUtils.RuleModule<"weakTypeof", Options, unknown, ESLintUtils.RuleListener> & {
12
+ name: string;
13
+ };
14
+ export {};
15
+ //# sourceMappingURL=no-weak-typeof-satisfies.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-weak-typeof-satisfies.d.ts","sourceRoot":"","sources":["../../src/rules/no-weak-typeof-satisfies.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,WAAW,EAAY,MAAM,0BAA0B,CAAC;AAKjF,MAAM,WAAW,4BAA4B;IAC3C,oEAAoE;IACpE,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAED,KAAK,OAAO,GAAG,CAAC,4BAA4B,CAAC,CAAC;AAgB9C;;;GAGG;AACH,eAAO,MAAM,qBAAqB;;CAuEhC,CAAC"}
@@ -0,0 +1,93 @@
1
+ import { AST_NODE_TYPES, ESLintUtils, TSESTree } from '@typescript-eslint/utils';
2
+ import ts from 'typescript';
3
+ import { createRule } from '../utils/create-rule.js';
4
+ function isAnyOrUnknown(type, allowUnknown) {
5
+ const flags = allowUnknown ? ts.TypeFlags.Any : ts.TypeFlags.Any | ts.TypeFlags.Unknown;
6
+ if (type.flags & flags)
7
+ return true;
8
+ if (type.isUnion()) {
9
+ return type.types.every((part) => isAnyOrUnknown(part, allowUnknown));
10
+ }
11
+ return false;
12
+ }
13
+ function isTraversableNode(value) {
14
+ return value != null && typeof value === 'object' && 'type' in value;
15
+ }
16
+ /**
17
+ * Flags `typeof expr` inside `satisfies` when `expr` resolves to `any` or `unknown`.
18
+ * Catches untyped `await res.json()` bodies and similar weak expectation typing.
19
+ */
20
+ export const noWeakTypeofSatisfies = createRule({
21
+ name: 'no-weak-typeof-satisfies',
22
+ meta: {
23
+ type: 'problem',
24
+ docs: {
25
+ description: 'Disallow typeof in satisfies when the expression type is any or unknown.',
26
+ },
27
+ schema: [
28
+ {
29
+ type: 'object',
30
+ properties: {
31
+ allowUnknown: { type: 'boolean' },
32
+ },
33
+ additionalProperties: false,
34
+ },
35
+ ],
36
+ messages: {
37
+ weakTypeof: 'Do not use `typeof {{expr}}` in `satisfies` when it resolves to any/unknown. Use an exported API/domain type, ReturnType, or a named alias instead.',
38
+ },
39
+ },
40
+ defaultOptions: [{ allowUnknown: false }],
41
+ create(context, [options]) {
42
+ const allowUnknown = options.allowUnknown ?? false;
43
+ const services = ESLintUtils.getParserServices(context, /* allowWithoutFullTypeInformation */ true);
44
+ if (!services.program) {
45
+ return {};
46
+ }
47
+ const checker = services.program.getTypeChecker();
48
+ function visit(node) {
49
+ if (!isTraversableNode(node))
50
+ return;
51
+ if (node.type === AST_NODE_TYPES.TSTypeQuery) {
52
+ try {
53
+ const tsNode = services.esTreeNodeToTSNodeMap.get(node);
54
+ if (tsNode && ts.isTypeQueryNode(tsNode)) {
55
+ const type = checker.getTypeFromTypeNode(tsNode);
56
+ if (isAnyOrUnknown(type, allowUnknown)) {
57
+ context.report({
58
+ node,
59
+ messageId: 'weakTypeof',
60
+ data: { expr: context.sourceCode.getText(node.exprName) },
61
+ });
62
+ }
63
+ }
64
+ }
65
+ catch {
66
+ // Incomplete parser services — skip.
67
+ }
68
+ }
69
+ for (const key of Object.keys(node)) {
70
+ if (key === 'parent' || key === 'loc' || key === 'range' || key === 'type')
71
+ continue;
72
+ const child = node[key];
73
+ if (!child || typeof child !== 'object')
74
+ continue;
75
+ if (Array.isArray(child)) {
76
+ for (const item of child) {
77
+ if (isTraversableNode(item))
78
+ visit(item);
79
+ }
80
+ }
81
+ else if (isTraversableNode(child)) {
82
+ visit(child);
83
+ }
84
+ }
85
+ }
86
+ return {
87
+ TSSatisfiesExpression(node) {
88
+ visit(node.typeAnnotation);
89
+ },
90
+ };
91
+ },
92
+ });
93
+ //# sourceMappingURL=no-weak-typeof-satisfies.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-weak-typeof-satisfies.js","sourceRoot":"","sources":["../../src/rules/no-weak-typeof-satisfies.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACjF,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5B,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAUrD,SAAS,cAAc,CAAC,IAAa,EAAE,YAAqB;IAC1D,MAAM,KAAK,GAAG,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,SAAS,CAAC,GAAG,GAAG,EAAE,CAAC,SAAS,CAAC,OAAO,CAAC;IACxF,IAAI,IAAI,CAAC,KAAK,GAAG,KAAK;QAAE,OAAO,IAAI,CAAC;IACpC,IAAI,IAAI,CAAC,OAAO,EAAE,EAAE,CAAC;QACnB,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,cAAc,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC,CAAC;IACxE,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAS,iBAAiB,CAAC,KAAc;IACvC,OAAO,KAAK,IAA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 import type { RestrictedSyntaxEntry } from './types.js';
2
+ /**
3
+ * In tests/stories, inline mock return values, JSON bodies, and expectation objects
4
+ * must use `satisfies SomeType` (named type, not inline literals).
5
+ */
6
+ export declare const mockBodySatisfiesSelectors: Record<string, RestrictedSyntaxEntry>;
7
+ //# sourceMappingURL=mock-body-satisfies.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mock-body-satisfies.d.ts","sourceRoot":"","sources":["../../src/selectors/mock-body-satisfies.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAExD;;;GAGG;AACH,eAAO,MAAM,0BAA0B,EAAE,MAAM,CAAC,MAAM,EAAE,qBAAqB,CAgC5E,CAAC"}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * In tests/stories, inline mock return values, JSON bodies, and expectation objects
3
+ * must use `satisfies SomeType` (named type, not inline literals).
4
+ */
5
+ export const mockBodySatisfiesSelectors = {
6
+ mockReturnResolvedValue: {
7
+ selector: 'CallExpression[callee.property.name=/^(mockResolvedValue|mockReturnValue|mockResolvedValueOnce|mockReturnValueOnce)$/][arguments.0.type="ObjectExpression"]',
8
+ message: 'Inline mock objects must use `satisfies SomeType` (e.g. mockResolvedValue({ ... } satisfies MyType)).',
9
+ },
10
+ expectationObject: {
11
+ selector: 'CallExpression[callee.property.name=/^(toEqual|toStrictEqual|toMatchObject)$/][arguments.0.type="ObjectExpression"]',
12
+ message: 'Inline expectation objects must use `satisfies SomeType` (e.g. expect(x).toEqual({ ... } satisfies MyType)).',
13
+ },
14
+ jsonStringifyBody: {
15
+ selector: 'Property[key.name="body"] CallExpression[callee.object.name="JSON"][callee.property.name="stringify"][arguments.0.type="ObjectExpression"]',
16
+ message: 'Inline JSON.stringify request bodies must use `satisfies SomeType`.',
17
+ },
18
+ inlineTypeLiteral: {
19
+ selector: 'TSSatisfiesExpression > TSTypeLiteral',
20
+ message: 'Do not use an inline type literal with `satisfies`. Reference a named type, an existing type, or Awaited<ReturnType<typeof fn>> (declare a one-off `type X = {...}` alias if truly needed).',
21
+ },
22
+ recordStringUnknown: {
23
+ selector: 'TSSatisfiesExpression > TSTypeReference[typeName.name="Record"][typeArguments.params.0.type="TSStringKeyword"][typeArguments.params.1.type=/^(TSUnknownKeyword|TSAnyKeyword)$/]',
24
+ message: 'Do not use `satisfies Record<string, unknown|any>`. Use a domain type, NonNullable<typeof value>, Partial<…>, ReturnType/Awaited<ReturnType>, or a local named alias.',
25
+ },
26
+ weakSatisfiesKeyword: {
27
+ selector: 'TSSatisfiesExpression > :matches(TSAnyKeyword, TSUnknownKeyword, TSObjectKeyword)',
28
+ message: 'Do not use weak `satisfies any|unknown|object`. Use a domain type, NonNullable<typeof value>, Partial<…>, ReturnType/Awaited<ReturnType>, or a local named alias.',
29
+ },
30
+ };
31
+ //# sourceMappingURL=mock-body-satisfies.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mock-body-satisfies.js","sourceRoot":"","sources":["../../src/selectors/mock-body-satisfies.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAA0C;IAC/E,uBAAuB,EAAE;QACvB,QAAQ,EACN,6JAA6J;QAC/J,OAAO,EAAE,uGAAuG;KACjH;IACD,iBAAiB,EAAE;QACjB,QAAQ,EACN,qHAAqH;QACvH,OAAO,EAAE,8GAA8G;KACxH;IACD,iBAAiB,EAAE;QACjB,QAAQ,EACN,4IAA4I;QAC9I,OAAO,EAAE,qEAAqE;KAC/E;IACD,iBAAiB,EAAE;QACjB,QAAQ,EAAE,uCAAuC;QACjD,OAAO,EACL,6LAA6L;KAChM;IACD,mBAAmB,EAAE;QACnB,QAAQ,EACN,iLAAiL;QACnL,OAAO,EACL,uKAAuK;KAC1K;IACD,oBAAoB,EAAE;QACpB,QAAQ,EAAE,mFAAmF;QAC7F,OAAO,EACL,mKAAmK;KACtK;CACF,CAAC"}
@@ -0,0 +1,7 @@
1
+ import type { RestrictedSyntaxEntry } from './types.js';
2
+ /**
3
+ * Const-bound object/array/JSX locals must use `: Type` on the binding (not bare
4
+ * literals or `satisfies` on the initializer).
5
+ */
6
+ export declare const objectLiteralTypingSelectors: Record<string, RestrictedSyntaxEntry>;
7
+ //# sourceMappingURL=object-literal-typing.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"object-literal-typing.d.ts","sourceRoot":"","sources":["../../src/selectors/object-literal-typing.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAExD;;;GAGG;AACH,eAAO,MAAM,4BAA4B,EAAE,MAAM,CAAC,MAAM,EAAE,qBAAqB,CAuB9E,CAAC"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Const-bound object/array/JSX locals must use `: Type` on the binding (not bare
3
+ * literals or `satisfies` on the initializer).
4
+ */
5
+ export const objectLiteralTypingSelectors = {
6
+ objectOrArrayBinding: {
7
+ selector: 'VariableDeclarator[init.type=/^(ObjectExpression|ArrayExpression)$/] > Identifier:not([typeAnnotation])',
8
+ message: 'Object and array values must use an explicit type annotation on the binding (e.g. const data: MyType = { ... }).',
9
+ },
10
+ jsxBinding: {
11
+ selector: 'VariableDeclarator[init.type="JSXElement"] > Identifier:not([typeAnnotation])',
12
+ message: 'JSX values must use an explicit type annotation on the binding (e.g. const node: ReactElement = <App />).',
13
+ },
14
+ satisfiesOnConstBinding: {
15
+ selector: 'VariableDeclarator[init.type="TSSatisfiesExpression"][init.expression.type=/^(ObjectExpression|ArrayExpression)$/] > Identifier:not([typeAnnotation])',
16
+ message: 'Prefer `const x: MyType = { ... }` for const-bound mocks; reserve `satisfies` for inline mockReturnValue/mockResolvedValue arguments.',
17
+ },
18
+ asNeverLiteral: {
19
+ selector: 'TSAsExpression[typeAnnotation.type="TSNeverKeyword"][expression.type=/^(ObjectExpression|ArrayExpression)$/]',
20
+ message: 'Use satisfies TargetType instead of as never on object/array literals (e.g. mockReturnValueOnce({ ... } satisfies MyType)).',
21
+ },
22
+ };
23
+ //# sourceMappingURL=object-literal-typing.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"object-literal-typing.js","sourceRoot":"","sources":["../../src/selectors/object-literal-typing.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAA0C;IACjF,oBAAoB,EAAE;QACpB,QAAQ,EACN,yGAAyG;QAC3G,OAAO,EACL,kHAAkH;KACrH;IACD,UAAU,EAAE;QACV,QAAQ,EAAE,+EAA+E;QACzF,OAAO,EAAE,2GAA2G;KACrH;IACD,uBAAuB,EAAE;QACvB,QAAQ,EACN,uJAAuJ;QACzJ,OAAO,EACL,uIAAuI;KAC1I;IACD,cAAc,EAAE;QACd,QAAQ,EACN,8GAA8G;QAChH,OAAO,EACL,6HAA6H;KAChI;CACF,CAAC"}
@@ -0,0 +1,20 @@
1
+ import type { RestrictedSyntaxEntry } from './types.js';
2
+ export interface RestrictedSyntaxOptions {
3
+ /** Keys to omit from the provided groups. */
4
+ exclude?: string[];
5
+ /** Additional entries appended after the collected group entries. */
6
+ extra?: RestrictedSyntaxEntry[];
7
+ }
8
+ /**
9
+ * Collects all entries from the given keyed selector groups (e.g.
10
+ * `objectLiteralTypingSelectors`, `mockBodySatisfiesSelectors`), optionally filtering
11
+ * out keys and appending extra entries. Useful for composing a project's own
12
+ * `no-restricted-syntax` rule configuration.
13
+ */
14
+ export declare function restrictedSyntax(groups: Array<Record<string, RestrictedSyntaxEntry>>, options?: RestrictedSyntaxOptions): RestrictedSyntaxEntry[];
15
+ /**
16
+ * Convenience wrapper that produces a ready-to-spread `no-restricted-syntax` rule
17
+ * entry: `['error', ...entries]`.
18
+ */
19
+ export declare function restrictedSyntaxRuleEntry(groups: Array<Record<string, RestrictedSyntaxEntry>>, options?: RestrictedSyntaxOptions, severity?: 'error' | 'warn'): ['error' | 'warn', ...RestrictedSyntaxEntry[]];
20
+ //# sourceMappingURL=restricted-syntax.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"restricted-syntax.d.ts","sourceRoot":"","sources":["../../src/selectors/restricted-syntax.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAExD,MAAM,WAAW,uBAAuB;IACtC,6CAA6C;IAC7C,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,qEAAqE;IACrE,KAAK,CAAC,EAAE,qBAAqB,EAAE,CAAC;CACjC;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,qBAAqB,CAAC,CAAC,EACpD,OAAO,CAAC,EAAE,uBAAuB,GAChC,qBAAqB,EAAE,CAezB;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,qBAAqB,CAAC,CAAC,EACpD,OAAO,CAAC,EAAE,uBAAuB,EACjC,QAAQ,GAAE,OAAO,GAAG,MAAgB,GACnC,CAAC,OAAO,GAAG,MAAM,EAAE,GAAG,qBAAqB,EAAE,CAAC,CAEhD"}
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Collects all entries from the given keyed selector groups (e.g.
3
+ * `objectLiteralTypingSelectors`, `mockBodySatisfiesSelectors`), optionally filtering
4
+ * out keys and appending extra entries. Useful for composing a project's own
5
+ * `no-restricted-syntax` rule configuration.
6
+ */
7
+ export function restrictedSyntax(groups, options) {
8
+ const exclude = new Set(options?.exclude ?? []);
9
+ const extra = options?.extra ?? [];
10
+ const entries = [];
11
+ for (const group of groups) {
12
+ for (const [key, entry] of Object.entries(group)) {
13
+ if (exclude.has(key)) {
14
+ continue;
15
+ }
16
+ entries.push(entry);
17
+ }
18
+ }
19
+ return [...entries, ...extra];
20
+ }
21
+ /**
22
+ * Convenience wrapper that produces a ready-to-spread `no-restricted-syntax` rule
23
+ * entry: `['error', ...entries]`.
24
+ */
25
+ export function restrictedSyntaxRuleEntry(groups, options, severity = 'error') {
26
+ return [severity, ...restrictedSyntax(groups, options)];
27
+ }
28
+ //# sourceMappingURL=restricted-syntax.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"restricted-syntax.js","sourceRoot":"","sources":["../../src/selectors/restricted-syntax.ts"],"names":[],"mappings":"AASA;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB,CAC9B,MAAoD,EACpD,OAAiC;IAEjC,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,OAAO,EAAE,OAAO,IAAI,EAAE,CAAC,CAAC;IAChD,MAAM,KAAK,GAAG,OAAO,EAAE,KAAK,IAAI,EAAE,CAAC;IAEnC,MAAM,OAAO,GAA4B,EAAE,CAAC;IAC5C,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;YACjD,IAAI,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;gBACrB,SAAS;YACX,CAAC;YACD,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACtB,CAAC;IACH,CAAC;IAED,OAAO,CAAC,GAAG,OAAO,EAAE,GAAG,KAAK,CAAC,CAAC;AAChC,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,yBAAyB,CACvC,MAAoD,EACpD,OAAiC,EACjC,WAA6B,OAAO;IAEpC,OAAO,CAAC,QAAQ,EAAE,GAAG,gBAAgB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;AAC1D,CAAC"}