@trackunit/eslint-plugin-trackunit 0.4.66 → 0.5.1
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.
- package/CHANGELOG.md +25 -0
- package/README.md +2 -0
- package/package.json +1 -1
- package/src/lib/config/fragments/react-rules.js +15 -0
- package/src/lib/config/index.d.ts +60 -3
- package/src/lib/config/plugins.d.ts +14 -1
- package/src/lib/config/presets/base.d.ts +28 -2
- package/src/lib/config/presets/react.d.ts +32 -1
- package/src/lib/config/presets/react.js +9 -0
- package/src/lib/rules/component-name-matches-filename/component-name-matches-filename.d.ts +34 -0
- package/src/lib/rules/component-name-matches-filename/component-name-matches-filename.js +108 -0
- package/src/lib/rules/one-component-per-file/one-component-per-file.d.ts +29 -0
- package/src/lib/rules/one-component-per-file/one-component-per-file.js +73 -0
- package/src/lib/rules/require-component-prop-contracts/require-component-prop-contracts.d.ts +1 -2
- package/src/lib/rules/require-component-prop-contracts/require-component-prop-contracts.js +30 -27
- package/src/lib/rules-map.d.ts +14 -1
- package/src/lib/rules-map.js +4 -0
- package/src/lib/utils/ast-utils.d.ts +4 -0
- package/src/lib/utils/ast-utils.js +74 -21
- package/src/lib/utils/component-utils.d.ts +36 -0
- package/src/lib/utils/component-utils.js +192 -0
- package/src/index.js.map +0 -1
- package/src/lib/config/fragments/ignores.js.map +0 -1
- package/src/lib/config/fragments/import-rules.js.map +0 -1
- package/src/lib/config/fragments/jest-overrides.js.map +0 -1
- package/src/lib/config/fragments/jsdoc-rules.js.map +0 -1
- package/src/lib/config/fragments/module-boundaries.js.map +0 -1
- package/src/lib/config/fragments/react-rules.js.map +0 -1
- package/src/lib/config/fragments/restricted-imports.js.map +0 -1
- package/src/lib/config/fragments/testing-library.js.map +0 -1
- package/src/lib/config/fragments/typescript-rules.js.map +0 -1
- package/src/lib/config/index.js.map +0 -1
- package/src/lib/config/plugins.js.map +0 -1
- package/src/lib/config/presets/base.js.map +0 -1
- package/src/lib/config/presets/e2e.js.map +0 -1
- package/src/lib/config/presets/react.js.map +0 -1
- package/src/lib/config/presets/server.js.map +0 -1
- package/src/lib/config/utils.js.map +0 -1
- package/src/lib/config-helpers/create-skip-when.js.map +0 -1
- package/src/lib/rules/cva-merge-base-classes-as-array/cva-merge-base-classes-as-array.js.map +0 -1
- package/src/lib/rules/design-guideline-button-icon-size-match/design-guideline-button-icon-size-match.js.map +0 -1
- package/src/lib/rules/no-internal-barrel-files/no-internal-barrel-files.js.map +0 -1
- package/src/lib/rules/no-internal-graphql-when-tagged-with-gql-public/no-internal-graphql-when-tagged-with-gql-public.js.map +0 -1
- package/src/lib/rules/no-jest-mock-trackunit-react-core-hooks/no-jest-mock-trackunit-react-core-hooks.js.map +0 -1
- package/src/lib/rules/no-template-strings-in-classname-prop/no-template-strings-in-classname-prop.js.map +0 -1
- package/src/lib/rules/no-typescript-assertion/no-typescript-assertion.js.map +0 -1
- package/src/lib/rules/prefer-destructured-imports/prefer-destructured-imports.js.map +0 -1
- package/src/lib/rules/prefer-event-specific-callback-naming/name-suggestion-strategies.js.map +0 -1
- package/src/lib/rules/prefer-event-specific-callback-naming/prefer-event-specific-callback-naming.js.map +0 -1
- package/src/lib/rules/prefer-event-specific-callback-naming/strategies/string-based.js.map +0 -1
- package/src/lib/rules/prefer-event-specific-callback-naming/strategies/type-based.js.map +0 -1
- package/src/lib/rules/prefer-event-specific-callback-naming/utils.js.map +0 -1
- package/src/lib/rules/prefer-field-components/prefer-field-components.js.map +0 -1
- package/src/lib/rules/prefer-mouse-event-handler-in-react-props/prefer-mouse-event-handler-in-react-props.js.map +0 -1
- package/src/lib/rules/require-classname-alternatives/require-classname-alternatives.js.map +0 -1
- package/src/lib/rules/require-component-prop-contracts/require-component-prop-contracts.js.map +0 -1
- package/src/lib/rules/require-list-item-virtualization-props/require-list-item-virtualization-props.js.map +0 -1
- package/src/lib/rules/require-optional-prop-initialization/require-optional-prop-initialization.js.map +0 -1
- package/src/lib/rules/require-optional-prop-initialization/suggestion-utils.js.map +0 -1
- package/src/lib/rules-map.js.map +0 -1
- package/src/lib/utils/ast-utils.js.map +0 -1
- package/src/lib/utils/classname-utils.js.map +0 -1
- package/src/lib/utils/file-utils.js.map +0 -1
- package/src/lib/utils/import-utils.js.map +0 -1
- package/src/lib/utils/nx-utils.js.map +0 -1
- package/src/lib/utils/package-utils.js.map +0 -1
- package/src/lib/utils/typescript-utils.js.map +0 -1
|
@@ -121,6 +121,17 @@ const isComponentWrapperCallExpression = (node) => {
|
|
|
121
121
|
return (firstArgument?.type === utils_1.AST_NODE_TYPES.ArrowFunctionExpression ||
|
|
122
122
|
firstArgument?.type === utils_1.AST_NODE_TYPES.FunctionExpression);
|
|
123
123
|
};
|
|
124
|
+
const getWrappedComponentFunction = (node) => {
|
|
125
|
+
if (!isComponentWrapperCallExpression(node)) {
|
|
126
|
+
return null;
|
|
127
|
+
}
|
|
128
|
+
const firstArgument = node.arguments[0];
|
|
129
|
+
return firstArgument &&
|
|
130
|
+
(firstArgument.type === utils_1.AST_NODE_TYPES.ArrowFunctionExpression ||
|
|
131
|
+
firstArgument.type === utils_1.AST_NODE_TYPES.FunctionExpression)
|
|
132
|
+
? firstArgument
|
|
133
|
+
: null;
|
|
134
|
+
};
|
|
124
135
|
const getHeritageName = (heritage) => {
|
|
125
136
|
const { expression } = heritage;
|
|
126
137
|
if (expression.type === utils_1.AST_NODE_TYPES.Identifier) {
|
|
@@ -391,27 +402,9 @@ exports.requireComponentPropContracts = createRule({
|
|
|
391
402
|
items: { type: "string" },
|
|
392
403
|
description: "Interface names every exported component props type must reference or extend.",
|
|
393
404
|
},
|
|
394
|
-
|
|
395
|
-
type: "
|
|
396
|
-
|
|
397
|
-
tags: {
|
|
398
|
-
type: "array",
|
|
399
|
-
items: { type: "string" },
|
|
400
|
-
},
|
|
401
|
-
targets: {
|
|
402
|
-
type: "array",
|
|
403
|
-
items: { type: "string" },
|
|
404
|
-
},
|
|
405
|
-
tagsMatchMode: {
|
|
406
|
-
type: "string",
|
|
407
|
-
enum: ["some", "every"],
|
|
408
|
-
},
|
|
409
|
-
targetsMatchMode: {
|
|
410
|
-
type: "string",
|
|
411
|
-
enum: ["some", "every"],
|
|
412
|
-
},
|
|
413
|
-
},
|
|
414
|
-
additionalProperties: false,
|
|
405
|
+
restrictToComponentsWithJsxReturn: {
|
|
406
|
+
type: "boolean",
|
|
407
|
+
description: "When true, only enforce for components that return intrinsic JSX. Defaults to false (all components).",
|
|
415
408
|
},
|
|
416
409
|
},
|
|
417
410
|
additionalProperties: false,
|
|
@@ -425,7 +418,7 @@ exports.requireComponentPropContracts = createRule({
|
|
|
425
418
|
{
|
|
426
419
|
requiredProps: [],
|
|
427
420
|
requiredInterfaces: [],
|
|
428
|
-
|
|
421
|
+
restrictToComponentsWithJsxReturn: false,
|
|
429
422
|
},
|
|
430
423
|
],
|
|
431
424
|
create(context, [options]) {
|
|
@@ -434,12 +427,12 @@ exports.requireComponentPropContracts = createRule({
|
|
|
434
427
|
return {};
|
|
435
428
|
}
|
|
436
429
|
const projectMetadata = (0, nx_utils_1.getProjectMetadata)(filename);
|
|
437
|
-
|
|
438
|
-
if (!projectMetadata || !(0, nx_utils_1.projectMatchesCriteria)(projectMetadata, projectCriteria)) {
|
|
430
|
+
if (!projectMetadata) {
|
|
439
431
|
return {};
|
|
440
432
|
}
|
|
441
433
|
const requiredProps = options.requiredProps ?? [];
|
|
442
434
|
const requiredInterfaces = options.requiredInterfaces ?? [];
|
|
435
|
+
const restrictToComponentsWithJsxReturn = options.restrictToComponentsWithJsxReturn ?? false;
|
|
443
436
|
if (requiredProps.length === 0 && requiredInterfaces.length === 0) {
|
|
444
437
|
return {};
|
|
445
438
|
}
|
|
@@ -504,7 +497,11 @@ exports.requireComponentPropContracts = createRule({
|
|
|
504
497
|
},
|
|
505
498
|
FunctionDeclaration(node) {
|
|
506
499
|
const componentName = node.id?.name;
|
|
507
|
-
|
|
500
|
+
const returnsIntrinsicJsx = (0, ast_utils_1.functionReturnsIntrinsicJSX)(node) === true;
|
|
501
|
+
if (!componentName ||
|
|
502
|
+
!(0, ast_utils_1.isReactComponent)(node) ||
|
|
503
|
+
(restrictToComponentsWithJsxReturn && !returnsIntrinsicJsx) ||
|
|
504
|
+
!isExportedComponentName(componentName, node)) {
|
|
508
505
|
return;
|
|
509
506
|
}
|
|
510
507
|
componentCandidates.push({
|
|
@@ -518,10 +515,16 @@ exports.requireComponentPropContracts = createRule({
|
|
|
518
515
|
return;
|
|
519
516
|
}
|
|
520
517
|
const { init } = node;
|
|
518
|
+
const wrappedComponentFunction = init?.type === utils_1.AST_NODE_TYPES.CallExpression ? getWrappedComponentFunction(init) : null;
|
|
521
519
|
const isComponent = init?.type === utils_1.AST_NODE_TYPES.ArrowFunctionExpression
|
|
522
520
|
? (0, ast_utils_1.isReactComponent)(init)
|
|
523
|
-
:
|
|
524
|
-
|
|
521
|
+
: wrappedComponentFunction !== null;
|
|
522
|
+
const returnsJsx = init?.type === utils_1.AST_NODE_TYPES.ArrowFunctionExpression
|
|
523
|
+
? (0, ast_utils_1.functionReturnsIntrinsicJSX)(init) === true
|
|
524
|
+
: wrappedComponentFunction !== null && (0, ast_utils_1.functionReturnsIntrinsicJSX)(wrappedComponentFunction) === true;
|
|
525
|
+
if (!isComponent ||
|
|
526
|
+
(restrictToComponentsWithJsxReturn && !returnsJsx) ||
|
|
527
|
+
!isExportedComponentName(node.id.name, node)) {
|
|
525
528
|
return;
|
|
526
529
|
}
|
|
527
530
|
componentCandidates.push({
|
package/src/lib/rules-map.d.ts
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
import { ESLintUtils } from "@typescript-eslint/utils";
|
|
2
2
|
export declare const rulesMap: {
|
|
3
|
+
"component-name-matches-filename": ESLintUtils.RuleModule<"componentNameMismatch", [{
|
|
4
|
+
allowedMismatches?: ReadonlyArray<{
|
|
5
|
+
file: string;
|
|
6
|
+
component: string;
|
|
7
|
+
}>;
|
|
8
|
+
}], unknown, ESLintUtils.RuleListener> & {
|
|
9
|
+
name: string;
|
|
10
|
+
};
|
|
11
|
+
"one-component-per-file": ESLintUtils.RuleModule<"tooManyExported" | "tooManyComponents", [{
|
|
12
|
+
exportedOnly?: boolean;
|
|
13
|
+
}], unknown, ESLintUtils.RuleListener> & {
|
|
14
|
+
name: string;
|
|
15
|
+
};
|
|
3
16
|
"cva-merge-base-classes-as-array": ESLintUtils.RuleModule<"stringNeedsArray" | "arrayNeedsSplit", [], unknown, ESLintUtils.RuleListener> & {
|
|
4
17
|
name: string;
|
|
5
18
|
};
|
|
@@ -57,7 +70,7 @@ export declare const rulesMap: {
|
|
|
57
70
|
"require-component-prop-contracts": ESLintUtils.RuleModule<"missingPropContracts", [{
|
|
58
71
|
requiredProps?: ReadonlyArray<string>;
|
|
59
72
|
requiredInterfaces?: ReadonlyArray<string>;
|
|
60
|
-
|
|
73
|
+
restrictToComponentsWithJsxReturn?: boolean;
|
|
61
74
|
}], unknown, ESLintUtils.RuleListener> & {
|
|
62
75
|
name: string;
|
|
63
76
|
};
|
package/src/lib/rules-map.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.rulesMap = void 0;
|
|
4
|
+
const component_name_matches_filename_1 = require("./rules/component-name-matches-filename/component-name-matches-filename");
|
|
4
5
|
const cva_merge_base_classes_as_array_1 = require("./rules/cva-merge-base-classes-as-array/cva-merge-base-classes-as-array");
|
|
5
6
|
const design_guideline_button_icon_size_match_1 = require("./rules/design-guideline-button-icon-size-match/design-guideline-button-icon-size-match");
|
|
6
7
|
const no_internal_barrel_files_1 = require("./rules/no-internal-barrel-files/no-internal-barrel-files");
|
|
@@ -8,6 +9,7 @@ const no_internal_graphql_when_tagged_with_gql_public_1 = require("./rules/no-in
|
|
|
8
9
|
const no_jest_mock_trackunit_react_core_hooks_1 = require("./rules/no-jest-mock-trackunit-react-core-hooks/no-jest-mock-trackunit-react-core-hooks");
|
|
9
10
|
const no_template_strings_in_classname_prop_1 = require("./rules/no-template-strings-in-classname-prop/no-template-strings-in-classname-prop");
|
|
10
11
|
const no_typescript_assertion_1 = require("./rules/no-typescript-assertion/no-typescript-assertion");
|
|
12
|
+
const one_component_per_file_1 = require("./rules/one-component-per-file/one-component-per-file");
|
|
11
13
|
const prefer_destructured_imports_1 = require("./rules/prefer-destructured-imports/prefer-destructured-imports");
|
|
12
14
|
const prefer_event_specific_callback_naming_1 = require("./rules/prefer-event-specific-callback-naming/prefer-event-specific-callback-naming");
|
|
13
15
|
const prefer_field_components_1 = require("./rules/prefer-field-components/prefer-field-components");
|
|
@@ -17,6 +19,8 @@ const require_component_prop_contracts_1 = require("./rules/require-component-pr
|
|
|
17
19
|
const require_list_item_virtualization_props_1 = require("./rules/require-list-item-virtualization-props/require-list-item-virtualization-props");
|
|
18
20
|
const require_optional_prop_initialization_1 = require("./rules/require-optional-prop-initialization/require-optional-prop-initialization");
|
|
19
21
|
exports.rulesMap = {
|
|
22
|
+
"component-name-matches-filename": component_name_matches_filename_1.componentNameMatchesFilename,
|
|
23
|
+
"one-component-per-file": one_component_per_file_1.oneComponentPerFile,
|
|
20
24
|
"cva-merge-base-classes-as-array": cva_merge_base_classes_as_array_1.cvaMergeBaseClassesAsArray,
|
|
21
25
|
"no-internal-barrel-files": no_internal_barrel_files_1.noInternalBarrelFiles,
|
|
22
26
|
"no-typescript-assertion": no_typescript_assertion_1.noTypescriptAssertion,
|
|
@@ -16,6 +16,9 @@ export declare const isParameterInitialized: (functionBody: Array<TSESTree.State
|
|
|
16
16
|
* Check if a parameter is used within the function body
|
|
17
17
|
*/
|
|
18
18
|
export declare const isParameterUsedInFunction: (context: TSESLint.RuleContext<string, ReadonlyArray<unknown>>, functionNode: TSESTree.FunctionDeclaration | TSESTree.ArrowFunctionExpression, paramName: string) => boolean;
|
|
19
|
+
type FunctionLikeNode = TSESTree.FunctionDeclaration | TSESTree.ArrowFunctionExpression | TSESTree.FunctionExpression;
|
|
20
|
+
export declare const functionReturnsJSX: (node: FunctionLikeNode) => boolean;
|
|
21
|
+
export declare const functionReturnsIntrinsicJSX: (node: FunctionLikeNode) => boolean;
|
|
19
22
|
/**
|
|
20
23
|
* Check if a function is likely a React component based on naming and JSX usage
|
|
21
24
|
*/
|
|
@@ -83,3 +86,4 @@ export declare const isIdentifierFromParameter: (identifier: TSESTree.Identifier
|
|
|
83
86
|
* // isIdentifierFromRenderPropCallback(onClose) => false
|
|
84
87
|
*/
|
|
85
88
|
export declare const isIdentifierFromRenderPropCallback: (identifier: TSESTree.Identifier, context: TSESLint.RuleContext<string, ReadonlyArray<unknown>>) => boolean;
|
|
89
|
+
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isIdentifierFromRenderPropCallback = exports.isIdentifierFromParameter = exports.isParameterOnlyUsedInJSX = exports.isReactComponent = exports.isParameterUsedInFunction = exports.isParameterInitialized = exports.hasExistingBodyInitializations = exports.isParameterExplicitlyDestructured = void 0;
|
|
3
|
+
exports.isIdentifierFromRenderPropCallback = exports.isIdentifierFromParameter = exports.isParameterOnlyUsedInJSX = exports.isReactComponent = exports.functionReturnsIntrinsicJSX = exports.functionReturnsJSX = exports.isParameterUsedInFunction = exports.isParameterInitialized = exports.hasExistingBodyInitializations = exports.isParameterExplicitlyDestructured = void 0;
|
|
4
4
|
const utils_1 = require("@typescript-eslint/utils");
|
|
5
5
|
/**
|
|
6
6
|
* Utility functions for analyzing AST nodes and function structure in ESLint rules.
|
|
@@ -22,6 +22,8 @@ const utils_1 = require("@typescript-eslint/utils");
|
|
|
22
22
|
*
|
|
23
23
|
* ## JSX/React Specific
|
|
24
24
|
* - `isReactComponent()` - Check if function is likely a React component
|
|
25
|
+
* - `functionReturnsJSX()` - Check if function body returns JSX
|
|
26
|
+
* - `functionReturnsIntrinsicJSX()` - Check if function body returns intrinsic JSX tags (e.g. `div`, `span`)
|
|
25
27
|
* - `isParameterOnlyUsedInJSX()` - Check if parameter is only used in JSX attributes
|
|
26
28
|
*/
|
|
27
29
|
/**
|
|
@@ -230,6 +232,76 @@ const getParameterRestUsage = (context, functionNode, paramName) => {
|
|
|
230
232
|
}
|
|
231
233
|
return { isUsedViaRest: false };
|
|
232
234
|
};
|
|
235
|
+
const jsxTagNameIsIntrinsic = (name) => name.type === utils_1.AST_NODE_TYPES.JSXIdentifier && /^[a-z]/.test(name.name);
|
|
236
|
+
const nodeContainsJSX = (node) => {
|
|
237
|
+
if (node.type === utils_1.AST_NODE_TYPES.JSXElement) {
|
|
238
|
+
return true;
|
|
239
|
+
}
|
|
240
|
+
if (node.type === utils_1.AST_NODE_TYPES.JSXFragment) {
|
|
241
|
+
return true;
|
|
242
|
+
}
|
|
243
|
+
if (node.type === utils_1.AST_NODE_TYPES.ConditionalExpression) {
|
|
244
|
+
return nodeContainsJSX(node.consequent) || nodeContainsJSX(node.alternate);
|
|
245
|
+
}
|
|
246
|
+
if (node.type === utils_1.AST_NODE_TYPES.LogicalExpression) {
|
|
247
|
+
return nodeContainsJSX(node.left) || nodeContainsJSX(node.right);
|
|
248
|
+
}
|
|
249
|
+
return false;
|
|
250
|
+
};
|
|
251
|
+
const nodeContainsIntrinsicJSX = (node) => {
|
|
252
|
+
if (node.type === utils_1.AST_NODE_TYPES.JSXElement) {
|
|
253
|
+
if (jsxTagNameIsIntrinsic(node.openingElement.name)) {
|
|
254
|
+
return true;
|
|
255
|
+
}
|
|
256
|
+
return node.children.some(child => {
|
|
257
|
+
if (child.type === utils_1.AST_NODE_TYPES.JSXElement || child.type === utils_1.AST_NODE_TYPES.JSXFragment) {
|
|
258
|
+
return nodeContainsIntrinsicJSX(child);
|
|
259
|
+
}
|
|
260
|
+
if (child.type === utils_1.AST_NODE_TYPES.JSXExpressionContainer &&
|
|
261
|
+
child.expression.type !== utils_1.AST_NODE_TYPES.JSXEmptyExpression) {
|
|
262
|
+
return nodeContainsIntrinsicJSX(child.expression);
|
|
263
|
+
}
|
|
264
|
+
return false;
|
|
265
|
+
});
|
|
266
|
+
}
|
|
267
|
+
if (node.type === utils_1.AST_NODE_TYPES.JSXFragment) {
|
|
268
|
+
return node.children.some(child => {
|
|
269
|
+
if (child.type === utils_1.AST_NODE_TYPES.JSXElement || child.type === utils_1.AST_NODE_TYPES.JSXFragment) {
|
|
270
|
+
return nodeContainsIntrinsicJSX(child);
|
|
271
|
+
}
|
|
272
|
+
if (child.type === utils_1.AST_NODE_TYPES.JSXExpressionContainer &&
|
|
273
|
+
child.expression.type !== utils_1.AST_NODE_TYPES.JSXEmptyExpression) {
|
|
274
|
+
return nodeContainsIntrinsicJSX(child.expression);
|
|
275
|
+
}
|
|
276
|
+
return false;
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
if (node.type === utils_1.AST_NODE_TYPES.ConditionalExpression) {
|
|
280
|
+
return nodeContainsIntrinsicJSX(node.consequent) || nodeContainsIntrinsicJSX(node.alternate);
|
|
281
|
+
}
|
|
282
|
+
if (node.type === utils_1.AST_NODE_TYPES.LogicalExpression) {
|
|
283
|
+
return nodeContainsIntrinsicJSX(node.left) || nodeContainsIntrinsicJSX(node.right);
|
|
284
|
+
}
|
|
285
|
+
return false;
|
|
286
|
+
};
|
|
287
|
+
const functionReturnsJSX = (node) => {
|
|
288
|
+
if (node.body.type === utils_1.AST_NODE_TYPES.BlockStatement) {
|
|
289
|
+
return node.body.body.some(statement => statement.type === utils_1.AST_NODE_TYPES.ReturnStatement &&
|
|
290
|
+
statement.argument !== null &&
|
|
291
|
+
nodeContainsJSX(statement.argument));
|
|
292
|
+
}
|
|
293
|
+
return nodeContainsJSX(node.body);
|
|
294
|
+
};
|
|
295
|
+
exports.functionReturnsJSX = functionReturnsJSX;
|
|
296
|
+
const functionReturnsIntrinsicJSX = (node) => {
|
|
297
|
+
if (node.body.type === utils_1.AST_NODE_TYPES.BlockStatement) {
|
|
298
|
+
return node.body.body.some(statement => statement.type === utils_1.AST_NODE_TYPES.ReturnStatement &&
|
|
299
|
+
statement.argument !== null &&
|
|
300
|
+
nodeContainsIntrinsicJSX(statement.argument));
|
|
301
|
+
}
|
|
302
|
+
return nodeContainsIntrinsicJSX(node.body);
|
|
303
|
+
};
|
|
304
|
+
exports.functionReturnsIntrinsicJSX = functionReturnsIntrinsicJSX;
|
|
233
305
|
/**
|
|
234
306
|
* Check if a function is likely a React component based on naming and JSX usage
|
|
235
307
|
*/
|
|
@@ -240,26 +312,7 @@ const isReactComponent = (node) => {
|
|
|
240
312
|
if (functionName && startsWithUppercase.test(functionName)) {
|
|
241
313
|
return true;
|
|
242
314
|
}
|
|
243
|
-
|
|
244
|
-
const hasJSXReturn = (body) => {
|
|
245
|
-
if (body.type === utils_1.AST_NODE_TYPES.JSXElement || body.type === utils_1.AST_NODE_TYPES.JSXFragment) {
|
|
246
|
-
return true;
|
|
247
|
-
}
|
|
248
|
-
// Handle conditional expressions that contain JSX: condition ? <JSX /> : null
|
|
249
|
-
if (body.type === utils_1.AST_NODE_TYPES.ConditionalExpression) {
|
|
250
|
-
return hasJSXReturn(body.consequent) || hasJSXReturn(body.alternate);
|
|
251
|
-
}
|
|
252
|
-
if (body.type === utils_1.AST_NODE_TYPES.BlockStatement) {
|
|
253
|
-
return body.body.some(stmt => {
|
|
254
|
-
if (stmt.type === utils_1.AST_NODE_TYPES.ReturnStatement && stmt.argument) {
|
|
255
|
-
return hasJSXReturn(stmt.argument);
|
|
256
|
-
}
|
|
257
|
-
return false;
|
|
258
|
-
});
|
|
259
|
-
}
|
|
260
|
-
return false;
|
|
261
|
-
};
|
|
262
|
-
return hasJSXReturn(node.body);
|
|
315
|
+
return (0, exports.functionReturnsJSX)(node);
|
|
263
316
|
};
|
|
264
317
|
exports.isReactComponent = isReactComponent;
|
|
265
318
|
/**
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared utilities for detecting React components and their export status in a file.
|
|
3
|
+
*
|
|
4
|
+
* Used by `one-component-per-file` and `component-name-matches-filename` rules.
|
|
5
|
+
*
|
|
6
|
+
* ## Handled patterns
|
|
7
|
+
* - `export function Foo() {}`
|
|
8
|
+
* - `export const Foo = () => {}`
|
|
9
|
+
* - `export default function Foo() {}`
|
|
10
|
+
* - `export default () => {}`
|
|
11
|
+
* - `const Foo = () => {}; export { Foo }`
|
|
12
|
+
* - `const Foo = () => {}; export { Foo as Bar }`
|
|
13
|
+
* - `export const Foo = forwardRef(...)` / `memo(...)` (React wrapper calls)
|
|
14
|
+
*/
|
|
15
|
+
import { TSESTree } from "@typescript-eslint/utils";
|
|
16
|
+
export type ComponentEntry = {
|
|
17
|
+
/** The name as it appears in the export (null for anonymous default exports). */
|
|
18
|
+
name: string | null;
|
|
19
|
+
/** The declaration node to report on (FunctionDeclaration or VariableDeclarator). */
|
|
20
|
+
node: TSESTree.Node;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Creates a stateful tracker that collects React component declarations and export
|
|
24
|
+
* information as ESLint visits AST nodes. Call `getExportedComponents()` or
|
|
25
|
+
* `getAllComponents()` inside a `Program:exit` handler once traversal is complete.
|
|
26
|
+
*/
|
|
27
|
+
export declare const createComponentFileTracker: () => {
|
|
28
|
+
onFunctionDeclaration(node: TSESTree.FunctionDeclaration): void;
|
|
29
|
+
onVariableDeclarator(node: TSESTree.VariableDeclarator): void;
|
|
30
|
+
onExportNamedDeclaration(node: TSESTree.ExportNamedDeclaration): void;
|
|
31
|
+
onExportDefaultDeclaration(node: TSESTree.ExportDefaultDeclaration): void;
|
|
32
|
+
/** Returns all exported React component entries. Call from `Program:exit`. */
|
|
33
|
+
getExportedComponents(): Array<ComponentEntry>;
|
|
34
|
+
/** Returns all top-level React component entries, exported or not. Call from `Program:exit`. */
|
|
35
|
+
getAllComponents(): Array<ComponentEntry>;
|
|
36
|
+
};
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Shared utilities for detecting React components and their export status in a file.
|
|
4
|
+
*
|
|
5
|
+
* Used by `one-component-per-file` and `component-name-matches-filename` rules.
|
|
6
|
+
*
|
|
7
|
+
* ## Handled patterns
|
|
8
|
+
* - `export function Foo() {}`
|
|
9
|
+
* - `export const Foo = () => {}`
|
|
10
|
+
* - `export default function Foo() {}`
|
|
11
|
+
* - `export default () => {}`
|
|
12
|
+
* - `const Foo = () => {}; export { Foo }`
|
|
13
|
+
* - `const Foo = () => {}; export { Foo as Bar }`
|
|
14
|
+
* - `export const Foo = forwardRef(...)` / `memo(...)` (React wrapper calls)
|
|
15
|
+
*/
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.createComponentFileTracker = void 0;
|
|
18
|
+
const utils_1 = require("@typescript-eslint/utils");
|
|
19
|
+
const ast_utils_1 = require("./ast-utils");
|
|
20
|
+
const isComponentName = (name) => /^[A-Z]/.test(name);
|
|
21
|
+
const REACT_WRAPPER_NAMES = new Set(["memo", "forwardRef"]);
|
|
22
|
+
/**
|
|
23
|
+
* Returns true only for known React higher-order component wrappers:
|
|
24
|
+
* `memo(...)`, `forwardRef(...)`, `React.memo(...)`, `React.forwardRef(...)`.
|
|
25
|
+
*
|
|
26
|
+
* This is intentionally narrow to avoid false positives on other PascalCase
|
|
27
|
+
* call expressions like `createLazyRoute(...)` or `createThemeWithBranding(...)`.
|
|
28
|
+
*/
|
|
29
|
+
const isReactWrapperCall = (init) => {
|
|
30
|
+
const { callee } = init;
|
|
31
|
+
if (callee.type === utils_1.AST_NODE_TYPES.Identifier) {
|
|
32
|
+
return REACT_WRAPPER_NAMES.has(callee.name);
|
|
33
|
+
}
|
|
34
|
+
if (callee.type === utils_1.AST_NODE_TYPES.MemberExpression) {
|
|
35
|
+
return (callee.object.type === utils_1.AST_NODE_TYPES.Identifier &&
|
|
36
|
+
callee.object.name === "React" &&
|
|
37
|
+
callee.property.type === utils_1.AST_NODE_TYPES.Identifier &&
|
|
38
|
+
REACT_WRAPPER_NAMES.has(callee.property.name));
|
|
39
|
+
}
|
|
40
|
+
return false;
|
|
41
|
+
};
|
|
42
|
+
const isFunctionLikeComponent = (fn, name) => {
|
|
43
|
+
// Named functions are components only if PascalCase. camelCase render-function
|
|
44
|
+
// callbacks (e.g. `renderFn`, `shapeEdgeLabelPortalRender`) return JSX but are
|
|
45
|
+
// NOT React components and must not be flagged.
|
|
46
|
+
if (name !== null)
|
|
47
|
+
return isComponentName(name);
|
|
48
|
+
// Anonymous functions: fall back to JSX-return detection (e.g. `export default () => <div />`)
|
|
49
|
+
return (0, ast_utils_1.functionReturnsJSX)(fn);
|
|
50
|
+
};
|
|
51
|
+
const isTopLevelFunctionDeclaration = (node) => node.parent.type === utils_1.AST_NODE_TYPES.Program ||
|
|
52
|
+
node.parent.type === utils_1.AST_NODE_TYPES.ExportNamedDeclaration ||
|
|
53
|
+
node.parent.type === utils_1.AST_NODE_TYPES.ExportDefaultDeclaration;
|
|
54
|
+
const isTopLevelVariableDeclarator = (node) => node.parent.parent.type === utils_1.AST_NODE_TYPES.Program ||
|
|
55
|
+
node.parent.parent.type === utils_1.AST_NODE_TYPES.ExportNamedDeclaration;
|
|
56
|
+
/**
|
|
57
|
+
* Creates a stateful tracker that collects React component declarations and export
|
|
58
|
+
* information as ESLint visits AST nodes. Call `getExportedComponents()` or
|
|
59
|
+
* `getAllComponents()` inside a `Program:exit` handler once traversal is complete.
|
|
60
|
+
*/
|
|
61
|
+
const createComponentFileTracker = () => {
|
|
62
|
+
// component name → declaration node
|
|
63
|
+
const namedComponents = new Map();
|
|
64
|
+
// names exported inline: `export function Foo` / `export const Foo = ...`
|
|
65
|
+
const inlineExportedNames = new Set();
|
|
66
|
+
// re-export specifiers: local name → exported name (`export { Foo as Bar }`)
|
|
67
|
+
const reExportedNames = new Map();
|
|
68
|
+
// default export tracking
|
|
69
|
+
let defaultExportFunctionName = null; // `export default function Foo() {}`
|
|
70
|
+
let defaultExportIdentifier = null; // `export default Foo`
|
|
71
|
+
let anonymousDefaultExportNode = null; // `export default () => ...`
|
|
72
|
+
return {
|
|
73
|
+
onFunctionDeclaration(node) {
|
|
74
|
+
if (!isTopLevelFunctionDeclaration(node))
|
|
75
|
+
return;
|
|
76
|
+
const name = node.id?.name ?? null;
|
|
77
|
+
if (!isFunctionLikeComponent(node, name))
|
|
78
|
+
return;
|
|
79
|
+
if (name)
|
|
80
|
+
namedComponents.set(name, node);
|
|
81
|
+
if (node.parent.type === utils_1.AST_NODE_TYPES.ExportDefaultDeclaration) {
|
|
82
|
+
defaultExportFunctionName = name;
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
onVariableDeclarator(node) {
|
|
86
|
+
if (!isTopLevelVariableDeclarator(node))
|
|
87
|
+
return;
|
|
88
|
+
if (node.id.type !== utils_1.AST_NODE_TYPES.Identifier)
|
|
89
|
+
return;
|
|
90
|
+
const name = node.id.name;
|
|
91
|
+
const init = node.init;
|
|
92
|
+
if (!init)
|
|
93
|
+
return;
|
|
94
|
+
if (init.type === utils_1.AST_NODE_TYPES.ArrowFunctionExpression || init.type === utils_1.AST_NODE_TYPES.FunctionExpression) {
|
|
95
|
+
if (isFunctionLikeComponent(init, name)) {
|
|
96
|
+
namedComponents.set(name, node);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
else if (init.type === utils_1.AST_NODE_TYPES.CallExpression && isReactWrapperCall(init)) {
|
|
100
|
+
// forwardRef / memo wrappers — always produce a component regardless of surrounding name
|
|
101
|
+
namedComponents.set(name, node);
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
onExportNamedDeclaration(node) {
|
|
105
|
+
if (node.source !== null)
|
|
106
|
+
return; // skip `export { Foo } from './other'`
|
|
107
|
+
if (node.declaration) {
|
|
108
|
+
if (node.declaration.type === utils_1.AST_NODE_TYPES.FunctionDeclaration) {
|
|
109
|
+
const name = node.declaration.id?.name;
|
|
110
|
+
if (name)
|
|
111
|
+
inlineExportedNames.add(name);
|
|
112
|
+
}
|
|
113
|
+
else if (node.declaration.type === utils_1.AST_NODE_TYPES.VariableDeclaration) {
|
|
114
|
+
for (const decl of node.declaration.declarations) {
|
|
115
|
+
if (decl.id.type === utils_1.AST_NODE_TYPES.Identifier) {
|
|
116
|
+
inlineExportedNames.add(decl.id.name);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
for (const specifier of node.specifiers) {
|
|
122
|
+
const localName = specifier.local.name;
|
|
123
|
+
const exportedName = specifier.exported.type === utils_1.AST_NODE_TYPES.Identifier ? specifier.exported.name : specifier.exported.value;
|
|
124
|
+
reExportedNames.set(localName, exportedName);
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
onExportDefaultDeclaration(node) {
|
|
128
|
+
const decl = node.declaration;
|
|
129
|
+
if (decl.type === utils_1.AST_NODE_TYPES.Identifier) {
|
|
130
|
+
// `export default Foo` — resolved in getExportedComponents after full traversal
|
|
131
|
+
defaultExportIdentifier = decl.name;
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
// Named `export default function Foo() {}` — handled by onFunctionDeclaration
|
|
135
|
+
if (decl.type === utils_1.AST_NODE_TYPES.FunctionDeclaration && decl.id?.name)
|
|
136
|
+
return;
|
|
137
|
+
if (decl.type === utils_1.AST_NODE_TYPES.ArrowFunctionExpression || decl.type === utils_1.AST_NODE_TYPES.FunctionExpression) {
|
|
138
|
+
if (isFunctionLikeComponent(decl, null)) {
|
|
139
|
+
anonymousDefaultExportNode = node;
|
|
140
|
+
}
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
// Anonymous function declaration: `export default function() {}`
|
|
144
|
+
if (decl.type === utils_1.AST_NODE_TYPES.FunctionDeclaration && !decl.id) {
|
|
145
|
+
if (isFunctionLikeComponent(decl, null)) {
|
|
146
|
+
anonymousDefaultExportNode = node;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
},
|
|
150
|
+
/** Returns all exported React component entries. Call from `Program:exit`. */
|
|
151
|
+
getExportedComponents() {
|
|
152
|
+
const result = [];
|
|
153
|
+
for (const name of inlineExportedNames) {
|
|
154
|
+
const node = namedComponents.get(name);
|
|
155
|
+
if (node)
|
|
156
|
+
result.push({ name, node });
|
|
157
|
+
}
|
|
158
|
+
for (const [localName, exportedName] of reExportedNames) {
|
|
159
|
+
const node = namedComponents.get(localName);
|
|
160
|
+
if (node)
|
|
161
|
+
result.push({ name: exportedName, node });
|
|
162
|
+
}
|
|
163
|
+
if (defaultExportFunctionName !== null) {
|
|
164
|
+
const node = namedComponents.get(defaultExportFunctionName);
|
|
165
|
+
if (node)
|
|
166
|
+
result.push({ name: defaultExportFunctionName, node });
|
|
167
|
+
}
|
|
168
|
+
if (defaultExportIdentifier !== null) {
|
|
169
|
+
const node = namedComponents.get(defaultExportIdentifier);
|
|
170
|
+
if (node)
|
|
171
|
+
result.push({ name: defaultExportIdentifier, node });
|
|
172
|
+
}
|
|
173
|
+
if (anonymousDefaultExportNode !== null) {
|
|
174
|
+
result.push({ name: null, node: anonymousDefaultExportNode });
|
|
175
|
+
}
|
|
176
|
+
return result;
|
|
177
|
+
},
|
|
178
|
+
/** Returns all top-level React component entries, exported or not. Call from `Program:exit`. */
|
|
179
|
+
getAllComponents() {
|
|
180
|
+
const result = [];
|
|
181
|
+
for (const [name, node] of namedComponents) {
|
|
182
|
+
result.push({ name, node });
|
|
183
|
+
}
|
|
184
|
+
if (anonymousDefaultExportNode !== null) {
|
|
185
|
+
result.push({ name: null, node: anonymousDefaultExportNode });
|
|
186
|
+
}
|
|
187
|
+
return result;
|
|
188
|
+
},
|
|
189
|
+
};
|
|
190
|
+
};
|
|
191
|
+
exports.createComponentFileTracker = createComponentFileTracker;
|
|
192
|
+
//# sourceMappingURL=component-utils.js.map
|
package/src/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../libs/eslint/plugin-trackunit/src/index.ts"],"names":[],"mappings":";;;AAAA,+CAA2C;AAE3C,kBAAe,oBAAQ,CAAC;AAExB,uCAAuC;AAA9B,iGAAA,OAAO,OAAA;AAChB,0EAAuE;AAA9D,kHAAA,cAAc,OAAA;AACvB,4CAAsD;AAA7C,yGAAA,gBAAgB,OAAA;AAGzB,kEAAsE;AAA7D,+GAAA,gBAAgB,OAAA;AACzB,gDAAgF;AAAvE,kGAAA,OAAO,OAAA;AAAE,gGAAA,KAAK,OAAA;AAAE,6FAAA,EAAE,OAAA;AAAE,qGAAA,UAAU,OAAA;AAAE,mGAAA,QAAQ,OAAA","sourcesContent":["import { rulesMap } from \"./lib/rules-map\";\n\nexport default rulesMap;\n\nexport { configs } from \"./lib/config\";\nexport { createSkipWhen } from \"./lib/config-helpers/create-skip-when\";\nexport { findMonorepoRoot } from \"./lib/config/utils\";\nexport type { MatchCriteria, ProjectMetadata } from \"./lib/utils/nx-utils\";\n\nexport { strictJsdocRules } from \"./lib/config/fragments/jsdoc-rules\";\nexport { globals, jsdoc, nx, reactHooks, tsParser } from \"./lib/config/plugins\";\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ignores.js","sourceRoot":"","sources":["../../../../../../../../libs/eslint/plugin-trackunit/src/lib/config/fragments/ignores.ts"],"names":[],"mappings":";;;AAEa,QAAA,aAAa,GAAkB;IAC1C,OAAO,EAAE;QACP,oBAAoB;QACpB,qBAAqB;QACrB,kBAAkB;QAClB,sBAAsB;QACtB,kBAAkB;QAClB,iBAAiB;QACjB,4BAA4B;QAC5B,uBAAuB;QACvB,cAAc;QACd,eAAe;KAChB;CACF,CAAC","sourcesContent":["import type { Linter } from \"eslint\";\n\nexport const globalIgnores: Linter.Config = {\n ignores: [\n \"**/src/gql-api.tsx\",\n \"**/src/typings/**/*\",\n \"**/testUtils.tsx\",\n \"**/webpack.config.js\",\n \"**/jest.config.*\",\n \"**/jest.setup.*\",\n \"**/src/**/generated/**/*.*\",\n \"**/src/**/generated.*\",\n \"**/dist/**/*\",\n \"**/*.docs.mdx\",\n ],\n};\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"import-rules.js","sourceRoot":"","sources":["../../../../../../../../libs/eslint/plugin-trackunit/src/lib/config/fragments/import-rules.ts"],"names":[],"mappings":";;;AACA,4EAAuE;AACvE,wCAA0C;AAE7B,QAAA,WAAW,GAAuB;IAC7C,mBAAmB,EAAE;QACnB,OAAO;QACP;YACE,cAAc,EAAE,IAAI;SACrB;KACF;IACD,gBAAgB,EAAE,KAAK;CACxB,CAAC;AAEK,MAAM,wCAAwC,GAAG,CAAC,OAAe,EAAiB,EAAE,CACzF,IAAA,iCAAc,EAAC;IACb,IAAI,EAAE,EAAE,IAAI,EAAE,CAAC,YAAY,CAAC,EAAE;IAC9B,OAAO,EAAE;QACP,UAAU,EAAE,sBAAY;KACzB;IACD,KAAK,EAAE;QACL,qCAAqC,EAAE;YACrC,OAAO;YACP;gBACE,UAAU,EAAE,OAAO;gBACnB,eAAe,EAAE;oBACf,kBAAkB;oBAClB,eAAe;oBACf,oBAAoB;oBACpB,oBAAoB;oBACpB,iBAAiB;oBACjB,YAAY;oBACZ,aAAa;oBACb,eAAe;oBACf,kBAAkB;oBAClB,kBAAkB;oBAClB,iBAAiB;oBACjB,iBAAiB;oBACjB,mBAAmB;oBACnB,0BAA0B;oBAC1B,uBAAuB;oBACvB,4BAA4B;oBAC5B,kBAAkB;oBAClB,eAAe;oBACf,aAAa;oBACb,6BAA6B;oBAC7B,oBAAoB;oBACpB,6CAA6C;oBAC7C,4BAA4B;iBAC7B;gBACD,oBAAoB,EAAE,KAAK;gBAC3B,gBAAgB,EAAE,IAAI;gBACtB,mBAAmB,EAAE,IAAI;aAC1B;SACF;KACF;CACF,CAAC,CAAC;AA1CQ,QAAA,wCAAwC,4CA0ChD","sourcesContent":["import type { Linter } from \"eslint\";\nimport { createSkipWhen } from \"../../config-helpers/create-skip-when\";\nimport { importPlugin } from \"../plugins\";\n\nexport const importRules: Linter.RulesRecord = {\n \"import-x/no-cycle\": [\n \"error\",\n {\n ignoreExternal: true,\n },\n ],\n \"import-x/first\": \"off\",\n};\n\nexport const createImportExtraneousDependenciesConfig = (rootDir: string): Linter.Config =>\n createSkipWhen({\n when: { tags: [\"scope:tool\"] },\n plugins: {\n \"import-x\": importPlugin,\n },\n rules: {\n \"import-x/no-extraneous-dependencies\": [\n \"error\",\n {\n packageDir: rootDir,\n devDependencies: [\n \"**/*.cy.{ts,tsx}\",\n \"**/cypress/**\",\n \"**/*.spec.{ts,tsx}\",\n \"**/*.test.{ts,tsx}\",\n \"**/jest.setup.*\",\n \"**/test/**\",\n \"**/tests/**\",\n \"**/testing/**\",\n \"**/test-setup/**\",\n \"**/test-utils/**\",\n \"**/__tests__/**\",\n \"**/__mocks__/**\",\n \"**/mocks.{ts,tsx}\",\n \"**/core-contexts-test/**\",\n \"**/*.stories.{ts,tsx}\",\n \"**/storybookUtils.{ts,tsx}\",\n \"**/.storybook/**\",\n \"**/scripts/**\",\n \"**/tools/**\",\n \"**/*.config.{ts,js,cjs,mjs}\",\n \"**/css/tailwind/**\",\n \"**/css/tailwind-custom-properties-plugin/**\",\n \"**/css/component-tokens/**\",\n ],\n optionalDependencies: false,\n peerDependencies: true,\n bundledDependencies: true,\n },\n ],\n },\n });\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"jest-overrides.js","sourceRoot":"","sources":["../../../../../../../../libs/eslint/plugin-trackunit/src/lib/config/fragments/jest-overrides.ts"],"names":[],"mappings":";;;AACA,wCAAkD;AAErC,QAAA,iBAAiB,GAAkB;IAC9C,KAAK,EAAE,CAAC,cAAc,EAAE,eAAe,CAAC;IACxC,eAAe,EAAE;QACf,WAAW,EAAE,CAAC;QACd,UAAU,EAAE,QAAQ;QACpB,aAAa,EAAE;YACb,OAAO,EAAE,CAAC,oBAAoB,CAAC;SAChC;KACF;IAED,OAAO,EAAE;QACP,IAAI,EAAJ,cAAI;QACJ,iBAAiB,EAAE,wBAAc;KAClC;IAED,KAAK,EAAE;QACL,GAAG,cAAI,CAAC,OAAO,CAAC,WAAW,CAAC,KAAK;QACjC,GAAG,cAAI,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK;QAC3B,oCAAoC,EAAE,KAAK;QAC3C,sCAAsC,EAAE,KAAK;QAC7C,0CAA0C,EAAE,KAAK;QACjD,oCAAoC,EAAE,KAAK;QAC3C,oDAAoD,EAAE,OAAO;QAC7D,YAAY,EAAE,KAAK;QACnB,+CAA+C,EAAE,KAAK;KACvD;CACF,CAAC","sourcesContent":["import type { Linter } from \"eslint\";\nimport { jest, testingLibrary } from \"../plugins\";\n\nexport const baseJestOverrides: Linter.Config = {\n files: [\"**/*.spec.ts\", \"**/*.spec.tsx\"],\n languageOptions: {\n ecmaVersion: 5,\n sourceType: \"script\",\n parserOptions: {\n project: [\"./tsconfig.*?.json\"],\n },\n },\n\n plugins: {\n jest,\n \"testing-library\": testingLibrary,\n },\n\n rules: {\n ...jest.configs.recommended.rules,\n ...jest.configs.style.rules,\n \"@typescript-eslint/no-explicit-any\": \"off\",\n \"@typescript-eslint/no-empty-function\": \"off\",\n \"@typescript-eslint/no-non-null-assertion\": \"off\",\n \"@trackunit/no-typescript-assertion\": \"off\",\n \"@trackunit/no-jest-mock-trackunit-react-core-hooks\": \"error\",\n \"no-console\": \"off\",\n \"@typescript-eslint/strict-boolean-expressions\": \"off\",\n },\n};\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"jsdoc-rules.js","sourceRoot":"","sources":["../../../../../../../../libs/eslint/plugin-trackunit/src/lib/config/fragments/jsdoc-rules.ts"],"names":[],"mappings":";;;AAEa,QAAA,eAAe,GAAuB;IACjD,iBAAiB,EAAE;QACjB,OAAO;QACP,OAAO;QACP;YACE,UAAU,EAAE,CAAC;SACd;KACF;IACD,uBAAuB,EAAE,OAAO;IAChC,wBAAwB,EAAE,KAAK;IAC/B,yBAAyB,EAAE,KAAK;IAChC,4BAA4B,EAAE;QAC5B,OAAO;QACP;YACE,QAAQ,EAAE;gBACR;oBACE,OAAO,EAAE,sCAAsC;oBAC/C,OAAO,EAAE,KAAK;oBACd,OAAO,EAAE,qDAAqD;iBAC/D;aACF;SACF;KACF;CACF,CAAC;AAEW,QAAA,gBAAgB,GAAuB;IAClD,qBAAqB,EAAE;QACrB,OAAO;QACP;YACE,UAAU,EAAE,IAAI;YAEhB,OAAO,EAAE;gBACP,uBAAuB,EAAE,IAAI;gBAC7B,gBAAgB,EAAE,IAAI;gBACtB,mBAAmB,EAAE,IAAI;gBACzB,kBAAkB,EAAE,IAAI;gBACxB,gBAAgB,EAAE,IAAI;aACvB;SACF;KACF;IAED,0BAA0B,EAAE;QAC1B,OAAO;QACP;YACE,YAAY,EAAE,CAAC,KAAK,CAAC;SACtB;KACF;IAED,yBAAyB,EAAE,OAAO;IAClC,4BAA4B,EAAE,OAAO;IACrC,mBAAmB,EAAE,OAAO;IAC5B,iCAAiC,EAAE,OAAO;IAC1C,oBAAoB,EAAE,OAAO;IAC7B,4BAA4B,EAAE,OAAO;IACrC,uBAAuB,EAAE,OAAO;IAChC,mBAAmB,EAAE,OAAO;IAC5B,oBAAoB,EAAE,OAAO;IAC7B,uBAAuB,EAAE,OAAO;IAChC,kBAAkB,EAAE,OAAO;IAC3B,6BAA6B,EAAE,OAAO;IACtC,wBAAwB,EAAE,OAAO;IACjC,0BAA0B,EAAE,OAAO;IACnC,wBAAwB,EAAE,OAAO;IACjC,oCAAoC,EAAE,OAAO;IAC7C,6BAA6B,EAAE,OAAO;IACtC,6BAA6B,EAAE,OAAO;IACtC,6BAA6B,EAAE,OAAO;IACtC,mCAAmC,EAAE,OAAO;IAC5C,sBAAsB,EAAE,OAAO;IAC/B,4BAA4B,EAAE,OAAO;CACtC,CAAC","sourcesContent":["import type { Linter } from \"eslint\";\n\nexport const basicJsdocRules: Linter.RulesRecord = {\n \"jsdoc/tag-lines\": [\n \"error\",\n \"never\",\n {\n startLines: 1,\n },\n ],\n \"jsdoc/check-alignment\": \"error\",\n \"prefer-arrow-functions\": \"off\",\n \"jsdoc/check-indentation\": \"off\",\n \"jsdoc/no-restricted-syntax\": [\n \"error\",\n {\n contexts: [\n {\n comment: \"JsdocBlock:has(JsdocTag[tag=/type/])\",\n context: \"any\",\n message: \"Projects should not use @type annotation in JSDocs.\",\n },\n ],\n },\n ],\n};\n\nexport const strictJsdocRules: Linter.RulesRecord = {\n \"jsdoc/require-jsdoc\": [\n \"error\",\n {\n publicOnly: true,\n\n require: {\n ArrowFunctionExpression: true,\n ClassDeclaration: true,\n FunctionDeclaration: true,\n FunctionExpression: true,\n MethodDefinition: true,\n },\n },\n ],\n\n \"jsdoc/no-undefined-types\": [\n \"error\",\n {\n definedTypes: [\"JSX\"],\n },\n ],\n\n \"jsdoc/check-param-names\": \"error\",\n \"jsdoc/require-returns-type\": \"error\",\n \"jsdoc/valid-types\": \"error\",\n \"jsdoc/require-param-description\": \"error\",\n \"jsdoc/check-access\": \"error\",\n \"jsdoc/check-property-names\": \"error\",\n \"jsdoc/check-tag-names\": \"error\",\n \"jsdoc/check-types\": \"error\",\n \"jsdoc/check-values\": \"error\",\n \"jsdoc/check-alignment\": \"error\",\n \"jsdoc/empty-tags\": \"error\",\n \"jsdoc/implements-on-classes\": \"error\",\n \"jsdoc/multiline-blocks\": \"error\",\n \"jsdoc/no-multi-asterisks\": \"error\",\n \"jsdoc/require-property\": \"error\",\n \"jsdoc/require-property-description\": \"error\",\n \"jsdoc/require-property-name\": \"error\",\n \"jsdoc/require-property-type\": \"error\",\n \"jsdoc/require-returns-check\": \"error\",\n \"jsdoc/require-returns-description\": \"error\",\n \"jsdoc/require-yields\": \"error\",\n \"jsdoc/require-yields-check\": \"error\",\n};\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"module-boundaries.js","sourceRoot":"","sources":["../../../../../../../../libs/eslint/plugin-trackunit/src/lib/config/fragments/module-boundaries.ts"],"names":[],"mappings":";;;AAEa,QAAA,mBAAmB,GAAuB;IACrD,+BAA+B,EAAE;QAC/B,OAAO;QACP;YACE,KAAK,EAAE,EAAE;YAET,cAAc,EAAE;gBACd;oBACE,SAAS,EAAE,UAAU;oBACrB,wBAAwB,EAAE,CAAC,gBAAgB,EAAE,YAAY,EAAE,cAAc,CAAC;oBAC1E,qBAAqB,EAAE,CAAC,SAAS,EAAE,eAAe,CAAC;iBACpD;gBACD;oBACE,SAAS,EAAE,gBAAgB;oBAC3B,wBAAwB,EAAE,CAAC,YAAY,EAAE,cAAc,CAAC;oBACxD,qBAAqB,EAAE,CAAC,SAAS,EAAE,eAAe,CAAC;iBACpD;gBACD;oBACE,SAAS,EAAE,YAAY;oBACvB,wBAAwB,EAAE,CAAC,YAAY,EAAE,cAAc,CAAC;oBACxD,qBAAqB,EAAE,CAAC,SAAS,EAAE,eAAe,CAAC;iBACpD;gBACD;oBACE,SAAS,EAAE,cAAc;oBACzB,wBAAwB,EAAE,CAAC,cAAc,CAAC;oBAC1C,qBAAqB,EAAE,CAAC,SAAS,EAAE,QAAQ,CAAC;iBAC7C;gBACD;oBACE,SAAS,EAAE,WAAW;oBACtB,wBAAwB,EAAE,CAAC,cAAc,EAAE,cAAc,CAAC;iBAC3D;gBACD;oBACE,SAAS,EAAE,cAAc;oBACzB,wBAAwB,EAAE,CAAC,cAAc,CAAC;iBAC3C;gBACD;oBACE,SAAS,EAAE,YAAY;oBACvB,wBAAwB,EAAE,CAAC,YAAY,CAAC;iBACzC;gBACD;oBACE,SAAS,EAAE,cAAc;oBACzB,wBAAwB,EAAE,CAAC,cAAc,CAAC;iBAC3C;gBACD;oBACE,SAAS,EAAE,iBAAiB;oBAC5B,wBAAwB,EAAE,CAAC,iBAAiB,EAAE,mBAAmB,CAAC;iBACnE;gBACD;oBACE,SAAS,EAAE,qBAAqB;oBAChC,wBAAwB,EAAE,CAAC,qBAAqB,EAAE,mBAAmB,CAAC;iBACvE;gBACD;oBACE,SAAS,EAAE,mBAAmB;oBAC9B,wBAAwB,EAAE,CAAC,mBAAmB,CAAC;iBAChD;gBACD;oBACE,SAAS,EAAE,4BAA4B;oBACvC,uBAAuB,EAAE,CAAC,YAAY,CAAC;iBACxC;gBACD;oBACE,SAAS,EAAE,cAAc;iBAC1B;gBACD;oBACE,SAAS,EAAE,YAAY;iBACxB;gBACD;oBACE,SAAS,EAAE,OAAO;iBACnB;gBACD;oBACE,SAAS,EAAE,OAAO;iBACnB;gBACD;oBACE,SAAS,EAAE,OAAO;iBACnB;gBACD;oBACE,SAAS,EAAE,OAAO;iBACnB;gBACD;oBACE,SAAS,EAAE,aAAa;oBACxB,wBAAwB,EAAE,CAAC,aAAa,CAAC;oBACzC,qBAAqB,EAAE,CAAC,WAAW,CAAC;oBACpC,uBAAuB,EAAE,CAAC,YAAY,CAAC;iBACxC;aACF;YAED,6BAA6B,EAAE,IAAI;YACnC,yBAAyB,EAAE,IAAI;SAChC;KACF;CACF,CAAC","sourcesContent":["import type { Linter } from \"eslint\";\n\nexport const moduleBoundaryRules: Linter.RulesRecord = {\n \"@nx/enforce-module-boundaries\": [\n \"error\",\n {\n allow: [],\n\n depConstraints: [\n {\n sourceTag: \"type:app\",\n onlyDependOnLibsWithTags: [\"type:extension\", \"type:react\", \"type:vanilla\"],\n bannedExternalImports: [\"i18next\", \"react-i18next\"],\n },\n {\n sourceTag: \"type:extension\",\n onlyDependOnLibsWithTags: [\"type:react\", \"type:vanilla\"],\n bannedExternalImports: [\"i18next\", \"react-i18next\"],\n },\n {\n sourceTag: \"type:react\",\n onlyDependOnLibsWithTags: [\"type:react\", \"type:vanilla\"],\n bannedExternalImports: [\"i18next\", \"react-i18next\"],\n },\n {\n sourceTag: \"type:vanilla\",\n onlyDependOnLibsWithTags: [\"type:vanilla\"],\n bannedExternalImports: [\"i18next\", \"react*\"],\n },\n {\n sourceTag: \"scope:app\",\n onlyDependOnLibsWithTags: [\"scope:client\", \"scope:server\"],\n },\n {\n sourceTag: \"scope:client\",\n onlyDependOnLibsWithTags: [\"scope:client\"],\n },\n {\n sourceTag: \"scope:tool\",\n onlyDependOnLibsWithTags: [\"scope:tool\"],\n },\n {\n sourceTag: \"scope:server\",\n onlyDependOnLibsWithTags: [\"scope:server\"],\n },\n {\n sourceTag: \"visibility:host\",\n onlyDependOnLibsWithTags: [\"visibility:host\", \"visibility:shared\"],\n },\n {\n sourceTag: \"visibility:iris-app\",\n onlyDependOnLibsWithTags: [\"visibility:iris-app\", \"visibility:shared\"],\n },\n {\n sourceTag: \"visibility:shared\",\n onlyDependOnLibsWithTags: [\"visibility:shared\"],\n },\n {\n sourceTag: \"dependencies:no-deprecated\",\n notDependOnLibsWithTags: [\"deprecated\"],\n },\n {\n sourceTag: \"gql:internal\",\n },\n {\n sourceTag: \"gql:public\",\n },\n {\n sourceTag: \"tier1\",\n },\n {\n sourceTag: \"tier2\",\n },\n {\n sourceTag: \"tier3\",\n },\n {\n sourceTag: \"tier4\",\n },\n {\n sourceTag: \"publish:npm\",\n onlyDependOnLibsWithTags: [\"publish:npm\"],\n bannedExternalImports: [\"@sentry/*\"],\n notDependOnLibsWithTags: [\"deprecated\"],\n },\n ],\n\n enforceBuildableLibDependency: true,\n banTransitiveDependencies: true,\n },\n ],\n};\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"react-rules.js","sourceRoot":"","sources":["../../../../../../../../libs/eslint/plugin-trackunit/src/lib/config/fragments/react-rules.ts"],"names":[],"mappings":"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","sourcesContent":["import type { Linter } from \"eslint\";\n\nexport const reactRules: Linter.RulesRecord = {\n \"react-hooks/rules-of-hooks\": \"error\",\n \"react-hooks/exhaustive-deps\": \"error\",\n\n \"react-hooks/config\": \"error\",\n \"react-hooks/error-boundaries\": \"error\",\n \"react-hooks/component-hook-factories\": \"error\",\n \"react-hooks/gating\": \"error\",\n \"react-hooks/globals\": \"error\",\n \"react-hooks/set-state-in-render\": \"error\",\n \"react-hooks/use-memo\": \"error\",\n \"react/self-closing-comp\": \"error\",\n \"react-hooks/unsupported-syntax\": \"error\",\n \"react-hooks/static-components\": \"error\",\n \"react-hooks/purity\": \"error\",\n\n \"react-hooks/immutability\": \"warn\",\n \"react/no-unstable-nested-components\": \"warn\",\n \"react-hooks/refs\": \"warn\",\n \"react-hooks/set-state-in-effect\": \"warn\",\n \"react-hooks/preserve-manual-memoization\": \"warn\",\n \"react-hooks/incompatible-library\": \"warn\",\n\n \"react/jsx-curly-brace-presence\": [\n \"error\",\n {\n children: \"never\",\n propElementValues: \"always\",\n props: \"never\",\n },\n ],\n\n \"react/jsx-key\": \"error\",\n \"react/jsx-no-leaked-render\": \"error\",\n \"react/jsx-uses-react\": \"error\",\n \"react/jsx-uses-vars\": \"error\",\n \"react/no-danger\": \"error\",\n \"react/no-unused-prop-types\": \"error\",\n \"react/jsx-sort-props\": \"error\",\n\n \"react/no-children-prop\": [\n \"error\",\n {\n allowFunctions: false,\n },\n ],\n};\n\nexport const reactCustomRules: Linter.RulesRecord = {\n \"@trackunit/no-template-strings-in-classname-prop\": \"error\",\n \"@trackunit/require-classname-alternatives\": [\n \"error\",\n {\n alternatives: {\n slate: [\"neutral\"],\n gray: [\"neutral\"],\n zinc: [\"neutral\"],\n stone: [\"neutral\"],\n teal: [\"cyan\"],\n purple: [\"violet\"],\n fuchsia: [\"pink\"],\n red: [\"danger\"],\n yellow: [\"warning\"],\n green: [\"success\"],\n emerald: [\"success\"],\n amber: [\"warning\", \"low\", \"idle\"],\n sky: [\"primary\", \"info\"],\n blue: [\"primary\", \"info\", \"working\", \"utilized\"],\n indigo: [\"primary\", \"violet\"],\n rose: [\"danger\", \"pink\"],\n },\n prefixes: [\n \"bg\",\n \"text\",\n \"border\",\n \"border-t\",\n \"border-r\",\n \"border-b\",\n \"border-l\",\n \"border-x\",\n \"border-y\",\n \"ring\",\n \"ring-offset\",\n \"outline\",\n \"divide\",\n \"shadow\",\n \"accent\",\n \"caret\",\n \"fill\",\n \"stroke\",\n \"decoration\",\n \"placeholder\",\n \"from\",\n \"via\",\n \"to\",\n ],\n },\n ],\n \"@trackunit/require-list-item-virtualization-props\": \"error\",\n \"@trackunit/cva-merge-base-classes-as-array\": \"error\",\n \"@trackunit/design-guideline-button-icon-size-match\": \"error\",\n \"@trackunit/prefer-destructured-imports\": [\n \"error\",\n {\n packages: {\n react: \"React\",\n },\n },\n ],\n \"@trackunit/require-optional-prop-initialization\": \"error\",\n \"@trackunit/prefer-event-specific-callback-naming\": [\n \"error\",\n {\n events: [\"onClick\", \"onSubmit\", \"onDoubleClick\"],\n },\n ],\n \"@trackunit/prefer-mouse-event-handler-in-react-props\": [\n \"error\",\n {\n allowedNames: [\"onClickClose\"],\n },\n ],\n \"@trackunit/prefer-field-components\": \"error\",\n};\n\nexport const reactTestingLibraryOverrides: Linter.Config = {\n files: [\"**/*.spec.ts\", \"**/*.spec.tsx\"],\n rules: {\n \"jest/no-commented-out-tests\": \"error\",\n \"jest/expect-expect\": \"error\",\n },\n};\n\nexport const reactStoryOverrides: Linter.Config = {\n files: [\"**/*.stories.ts\", \"**/*.stories.tsx\"],\n rules: {\n \"jsdoc/require-jsdoc\": \"off\",\n \"no-console\": \"off\",\n \"@typescript-eslint/no-empty-function\": \"off\",\n },\n};\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"restricted-imports.js","sourceRoot":"","sources":["../../../../../../../../libs/eslint/plugin-trackunit/src/lib/config/fragments/restricted-imports.ts"],"names":[],"mappings":";;;AAEa,QAAA,qBAAqB,GAAuB;IACvD,uBAAuB,EAAE;QACvB,OAAO;QACP;YACE,KAAK,EAAE;gBACL;oBACE,IAAI,EAAE,sBAAsB;oBAC5B,OAAO,EAAE,2DAA2D;iBACrE;gBACD;oBACE,IAAI,EAAE,eAAe;oBACrB,WAAW,EAAE,CAAC,gBAAgB,CAAC;oBAC/B,OAAO,EAAE,gFAAgF;iBAC1F;gBACD;oBACE,IAAI,EAAE,eAAe;oBACrB,WAAW,EAAE,CAAC,OAAO,CAAC;oBACtB,OAAO,EAAE,uEAAuE;iBACjF;gBACD;oBACE,IAAI,EAAE,gBAAgB;oBACtB,WAAW,EAAE,CAAC,UAAU,EAAE,cAAc,CAAC;oBACzC,OAAO,EACL,mHAAmH;iBACtH;gBACD;oBACE,IAAI,EAAE,oBAAoB;oBAC1B,OAAO,EAAE,+EAA+E;iBACzF;gBACD;oBACE,IAAI,EAAE,2BAA2B;oBACjC,OAAO,EAAE,8DAA8D;iBACxE;gBACD;oBACE,IAAI,EAAE,6BAA6B;oBACnC,OAAO,EAAE,8DAA8D;iBACxE;gBACD;oBACE,IAAI,EAAE,0BAA0B;oBAChC,OAAO,EACL,0HAA0H;iBAC7H;aACF;YAED,QAAQ,EAAE;gBACR;oBACE,KAAK,EAAE,CAAC,WAAW,CAAC;oBACpB,OAAO,EAAE,sFAAsF;iBAChG;gBACD;oBACE,KAAK,EAAE,CAAC,cAAc,CAAC;oBACvB,OAAO,EAAE,sFAAsF;iBAChG;aACF;SACF;KACF;CACF,CAAC","sourcesContent":["import type { Linter } from \"eslint\";\n\nexport const restrictedImportRules: Linter.RulesRecord = {\n \"no-restricted-imports\": [\n \"error\",\n {\n paths: [\n {\n name: \"react-dom/test-utils\",\n message: \"Please use 'act' from the @testing-library/react instead.\",\n },\n {\n name: \"react-i18next\",\n importNames: [\"useTranslation\"],\n message: \"Please import useTranslation from @trackunit/i18n-manager-translation instead.\",\n },\n {\n name: \"react-i18next\",\n importNames: [\"Trans\"],\n message: \"Please import Trans from @trackunit/i18n-manager-translation instead.\",\n },\n {\n name: \"@apollo/client\",\n importNames: [\"useQuery\", \"useLazyQuery\"],\n message:\n \"Please import the same from @trackunit/react-graphql-hooks instead, to ensure loading state is handled correctly.\",\n },\n {\n name: \"@nx/plugin/testing\",\n message: \"Please import it from @trackunit/nx-utils instead or expose it from that lib.\",\n },\n {\n name: \"@heroicons/react/20/solid\",\n message: \"Please use the Icon component from react-components instead.\",\n },\n {\n name: \"@heroicons/react/24/outline\",\n message: \"Please use the Icon component from react-components instead.\",\n },\n {\n name: \"class-variance-authority\",\n message:\n \"Import our wrappers from, @trackunit/css-class-variance-utilities or twMerge instead. [cva -> cvaMerge], [cx -> twMerge]\",\n },\n ],\n\n patterns: [\n {\n group: [\"date-fns*\"],\n message: \"Please use @trackunit/date-and-time-utils or @trackunit/date-and-time-hooks instead.\",\n },\n {\n group: [\"date-fns-tz*\"],\n message: \"Please use @trackunit/date-and-time-utils or @trackunit/date-and-time-hooks instead.\",\n },\n ],\n },\n ],\n};\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"testing-library.js","sourceRoot":"","sources":["../../../../../../../../libs/eslint/plugin-trackunit/src/lib/config/fragments/testing-library.ts"],"names":[],"mappings":";;;AACA,wCAA4C;AAE5C,MAAM,WAAW,GAAG,wBAAc,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,IAAI,EAAE,CAAC;AAEhD,QAAA,wBAAwB,GAAuB,MAAM,CAAC,WAAW,CAC5E,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,MAAM,CAAC,CAAC,KAAK,EAAuC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,SAAS,CAAC,CAC3G,CAAC","sourcesContent":["import type { Linter } from \"eslint\";\nimport { testingLibrary } from \"../plugins\";\n\nconst configRules = testingLibrary.configs.react.rules ?? {};\n\nexport const reactTestingLibraryRules: Linter.RulesRecord = Object.fromEntries(\n Object.entries(configRules).filter((entry): entry is [string, Linter.RuleEntry] => entry[1] !== undefined)\n);\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"typescript-rules.js","sourceRoot":"","sources":["../../../../../../../../libs/eslint/plugin-trackunit/src/lib/config/fragments/typescript-rules.ts"],"names":[],"mappings":";;;AAEa,QAAA,eAAe,GAAuB;IACjD,oCAAoC,EAAE,OAAO;IAC7C,wCAAwC,EAAE,OAAO;IACjD,uCAAuC,EAAE,OAAO;IAChD,6CAA6C,EAAE,OAAO;IACtD,gBAAgB,EAAE,KAAK;IACvB,mCAAmC,EAAE;QACnC,MAAM;QACN;YACE,IAAI,EAAE,KAAK;YACX,iBAAiB,EAAE,IAAI;YACvB,YAAY,EAAE,KAAK;YACnB,yBAAyB,EAAE,IAAI;YAC/B,8BAA8B,EAAE,IAAI;YACpC,iBAAiB,EAAE,IAAI;YACvB,kBAAkB,EAAE,IAAI;SACzB;KACF;IACD,+BAA+B,EAAE;QAC/B,OAAO;QACP;YACE,OAAO,EAAE,SAAS;SACnB;KACF;IACD,iCAAiC,EAAE,CAAC,OAAO,EAAE,EAAE,cAAc,EAAE,KAAK,EAAE,CAAC;IACvE,8BAA8B,EAAE;QAC9B,OAAO;QACP;YACE,KAAK,EAAE,KAAK;SACb;KACF;IACD,+CAA+C,EAAE;QAC/C,MAAM;QACN;YACE,oBAAoB,EAAE,IAAI;YAC1B,mBAAmB,EAAE,IAAI;SAC1B;KACF;IACD,sCAAsC,EAAE;QACtC,OAAO;QACP;YACE,QAAQ,EAAE,WAAW;YACrB,MAAM,EAAE,CAAC,YAAY,CAAC;YAEtB,MAAM,EAAE;gBACN,KAAK,EAAE,SAAS;gBAChB,KAAK,EAAE,KAAK;aACb;SACF;QACD;YACE,QAAQ,EAAE,eAAe;YACzB,MAAM,EAAE,CAAC,YAAY,CAAC;YAEtB,MAAM,EAAE;gBACN,KAAK,EAAE,2BAA2B;gBAClC,KAAK,EAAE,IAAI;aACZ;SACF;KACF;IACD,0CAA0C,EAAE,MAAM;IAClD,sCAAsC,EAAE,OAAO;IAC/C,0CAA0C,EAAE,OAAO;IACnD,iCAAiC,EAAE,OAAO;IAC1C,mCAAmC,EAAE,MAAM;IAC3C,mCAAmC,EAAE,MAAM;IAC3C,oCAAoC,EAAE,OAAO;IAC7C,yCAAyC,EAAE,OAAO;IAClD,yCAAyC,EAAE,OAAO;IAClD,kDAAkD,EAAE;QAClD,OAAO;QACP;YACE,aAAa,EAAE,UAAU;YACzB,SAAS,EAAE;gBACT,SAAS,EAAE,UAAU;gBACrB,YAAY,EAAE,UAAU;gBACxB,mBAAmB,EAAE,UAAU;aAChC;SACF;KACF;IACD,kDAAkD,EAAE,OAAO;IAC3D,uCAAuC,EAAE,MAAM;IAC/C,wCAAwC,EAAE;QACxC,OAAO;QACP;YACE,KAAK,EAAE;gBACL,UAAU,EAAE;oBACV,OAAO,EAAE,6CAA6C;iBACvD;gBAED,EAAE,EAAE;oBACF,OAAO,EAAE,6CAA6C;iBACvD;aACF;SACF;KACF;CACF,CAAC","sourcesContent":["import type { Linter } from \"eslint\";\n\nexport const typescriptRules: Linter.RulesRecord = {\n \"@typescript-eslint/no-explicit-any\": \"error\",\n \"@typescript-eslint/no-inferrable-types\": \"error\",\n \"@typescript-eslint/unified-signatures\": \"error\",\n \"@typescript-eslint/no-unnecessary-condition\": \"error\",\n \"no-unused-vars\": \"off\",\n \"@typescript-eslint/no-unused-vars\": [\n \"warn\",\n {\n args: \"all\",\n argsIgnorePattern: \"^_\",\n caughtErrors: \"all\",\n caughtErrorsIgnorePattern: \"^_\",\n destructuredArrayIgnorePattern: \"^_\",\n varsIgnorePattern: \"^_\",\n ignoreRestSiblings: true,\n },\n ],\n \"@typescript-eslint/array-type\": [\n \"error\",\n {\n default: \"generic\",\n },\n ],\n \"@typescript-eslint/no-redeclare\": [\"error\", { builtinGlobals: false }],\n \"@typescript-eslint/no-shadow\": [\n \"error\",\n {\n hoist: \"all\",\n },\n ],\n \"@typescript-eslint/strict-boolean-expressions\": [\n \"warn\",\n {\n allowNullableBoolean: true,\n allowNullableString: true,\n },\n ],\n \"@typescript-eslint/naming-convention\": [\n \"error\",\n {\n selector: \"interface\",\n format: [\"PascalCase\"],\n\n custom: {\n regex: \"^I[A-Z]\",\n match: false,\n },\n },\n {\n selector: \"typeParameter\",\n format: [\"PascalCase\"],\n\n custom: {\n regex: \"^(T|Keys?)[A-Z][a-zA-Z]+$\",\n match: true,\n },\n },\n ],\n \"@typescript-eslint/no-non-null-assertion\": \"warn\",\n \"@typescript-eslint/no-empty-function\": \"error\",\n \"@typescript-eslint/no-unused-expressions\": \"error\",\n \"@typescript-eslint/dot-notation\": \"error\",\n \"@typescript-eslint/await-thenable\": \"warn\",\n \"@typescript-eslint/ban-ts-comment\": \"warn\",\n \"@typescript-eslint/member-ordering\": \"error\",\n \"@typescript-eslint/no-empty-object-type\": \"error\",\n \"@typescript-eslint/no-floating-promises\": \"error\",\n \"@typescript-eslint/explicit-member-accessibility\": [\n \"error\",\n {\n accessibility: \"explicit\",\n overrides: {\n accessors: \"explicit\",\n constructors: \"explicit\",\n parameterProperties: \"explicit\",\n },\n },\n ],\n \"@typescript-eslint/no-unnecessary-type-assertion\": \"error\",\n \"@typescript-eslint/no-require-imports\": \"warn\",\n \"@typescript-eslint/no-restricted-types\": [\n \"error\",\n {\n types: {\n \"React.FC\": {\n message: \"Please use props interface or type instead.\",\n },\n\n FC: {\n message: \"Please use props interface or type instead.\",\n },\n },\n },\n ],\n};\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../libs/eslint/plugin-trackunit/src/lib/config/index.ts"],"names":[],"mappings":";;;AAAA,yCAAsC;AACtC,2CAA8C;AAEjC,QAAA,OAAO,GAAG;IACrB,IAAI,EAAJ,WAAI;IACJ,KAAK,EAAE,mBAAW;CACnB,CAAC","sourcesContent":["import { base } from \"./presets/base\";\nimport { reactPreset } from \"./presets/react\";\n\nexport const configs = {\n base,\n react: reactPreset,\n};\n"]}
|