@trackunit/eslint-plugin-trackunit 0.4.6 → 0.4.8
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 +10 -0
- package/package.json +1 -1
- package/src/lib/config/index.d.ts +21 -21
- package/src/lib/config/plugins.d.ts +7 -7
- package/src/lib/config/presets/base.d.ts +14 -14
- package/src/lib/config/presets/react.d.ts +7 -7
- package/src/lib/rules/no-internal-graphql-when-tagged-with-gql-public/no-internal-graphql-when-tagged-with-gql-public.d.ts +3 -4
- package/src/lib/rules/no-internal-graphql-when-tagged-with-gql-public/no-internal-graphql-when-tagged-with-gql-public.js +60 -57
- package/src/lib/rules/no-jest-mock-trackunit-react-core-hooks/no-jest-mock-trackunit-react-core-hooks.d.ts +4 -2
- package/src/lib/rules/no-jest-mock-trackunit-react-core-hooks/no-jest-mock-trackunit-react-core-hooks.js +6 -2
- package/src/lib/rules/no-typescript-assertion/no-typescript-assertion.d.ts +5 -4
- package/src/lib/rules/no-typescript-assertion/no-typescript-assertion.js +57 -72
- package/src/lib/rules/require-list-item-virtualization-props/require-list-item-virtualization-props.js +1 -1
- package/src/lib/rules-map.d.ts +7 -8
- 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/examples.d.ts +0 -80
- package/src/lib/rules/no-internal-barrel-files/examples.js +0 -84
- package/src/lib/rules/no-internal-barrel-files/examples.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/examples.d.ts +0 -1
- package/src/lib/rules/no-typescript-assertion/examples.js +0 -45
- package/src/lib/rules/no-typescript-assertion/examples.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-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
|
@@ -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;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E,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":";;;AAEa,QAAA,UAAU,GAAuB;IAC5C,4BAA4B,EAAE,OAAO;IACrC,6BAA6B,EAAE,OAAO;IAEtC,oBAAoB,EAAE,OAAO;IAC7B,8BAA8B,EAAE,OAAO;IACvC,sCAAsC,EAAE,OAAO;IAC/C,oBAAoB,EAAE,OAAO;IAC7B,qBAAqB,EAAE,OAAO;IAC9B,iCAAiC,EAAE,OAAO;IAC1C,sBAAsB,EAAE,OAAO;IAC/B,yBAAyB,EAAE,OAAO;IAClC,gCAAgC,EAAE,OAAO;IACzC,+BAA+B,EAAE,OAAO;IACxC,oBAAoB,EAAE,OAAO;IAE7B,0BAA0B,EAAE,MAAM;IAClC,qCAAqC,EAAE,MAAM;IAC7C,kBAAkB,EAAE,MAAM;IAC1B,iCAAiC,EAAE,MAAM;IACzC,yCAAyC,EAAE,MAAM;IACjD,kCAAkC,EAAE,MAAM;IAE1C,gCAAgC,EAAE;QAChC,OAAO;QACP;YACE,QAAQ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,UAAU;gBACV,UAAU;gBACV,UAAU;gBACV,UAAU;gBACV,UAAU;gBACV,MAAM;gBACN,aAAa;gBACb,SAAS;gBACT,QAAQ;gBACR,QAAQ;gBACR,QAAQ;gBACR,OAAO;gBACP,MAAM;gBACN,QAAQ;gBACR,YAAY;gBACZ,aAAa;gBACb,MAAM;gBACN,KAAK;gBACL,IAAI;aACL;SACF;KACF;IACD,mDAAmD,EAAE,OAAO;IAC5D,4CAA4C,EAAE,OAAO;IACrD,oDAAoD,EAAE,OAAO;IAC7D,wCAAwC,EAAE;QACxC,OAAO;QACP;YACE,QAAQ,EAAE;gBACR,KAAK,EAAE,OAAO;aACf;SACF;KACF;IACD,iDAAiD,EAAE,MAAM;IACzD,kDAAkD,EAAE;QAClD,OAAO;QACP;YACE,MAAM,EAAE,CAAC,SAAS,EAAE,UAAU,EAAE,eAAe,CAAC;SACjD;KACF;IACD,sDAAsD,EAAE;QACtD,OAAO;QACP;YACE,YAAY,EAAE,CAAC,cAAc,CAAC;SAC/B;KACF;IACD,oCAAoC,EAAE,OAAO;CAC9C,CAAC;AAEW,QAAA,4BAA4B,GAAkB;IACzD,KAAK,EAAE,CAAC,cAAc,EAAE,eAAe,CAAC;IACxC,KAAK,EAAE;QACL,6BAA6B,EAAE,OAAO;QACtC,oBAAoB,EAAE,OAAO;KAC9B;CACF,CAAC;AAEW,QAAA,mBAAmB,GAAkB;IAChD,KAAK,EAAE,CAAC,iBAAiB,EAAE,kBAAkB,CAAC;IAC9C,KAAK,EAAE;QACL,qBAAqB,EAAE,KAAK;QAC5B,YAAY,EAAE,KAAK;QACnB,sCAAsC,EAAE,KAAK;KAC9C;CACF,CAAC","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\": \"warn\",\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,QAA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AAO;IAClD,yCAAyC,EAAE,MAAM;IACjD,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\": \"warn\",\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\": \"warn\",\n \"@typescript-eslint/no-empty-object-type\": \"error\",\n \"@typescript-eslint/no-floating-promises\": \"warn\",\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"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"plugins.js","sourceRoot":"","sources":["../../../../../../../libs/eslint/plugin-trackunit/src/lib/config/plugins.ts"],"names":[],"mappings":";;;;AAAA;;;;;;;;GAQG;AACH,8DAAwC;AAwBtC,gBAAE;AAvBJ,2FAAqE;AA4BnE,4CAAgB;AA3BlB,4EAAsD;AA0BpD,4BAAQ;AAzBV,+EAA+D;AAc7D,+BAdK,cAAoB,CAcL;AAbtB,2EAAqD;AAenD,oCAAY;AAdd,iEAA2C;AAezC,oBAAI;AAdN,mEAA6C;AAe3C,sBAAK;AAdP,sEAAgD;AAgB9C,wBAAM;AAfR,mEAA6C;AAiB3C,sBAAK;AAhBP,8EAAwD;AAiBtD,gCAAU;AAhBZ,sFAAgE;AAiB9D,wCAAc;AAhBhB,yDAAmC;AAOjC,0BAAO;AANT,yEAAmD;AAUjD,kCAAW;AATb,4CAAwC;AAE3B,QAAA,gBAAgB,GAAG,EAAE,KAAK,EAAE,oBAAQ,EAAE,CAAC","sourcesContent":["/**\n * Shared plugin instances for ESLint flat config.\n *\n * ESLint flat config requires that the same plugin name always maps to the same\n * object reference. With TypeScript's __importStar() helper (from esModuleInterop),\n * each file that does `import * as foo from \"pkg\"` gets its own wrapper object.\n * By importing all plugins once here and re-exporting, all presets share the same\n * object references.\n */\nimport * as nx from \"@nx/eslint-plugin\";\nimport * as typescriptEslint from \"@typescript-eslint/eslint-plugin\";\nimport * as tsParser from \"@typescript-eslint/parser\";\nimport eslintConfigPrettier from \"eslint-config-prettier/flat\";\nimport * as importPlugin from \"eslint-plugin-import\";\nimport * as jest from \"eslint-plugin-jest\";\nimport * as jsdoc from \"eslint-plugin-jsdoc\";\nimport * as noNull from \"eslint-plugin-no-null\";\nimport * as react from \"eslint-plugin-react\";\nimport * as reactHooks from \"eslint-plugin-react-hooks\";\nimport * as testingLibrary from \"eslint-plugin-testing-library\";\nimport * as globals from \"globals\";\nimport * as jsoncParser from \"jsonc-eslint-parser\";\nimport { rulesMap } from \"../rules-map\";\n\nexport const localRulesPlugin = { rules: rulesMap };\nexport {\n eslintConfigPrettier,\n globals,\n importPlugin,\n jest,\n jsdoc,\n jsoncParser,\n noNull,\n nx,\n react,\n reactHooks,\n testingLibrary,\n tsParser,\n typescriptEslint,\n};\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"base.js","sourceRoot":"","sources":["../../../../../../../../libs/eslint/plugin-trackunit/src/lib/config/presets/base.ts"],"names":[],"mappings":";;;AAAA,4EAAuE;AAEvE,kDAAqD;AACrD,4DAAwD;AACxD,gEAAgE;AAChE,0DAA2D;AAC3D,sEAAqE;AACrE,wEAAwE;AACxE,oEAAgE;AAChE,wCAUoB;AACpB,oCAA4C;AAE/B,QAAA,IAAI,GAAG;IAClB,uBAAa;IACb;QACE,OAAO,EAAE;YACP,KAAK,EAAE,YAAE;YACT,YAAY,EAAE,0BAAgB;YAC9B,oBAAoB,EAAE,0BAAgB;YACtC,SAAS,EAAE,gBAAM;YACjB,UAAU,EAAE,sBAAY;YACxB,KAAK,EAAL,eAAK;SACN;QAED,KAAK,EAAE;YACL,GAAG,uCAAmB;YACtB,GAAG,0CAAqB;SACzB;KACF;IACD,IAAA,iCAAc,EAAC;QACb,IAAI,EAAE,EAAE,IAAI,EAAE,CAAC,YAAY,CAAC,EAAE;QAC9B,OAAO,EAAE;YACP,UAAU,EAAE,sBAAY;SACzB;QACD,KAAK,EAAE;YACL,qCAAqC,EAAE;gBACrC,OAAO;gBACP;oBACE,UAAU,EAAE,IAAA,wBAAgB,GAAE;oBAC9B,eAAe,EAAE;wBACf,kBAAkB;wBAClB,eAAe;wBACf,oBAAoB;wBACpB,oBAAoB;wBACpB,iBAAiB;wBACjB,YAAY;wBACZ,aAAa;wBACb,eAAe;wBACf,kBAAkB;wBAClB,kBAAkB;wBAClB,iBAAiB;wBACjB,iBAAiB;wBACjB,mBAAmB;wBACnB,0BAA0B;wBAC1B,uBAAuB;wBACvB,4BAA4B;wBAC5B,kBAAkB;wBAClB,eAAe;wBACf,aAAa;wBACb,6BAA6B;wBAC7B,oBAAoB;wBACpB,6CAA6C;wBAC7C,4BAA4B;qBAC7B;oBACD,oBAAoB,EAAE,KAAK;oBAC3B,gBAAgB,EA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B;QACE,KAAK,EAAE;YACL,sBAAsB;YACtB,yBAAyB;YACzB,qBAAqB;YACrB,qBAAqB;YACrB,sBAAsB;SACvB;QACD,KAAK,EAAE;YACL,uCAAuC,EAAE,KAAK;SAC/C;KACF;IACD,8BAAoB;IACpB;QACE,KAAK,EAAE,CAAC,8BAA8B,EAAE,2BAA2B,CAAC;QACpE,KAAK,EAAE;YACL,+BAA+B,EAAE,KAAK;SACvC;KACF;CACF,CAAC","sourcesContent":["import { createSkipWhen } from \"../../config-helpers/create-skip-when\";\n\nimport { globalIgnores } from \"../fragments/ignores\";\nimport { importRules } from \"../fragments/import-rules\";\nimport { baseJestOverrides } from \"../fragments/jest-overrides\";\nimport { basicJsdocRules } from \"../fragments/jsdoc-rules\";\nimport { moduleBoundaryRules } from \"../fragments/module-boundaries\";\nimport { restrictedImportRules } from \"../fragments/restricted-imports\";\nimport { typescriptRules } from \"../fragments/typescript-rules\";\nimport {\n eslintConfigPrettier,\n importPlugin,\n jsdoc,\n jsoncParser,\n localRulesPlugin,\n noNull,\n nx,\n tsParser,\n typescriptEslint,\n} from \"../plugins\";\nimport { findMonorepoRoot } from \"../utils\";\n\nexport const base = [\n globalIgnores,\n {\n plugins: {\n \"@nx\": nx,\n \"@trackunit\": localRulesPlugin,\n \"@typescript-eslint\": typescriptEslint,\n \"no-null\": noNull,\n \"import-x\": importPlugin,\n jsdoc,\n },\n\n rules: {\n ...moduleBoundaryRules,\n ...restrictedImportRules,\n },\n },\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: findMonorepoRoot(),\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 {\n files: [\"**/*.ts\", \"**/*.tsx\", \"**/*.js\", \"**/*.jsx\"],\n\n languageOptions: {\n ecmaVersion: 5,\n sourceType: \"script\",\n parser: tsParser,\n parserOptions: {\n project: [\"./tsconfig.*?.json\"],\n },\n },\n rules: {\n \"constructor-super\": \"error\",\n curly: \"error\",\n \"default-case\": \"error\",\n \"id-match\": \"error\",\n \"no-caller\": \"error\",\n \"no-debugger\": \"error\",\n \"no-duplicate-imports\": \"error\",\n \"no-empty\": \"error\",\n \"no-eval\": \"error\",\n \"no-console\": \"error\",\n \"no-var\": \"error\",\n \"prefer-const\": \"error\",\n \"no-template-curly-in-string\": \"error\",\n eqeqeq: [\"error\", \"always\"],\n \"no-undef-init\": \"error\",\n \"no-invalid-this\": \"off\",\n \"no-null/no-null\": \"off\",\n \"no-underscore-dangle\": \"off\",\n \"no-redeclare\": \"off\",\n \"no-empty-function\": \"off\",\n \"no-unused-expressions\": \"off\",\n \"no-shadow\": \"off\",\n\n ...basicJsdocRules,\n\n \"@trackunit/no-internal-barrel-files\": \"error\",\n \"@trackunit/no-typescript-assertion\": \"warn\",\n\n ...importRules,\n\n ...typescriptRules,\n },\n },\n {\n files: [\"**/project.json\"],\n languageOptions: {\n parser: jsoncParser,\n },\n plugins: {\n \"@trackunit\": localRulesPlugin,\n },\n rules: {\n \"@trackunit/no-internal-graphql-when-tagged-with-gql-public\": \"error\",\n },\n },\n baseJestOverrides,\n {\n files: [\n \"**/eslint.config.cjs\",\n \"**/iris-app-manifest.ts\",\n \"**/rspack.config.ts\",\n \"**/rspack.config.js\",\n \"**/webpack.config.ts\",\n ],\n rules: {\n \"@typescript-eslint/no-require-imports\": \"off\",\n },\n },\n eslintConfigPrettier,\n {\n files: [\"**/*.stories.{ts,tsx,js,jsx}\", \"**/*.demo.{ts,tsx,js,jsx}\"],\n rules: {\n \"@nx/enforce-module-boundaries\": \"off\",\n },\n },\n];\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"e2e.js","sourceRoot":"","sources":["../../../../../../../../libs/eslint/plugin-trackunit/src/lib/config/presets/e2e.ts"],"names":[],"mappings":";;;;AAAA,4EAAsD;AAEzC,QAAA,GAAG,GAAG;IACjB,OAAO,CAAC,OAAO,CAAC,WAAW;IAC3B;QACE,KAAK,EAAE,CAAC,SAAS,EAAE,UAAU,EAAE,SAAS,EAAE,UAAU,CAAC;QAErD,eAAe,EAAE;YACf,WAAW,EAAE,CAAC;YACd,UAAU,EAAE,QAAQ;YAEpB,aAAa,EAAE;gBACb,OAAO,EAAE,CAAC,oBAAoB,EAAE,iBAAiB,EAAE,yBAAyB,CAAC;aAC9E;SACF;KACF;CACF,CAAC","sourcesContent":["import * as cypress from \"eslint-plugin-cypress/flat\";\n\nexport const e2e = [\n cypress.configs.recommended,\n {\n files: [\"**/*.ts\", \"**/*.tsx\", \"**/*.js\", \"**/*.jsx\"],\n\n languageOptions: {\n ecmaVersion: 5,\n sourceType: \"script\",\n\n parserOptions: {\n project: [\"./tsconfig.*?.json\", \"./tsconfig.json\", \"./cypress/tsconfig.json\"],\n },\n },\n },\n];\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"react.js","sourceRoot":"","sources":["../../../../../../../../libs/eslint/plugin-trackunit/src/lib/config/presets/react.ts"],"names":[],"mappings":";;;AAAA,0DAAwE;AACxE,kEAAwE;AACxE,wCAWoB;AAEP,QAAA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,eAAe,CAAC;QAExC,OAAO,EAAE;YACP,IAAI,EAAJ,cAAI;YACJ,iBAAiB,EAAE,wBAAc;SAClC;QACD,eAAe,EAAE;YACf,OAAO,EAAE;gBACP,GAAG,iBAAO,CAAC,OAAO;gBAClB,GAAG,cAAI,CAAC,YAAY,CAAC,OAAO,CAAC,OAAO;gBACpC,GAAG,iBAAO,CAAC,IAAI;gBACf,IAAI,EAAE,UAAU;gBAChB,MAAM,EAAE,UAAU;aACnB;YAED,MAAM,EAAE,kBAAQ;SACjB;QAED,KAAK,EAAE;YACL,GAAG,cAAI,CAAC,OAAO,CAAC,WAAW,CAAC,KAAK;YACjC,GAAG,cAAI,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK;YAC3B,GAAG,0CAAwB;YAC3B,6BAA6B,EAAE,OAAO;YACtC,oBAAoB,EAAE,OAAO;SAC9B;KACF;CACF,CAAC","sourcesContent":["import { reactCustomRules, reactRules } from \"../fragments/react-rules\";\nimport { reactTestingLibraryRules } from \"../fragments/testing-library\";\nimport {\n globals,\n jest,\n jsdoc,\n localRulesPlugin,\n nx,\n react,\n reactHooks,\n testingLibrary,\n tsParser,\n typescriptEslint,\n} from \"../plugins\";\n\nexport const reactPreset = [\n {\n plugins: {\n \"@trackunit\": localRulesPlugin,\n \"@typescript-eslint\": typescriptEslint,\n jsdoc,\n react,\n \"react-hooks\": reactHooks,\n \"testing-library\": testingLibrary,\n \"@nx\": nx,\n },\n\n settings: {\n react: {\n version: \"detect\",\n },\n },\n languageOptions: {\n globals: {\n ...globals.browser,\n ...jest.environments.globals.globals,\n ...globals.node,\n Text: \"writable\",\n screen: \"writable\",\n },\n parser: tsParser,\n ecmaVersion: 2022,\n sourceType: \"commonjs\",\n parserOptions: {\n ecmaFeatures: {\n jsx: true,\n },\n },\n },\n },\n {\n files: [\"**/*.ts\", \"**/*.tsx\", \"**/*.js\", \"**/*.jsx\"],\n rules: {\n ...reactCustomRules,\n\n \"no-multiple-empty-lines\": [\n \"error\",\n {\n max: 1,\n },\n ],\n\n \"no-unreachable\": \"error\",\n \"prefer-spread\": \"error\",\n\n ...reactRules,\n\n \"no-restricted-syntax\": [\n \"warn\",\n {\n selector: \"TSEnumDeclaration\",\n message: \"Please use string literal union or objects instead of enums.\",\n },\n ],\n },\n },\n {\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 {\n files: [\"**/*.spec.ts\", \"**/*.spec.tsx\"],\n\n plugins: {\n jest,\n \"testing-library\": testingLibrary,\n },\n languageOptions: {\n globals: {\n ...globals.browser,\n ...jest.environments.globals.globals,\n ...globals.node,\n Text: \"writable\",\n screen: \"writable\",\n },\n\n parser: tsParser,\n },\n\n rules: {\n ...jest.configs.recommended.rules,\n ...jest.configs.style.rules,\n ...reactTestingLibraryRules,\n \"jest/no-commented-out-tests\": \"error\",\n \"jest/expect-expect\": \"error\",\n },\n },\n];\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../../../../../../../libs/eslint/plugin-trackunit/src/lib/config/presets/server.ts"],"names":[],"mappings":";;;;AAAA,2CAAkD;AAClD,gFAA0D;AAE1D,wCAAsD;AAEzC,QAAA,MAAM,GAAG;IACpB;QACE,eAAe,EAAE;YACf,OAAO,EAAE;gBACP,GAAG,iBAAO,CAAC,OAAO;aACnB;YAED,MAAM,EAAE,kBAAQ;SACjB;KACF;IACD;QACE,KAAK,EAAE,CAAC,SAAS,EAAE,SAAS,CAAC;QAC7B,OAAO,EAAE;YACP,KAAK,EAAL,eAAK;YACL,cAAc,EAAE,IAAA,yBAAgB,EAAC,WAAW,CAAC;SAC9C;QACD,eAAe,EAAE;YACf,aAAa,EAAE;gBACb,OAAO,EAAE,CAAC,oBAAoB,CAAC;aAChC;SACF;QAED,KAAK,EAAE;YACL,GAAG,WAAW,CAAC,OAAO,CAAC,WAAW,CAAC,KAAK;YACxC,qCAAqC,EAAE,CAAC,OAAO,EAAE,KAAK,CAAC;YACvD,2CAA2C,EAAE,KAAK;YAClD,wCAAwC,EAAE,OAAO;YACjD,0CAA0C,EAAE,KAAK;SAClD;KACF;CACF,CAAC","sourcesContent":["import { fixupPluginRules } from \"@eslint/compat\";\nimport * as typeGraphql from \"eslint-plugin-type-graphql\";\n\nimport { globals, jsdoc, tsParser } from \"../plugins\";\n\nexport const server = [\n {\n languageOptions: {\n globals: {\n ...globals.browser,\n },\n\n parser: tsParser,\n },\n },\n {\n files: [\"**/*.ts\", \"**/*.js\"],\n plugins: {\n jsdoc,\n \"type-graphql\": fixupPluginRules(typeGraphql),\n },\n languageOptions: {\n parserOptions: {\n project: [\"./tsconfig.*?.json\"],\n },\n },\n\n rules: {\n ...typeGraphql.configs.recommended.rules,\n \"type-graphql/missing-decorator-type\": [\"error\", \"all\"],\n \"type-graphql/invalid-nullable-output-type\": \"off\",\n \"type-graphql/wrong-decorator-signature\": \"error\",\n \"type-graphql/invalid-nullable-input-type\": \"off\",\n },\n },\n];\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../../../../libs/eslint/plugin-trackunit/src/lib/config/utils.ts"],"names":[],"mappings":";;AAUA,4CAcC;;AAxBD,+CAAyB;AACzB,mDAA6B;AAE7B,IAAI,UAA8B,CAAC;AAEnC;;;;GAIG;AACH,SAAgB,gBAAgB;IAC9B,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;QAC7B,OAAO,UAAU,CAAC;IACpB,CAAC;IACD,IAAI,GAAG,GAAG,SAAS,CAAC;IACpB,OAAO,GAAG,KAAK,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;QACjC,IAAI,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC,EAAE,CAAC;YAC7C,UAAU,GAAG,GAAG,CAAC;YACjB,OAAO,GAAG,CAAC;QACb,CAAC;QACD,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IAC1B,CAAC;IACD,UAAU,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;IAC3B,OAAO,UAAU,CAAC;AACpB,CAAC","sourcesContent":["import * as fs from \"fs\";\nimport * as path from \"path\";\n\nlet cachedRoot: string | undefined;\n\n/**\n * Finds the monorepo root by walking up from the config package directory\n * until a directory containing nx.json is found.\n * Falls back to process.cwd() if no nx.json is found.\n */\nexport function findMonorepoRoot(): string {\n if (cachedRoot !== undefined) {\n return cachedRoot;\n }\n let dir = __dirname;\n while (dir !== path.dirname(dir)) {\n if (fs.existsSync(path.join(dir, \"nx.json\"))) {\n cachedRoot = dir;\n return dir;\n }\n dir = path.dirname(dir);\n }\n cachedRoot = process.cwd();\n return cachedRoot;\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"create-skip-when.js","sourceRoot":"","sources":["../../../../../../../libs/eslint/plugin-trackunit/src/lib/config-helpers/create-skip-when.ts"],"names":[],"mappings":";;;AAqBA,gDAAmG;AAUnG,IAAI,eAAe,GAAG,CAAC,CAAC;AAExB;;GAEG;AACI,MAAM,cAAc,GAAG,CAAC,OAA8B,EAAqB,EAAE;IAClF,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC;IAEzC,8CAA8C;IAC9C,MAAM,UAAU,GAAG,aAAa,eAAe,EAAE,EAAE,CAAC;IAEpD,4CAA4C;IAC5C,MAAM,YAAY,GAAoC,EAAE,CAAC;IAEzD,KAAK,MAAM,CAAC,kBAAkB,EAAE,MAAM,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;QACnE,KAAK,MAAM,CAAC,QAAQ,EAAE,YAAY,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;YACpE,MAAM,YAAY,GAAG,GAAG,kBAAkB,IAAI,QAAQ,EAAE,CAAC;YAEzD,sCAAsC;YACtC,YAAY,CAAC,YAAY,CAAC,GAAG;gBAC3B,IAAI,EAAE,YAAY,CAAC,IAAI;gBACvB,MAAM,CAAC,OAAyB;oBAC9B,gEAAgE;oBAChE,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC;oBAC3D,MAAM,QAAQ,GAAG,IAAA,6BAAkB,EAAC,QAAQ,CAAC,CAAC;oBAE9C,6CAA6C;oBAC7C,IAAI,QAAQ,IAAI,IAAA,iCAAsB,EAAC,QAAQ,EAAE,IAAI,CAAC,EAAE,CAAC;wBACvD,0CAA0C;wBAC1C,OAAO,EAAE,CAAC;oBACZ,CAAC;oBAED,2CAA2C;oBAC3C,OAAO,YAAY,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;gBACtC,CAAC;aACF,CAAC;QACJ,CAAC;IACH,CAAC;IAED,yBAAyB;IACzB,MAAM,WAAW,GAAuB,EAAE,CAAC;IAE3C,KAAK,MAAM,CAAC,QAAQ,EAAE,UAAU,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QAC3D,4BAA4B;QAC5B,WAAW,CAAC,QAAQ,CAAC,GAAG,KAAK,CAAC;QAE9B,6BAA6B;QAC7B,WAAW,CAAC,GAAG,UAAU,IAAI,QAAQ,EAAE,CAAC,GAAG,UAAU,CAAC;IACxD,CAAC;IAED,OAAO;QACL,OAAO,EAAE;YACP,CAAC,UAAU,CAAC,EAAE;gBACZ,KAAK,EAAE,YAAY;aACpB;SACF;QACD,KAAK,EAAE,WAAW;KACnB,CAAC;AACJ,CAAC,CAAC;AArDW,QAAA,cAAc,kBAqDzB","sourcesContent":["/**\n * Helper to create ESLint config that wraps rules with skip-when-lib-has-tag-tool logic.\n *\n * This provides a cleaner API than manually using the skip-when-lib-has-tag-tool/ prefix.\n *\n * @example\n * createSkipWhen({\n * when: { tags: ['scope:tool'] },\n * plugins: {\n * 'import-x': importXPlugin,\n * },\n * rules: {\n * 'import-x/no-extraneous-dependencies': [\"error\", { ... }],\n * }\n * })\n *\n * Returns a config object with:\n * - A unique plugin containing the wrapped rules for this specific config\n * - Rules configured to use the wrapped versions\n */\nimport type { Linter, Rule } from \"eslint\";\nimport { getProjectMetadata, projectMatchesCriteria, type MatchCriteria } from \"../utils/nx-utils\";\n\ntype PluginMap = Record<string, { rules: Record<string, Rule.RuleModule> }>;\n\ntype CreateSkipWhenOptions = {\n when: MatchCriteria;\n plugins: PluginMap;\n rules: Linter.RulesRecord;\n};\n\nlet skipWhenCounter = 0;\n\n/**\n * Creates an ESLint config that wraps rules to skip enforcement based on NX project criteria.\n */\nexport const createSkipWhen = (options: CreateSkipWhenOptions): Linter.FlatConfig => {\n const { when, plugins, rules } = options;\n\n // Create a unique plugin name for this config\n const pluginName = `skip-when-${skipWhenCounter++}`;\n\n // Build wrapped rules from provided plugins\n const wrappedRules: Record<string, Rule.RuleModule> = {};\n\n for (const [originalPluginName, plugin] of Object.entries(plugins)) {\n for (const [ruleName, originalRule] of Object.entries(plugin.rules)) {\n const fullRuleName = `${originalPluginName}/${ruleName}`;\n\n // Create wrapped version of this rule\n wrappedRules[fullRuleName] = {\n meta: originalRule.meta,\n create(context: Rule.RuleContext) {\n // Check if this file belongs to a project matching the criteria\n const filename = context.filename || context.getFilename();\n const metadata = getProjectMetadata(filename);\n\n // Check if project matches the skip criteria\n if (metadata && projectMatchesCriteria(metadata, when)) {\n // Skip enforcement - return empty visitor\n return {};\n }\n\n // Otherwise, delegate to the original rule\n return originalRule.create(context);\n },\n };\n }\n }\n\n // Build the rules config\n const rulesConfig: Linter.RulesRecord = {};\n\n for (const [ruleName, ruleConfig] of Object.entries(rules)) {\n // Disable the original rule\n rulesConfig[ruleName] = \"off\";\n\n // Enable our wrapped version\n rulesConfig[`${pluginName}/${ruleName}`] = ruleConfig;\n }\n\n return {\n plugins: {\n [pluginName]: {\n rules: wrappedRules,\n },\n },\n rules: rulesConfig,\n };\n};\n"]}
|
package/src/lib/rules/cva-merge-base-classes-as-array/cva-merge-base-classes-as-array.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cva-merge-base-classes-as-array.js","sourceRoot":"","sources":["../../../../../../../../libs/eslint/plugin-trackunit/src/lib/rules/cva-merge-base-classes-as-array/cva-merge-base-classes-as-array.ts"],"names":[],"mappings":";;;AAAA,oDAAiF;AACjF,iEAAyF;AAEzF,MAAM,UAAU,GAAG,mBAAW,CAAC,WAAW,CACxC,IAAI,CAAC,EAAE,CAAC,6FAA6F,IAAI,KAAK,CAC/G,CAAC;AAKF;;;;;;;;;GASG;AACU,QAAA,0BAA0B,GAAG,UAAU,CAAsB;IACxE,IAAI,EAAE,iCAAiC;IACvC,IAAI,EAAE;QACJ,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE;YACJ,WAAW,EAAE,wEAAwE;SACtF;QACD,OAAO,EAAE,MAAM;QACf,QAAQ,EAAE;YACR,gBAAgB,EAAE,4FAA4F;YAC9G,eAAe,EAAE,sDAAsD;SACxE;QACD,MAAM,EAAE,EAAE;KACX;IACD,cAAc,EAAE,EAAE;IAClB,MAAM,CAAC,OAAO;QACZ,OAAO;YACL,cAAc,CAAC,IAA6B;gBAC1C,MAAM,UAAU,GAAG,IAAA,+BAAa,EAAC,IAAI,CAAC,MAAM,CAAC,CAAC;gBAE9C,IAAI,UAAU,KAAK,UAAU,IAAI,IAAI,CAAC,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;oBAC7D,OAAO;gBACT,CAAC;gBAED,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;gBACnC,IAAI,CAAC,QAAQ,EAAE,CAAC;oBACd,OAAO;gBACT,CAAC;gBAED,mDAAmD;gBACnD,IAAI,QAAQ,CAAC,IAAI,KA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AC,KAAK,CAAC,CAAC,CAAC;oCAClD,CAAC;gCACH,CAAC;gCACD,OAAO,KAAK,CAAC,WAAW,CAAC,QAAQ,EAAE,IAAA,+BAAa,EAAC,UAAU,CAAC,CAAC,CAAC;4BAChE,CAAC;yBACF,CAAC,CAAC;oBACL,CAAC;gBACH,CAAC;YACH,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC","sourcesContent":["import { AST_NODE_TYPES, ESLintUtils, TSESTree } from \"@typescript-eslint/utils\";\nimport { formatAsArray, getCalleeName, splitClasses } from \"../../utils/classname-utils\";\n\nconst createRule = ESLintUtils.RuleCreator(\n name => `https://github.com/trackunit/manager/blob/main/libs/eslint/plugin-trackunit/src/lib/rules/${name}.ts`\n);\n\ntype MessageIds = \"stringNeedsArray\" | \"arrayNeedsSplit\";\ntype Options = [];\n\n/**\n * ESLint rule that converts cvaMerge base styles to arrays if more than one class is used.\n *\n * @example\n * Invalid:\n * const cvaMyComponent = cvaMerge(\"text-danger-600 mb-4 font-semibold\");\n * const cvaMyComponent = cvaMerge([\"text-danger-600 mb-4\",\"font-semibold\"]);\n * Valid:\n * const cvaMyComponent = cvaMerge([\"text-danger-600\", \"mb-4\", \"font-semibold\"]);\n */\nexport const cvaMergeBaseClassesAsArray = createRule<Options, MessageIds>({\n name: \"cva-merge-base-classes-as-array\",\n meta: {\n type: \"layout\",\n docs: {\n description: \"Convert cvaMerge base styles to arrays if more than one class is used.\",\n },\n fixable: \"code\",\n messages: {\n stringNeedsArray: \"[cvaMerge] The first argument of cvaMerge should be an array if multiple classes are used.\",\n arrayNeedsSplit: \"[cvaMerge] Only one class per array item is allowed.\",\n },\n schema: [],\n },\n defaultOptions: [],\n create(context) {\n return {\n CallExpression(node: TSESTree.CallExpression) {\n const calleeName = getCalleeName(node.callee);\n\n if (calleeName !== \"cvaMerge\" || node.arguments.length === 0) {\n return;\n }\n\n const firstArg = node.arguments[0];\n if (!firstArg) {\n return;\n }\n\n // Handle string literal: cvaMerge(\"class1 class2\")\n if (firstArg.type === AST_NODE_TYPES.Literal && typeof firstArg.value === \"string\") {\n const value = firstArg.value;\n if (value.includes(\" \")) {\n context.report({\n node,\n messageId: \"stringNeedsArray\",\n fix(fixer) {\n return fixer.replaceText(firstArg, formatAsArray(splitClasses(value)));\n },\n });\n }\n return;\n }\n\n // Handle array: cvaMerge([\"class1 class2\", \"class3\"])\n if (firstArg.type === AST_NODE_TYPES.ArrayExpression) {\n const hasMultiClassElement = firstArg.elements.some(\n element =>\n element?.type === AST_NODE_TYPES.Literal &&\n typeof element.value === \"string\" &&\n element.value.includes(\" \")\n );\n\n if (hasMultiClassElement) {\n context.report({\n node,\n messageId: \"arrayNeedsSplit\",\n fix(fixer) {\n // Extract all string values and split them into individual classes\n const allClasses: Array<string> = [];\n for (const element of firstArg.elements) {\n if (element?.type === AST_NODE_TYPES.Literal && typeof element.value === \"string\") {\n allClasses.push(...splitClasses(element.value));\n }\n }\n return fixer.replaceText(firstArg, formatAsArray(allClasses));\n },\n });\n }\n }\n },\n };\n },\n});\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"design-guideline-button-icon-size-match.js","sourceRoot":"","sources":["../../../../../../../../libs/eslint/plugin-trackunit/src/lib/rules/design-guideline-button-icon-size-match/design-guideline-button-icon-size-match.ts"],"names":[],"mappings":";;;;AAAA,oDAAqF;AACrF,uDAAiC;AAEjC,MAAM,UAAU,GAAG,mBAAW,CAAC,WAAW,CACxC,IAAI,CAAC,EAAE,CAAC,0FAA0F,IAAI,KAAK,CAC5G,CAAC;AAEF,sEAAsE;AACtE,SAAS,yBAAyB,CAChC,OAA6D,EAC7D,UAA+B;IAE/B,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,mBAAW,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC;QACxD,MAAM,OAAO,GAAG,QAAQ,CAAC,OAAO,CAAC,cAAc,EAAE,CAAC;QAClD,MAAM,MAAM,GAAG,QAAQ,CAAC,qBA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AQ,EAAE,CAAC;gDACb,OAAO,KAAK,CAAC,eAAe,CAAC,QAAQ,EAAE,SAAS,eAAe,EAAE,CAAC,CAAC;4CACrE,CAAC;iDAAM,CAAC;gDACN,OAAO,KAAK,CAAC,eAAe,CAAC,WAAW,CAAC,IAAI,EAAE,SAAS,eAAe,EAAE,CAAC,CAAC;4CAC7E,CAAC;wCACH,CAAC;oCACH,CAAC;iCACF,CAAC,CAAC;4BACL,CAAC;wBACH,CAAC;oBACH,CAAC,CAAC,CAAC;gBACL,CAAC;YACH,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC","sourcesContent":["import { ESLintUtils, type TSESLint, type TSESTree } from \"@typescript-eslint/utils\";\nimport * as ts from \"typescript\";\n\nconst createRule = ESLintUtils.RuleCreator(\n name => `https://github.com/trackunit/manager/blob/main/libs/eslint/plugin-trackunit/docs/rules/${name}.md`\n);\n\n// Helper to get possible string literal values from a variable's type\nfunction getPossibleStringLiterals(\n context: TSESLint.RuleContext<string, ReadonlyArray<unknown>>,\n identifier: TSESTree.Identifier\n): Array<string> | null {\n try {\n const services = ESLintUtils.getParserServices(context);\n const checker = services.program.getTypeChecker();\n const tsNode = services.esTreeNodeToTSNodeMap.get(identifier);\n const type = checker.getTypeAtLocation(tsNode);\n\n const literalValues: Array<string> = [];\n\n // Type guard for string literal types\n const isStringLiteralType = (t: ts.Type): t is ts.Type & { value: string } => {\n if ((t.flags & ts.TypeFlags.StringLiteral) === 0) {\n return false;\n }\n // Check if the type has a value property and it's a string\n // eslint-disable-next-line @trackunit/no-typescript-assertion\n const typeWithValue = t as { value?: unknown };\n return \"value\" in typeWithValue && typeof typeWithValue.value === \"string\";\n };\n\n if (type.isUnion()) {\n for (const unionType of type.types) {\n if (isStringLiteralType(unionType)) {\n literalValues.push(unionType.value);\n }\n }\n } else if (isStringLiteralType(type)) {\n literalValues.push(type.value);\n }\n\n return literalValues.length > 0 ? literalValues : null;\n } catch {\n return null;\n }\n}\n\n// Helper to check if a conditional expression matches the expected button-icon size pattern\nfunction isCorrectConditionalExpression(expression: TSESTree.Expression, buttonVariableName: string): boolean {\n if (expression.type !== \"ConditionalExpression\") {\n return false;\n }\n\n const { test, consequent, alternate } = expression;\n\n // Check if test is: variable === \"large\"\n if (\n test.type === \"BinaryExpression\" &&\n test.operator === \"===\" &&\n test.left.type === \"Identifier\" &&\n test.left.name === buttonVariableName &&\n test.right.type === \"Literal\" &&\n test.right.value === \"large\"\n ) {\n // Check if consequent is \"medium\" and alternate is \"small\"\n return (\n consequent.type === \"Literal\" &&\n consequent.value === \"medium\" &&\n alternate.type === \"Literal\" &&\n alternate.value === \"small\"\n );\n }\n\n return false;\n}\n\nexport const designGuidelineButtonIconSizeMatch = createRule({\n name: \"design-guideline-button-icon-size-match\",\n meta: {\n type: \"suggestion\",\n docs: {\n description: \"Ensure Icon components within Button have the correct size prop based on the Button's size.\",\n },\n fixable: \"code\",\n schema: [],\n messages: {\n incorrectIconSize:\n \"Expected Icon size to be '{{expectedSize}}' for Button size '{{buttonSize}}', found '{{iconSize}}'.\",\n },\n },\n defaultOptions: [],\n create(context) {\n return {\n JSXOpeningElement(node: TSESTree.JSXOpeningElement) {\n if (node.name.type === \"JSXIdentifier\" && node.name.name === \"Button\") {\n const sizeAttr = node.attributes.find(\n (attr): attr is TSESTree.JSXAttribute =>\n attr.type === \"JSXAttribute\" && attr.name.type === \"JSXIdentifier\" && attr.name.name === \"size\"\n );\n\n const buttonSizeInfo = (() => {\n if (!sizeAttr?.value) return { type: \"implicit\", value: null };\n\n if (sizeAttr.value.type === \"Literal\" && typeof sizeAttr.value.value === \"string\") {\n return { type: \"literal\", value: sizeAttr.value.value };\n }\n\n if (sizeAttr.value.type === \"JSXExpressionContainer\") {\n const expr = sizeAttr.value.expression;\n if (expr.type === \"Identifier\") {\n return { type: \"variable\", value: expr.name, expression: expr };\n }\n return { type: \"expression\", value: null, expression: expr };\n }\n\n return { type: \"implicit\", value: null };\n })();\n\n node.attributes.forEach(attr => {\n if (\n attr.type === \"JSXAttribute\" &&\n attr.name.type === \"JSXIdentifier\" &&\n (attr.name.name === \"prefix\" || attr.name.name === \"suffix\") &&\n attr.value?.type === \"JSXExpressionContainer\"\n ) {\n // Find Icon element - could be direct or inside conditional\n const findIconElement = (expression: TSESTree.Expression): TSESTree.JSXOpeningElement | null => {\n if (\n expression.type === \"JSXElement\" &&\n expression.openingElement.name.type === \"JSXIdentifier\" &&\n expression.openingElement.name.name === \"Icon\"\n ) {\n return expression.openingElement;\n }\n\n if (expression.type === \"ConditionalExpression\") {\n // Check both consequent and alternate\n const consequent = findIconElement(expression.consequent);\n if (consequent) return consequent;\n\n const alternate = findIconElement(expression.alternate);\n if (alternate) return alternate;\n }\n\n return null;\n };\n\n // Skip empty JSX expressions like {}\n if (attr.value.expression.type === \"JSXEmptyExpression\") return;\n\n const iconElement = findIconElement(attr.value.expression);\n if (!iconElement) return;\n const iconSizeAttr = iconElement.attributes.find(\n (iconAttr): iconAttr is TSESTree.JSXAttribute =>\n iconAttr.type === \"JSXAttribute\" &&\n iconAttr.name.type === \"JSXIdentifier\" &&\n iconAttr.name.name === \"size\"\n );\n\n const iconSizeInfo = (() => {\n if (!iconSizeAttr?.value) return { type: \"implicit\", value: null };\n\n if (iconSizeAttr.value.type === \"Literal\" && typeof iconSizeAttr.value.value === \"string\") {\n return { type: \"literal\", value: iconSizeAttr.value.value };\n }\n\n if (iconSizeAttr.value.type === \"JSXExpressionContainer\") {\n const expr = iconSizeAttr.value.expression;\n if (expr.type === \"Identifier\") {\n return { type: \"variable\", value: expr.name, expression: expr };\n }\n return { type: \"expression\", value: null, expression: expr };\n }\n\n return { type: \"implicit\", value: null };\n })();\n\n // Rule: large buttons → medium icons, small/medium buttons → small icons\n const getExpectedIconSize = (buttonSize: string): string => {\n if (buttonSize === \"large\") return \"medium\";\n return \"small\"; // both \"small\" and \"medium\" buttons get \"small\" icons\n };\n\n const shouldReport = (() => {\n // For complex expressions, always warn but don't autofix\n if (buttonSizeInfo.type === \"expression\") {\n return true;\n }\n\n // For variables, check if icon already has the correct size\n if (buttonSizeInfo.type === \"variable\" && buttonSizeInfo.expression?.type === \"Identifier\") {\n const possibleSizes = getPossibleStringLiterals(context, buttonSizeInfo.expression);\n\n if (possibleSizes) {\n // Check if all possible button sizes map to the same icon size\n const iconSizes = possibleSizes.map(getExpectedIconSize);\n const uniqueIconSizes = [...new Set(iconSizes)];\n\n if (uniqueIconSizes.length === 1) {\n // All map to same icon size - check if icon already has correct literal\n const variableExpectedIconSize = uniqueIconSizes[0];\n const variableIconEffectiveSize = iconSizeInfo.value || \"medium\";\n\n if (variableIconEffectiveSize === variableExpectedIconSize) {\n return false; // Icon already has correct literal size\n }\n } else {\n // Mixed mapping - check if icon has correct conditional expression\n if (\n iconSizeInfo.type === \"expression\" &&\n iconSizeInfo.expression &&\n iconSizeInfo.expression.type !== \"JSXEmptyExpression\" &&\n buttonSizeInfo.value &&\n isCorrectConditionalExpression(iconSizeInfo.expression, buttonSizeInfo.value)\n ) {\n return false; // Icon already has correct conditional\n }\n }\n }\n\n // Mixed mapping or can't determine - always warn\n return true;\n }\n\n // For literals and implicit, check the mapping\n const buttonEffectiveSize = buttonSizeInfo.value || \"medium\";\n const iconEffectiveSize = iconSizeInfo.value || \"medium\";\n const expectedIconSize = getExpectedIconSize(buttonEffectiveSize);\n\n return iconEffectiveSize !== expectedIconSize;\n })();\n\n if (shouldReport) {\n context.report({\n node: iconElement,\n messageId: \"incorrectIconSize\",\n data: {\n expectedSize: (() => {\n if (buttonSizeInfo.type === \"variable\" && buttonSizeInfo.expression?.type === \"Identifier\") {\n // Analyze the variable's type to determine expected message\n const possibleSizes = getPossibleStringLiterals(context, buttonSizeInfo.expression);\n\n if (possibleSizes) {\n const iconSizes = possibleSizes.map(getExpectedIconSize);\n const uniqueIconSizes = [...new Set(iconSizes)];\n\n if (uniqueIconSizes.length === 1) {\n return uniqueIconSizes[0];\n }\n }\n\n return `{${buttonSizeInfo.value} === \"large\" ? \"medium\" : \"small\"}`;\n }\n if (buttonSizeInfo.type === \"expression\") {\n return \"small (for small/medium buttons) or medium (for large buttons)\";\n }\n const buttonEffectiveSize = buttonSizeInfo.value || \"medium\";\n return getExpectedIconSize(buttonEffectiveSize);\n })(),\n buttonSize:\n buttonSizeInfo.type === \"implicit\"\n ? \"medium (default)\"\n : buttonSizeInfo.type === \"literal\"\n ? buttonSizeInfo.value\n : buttonSizeInfo.type === \"variable\"\n ? (() => {\n if (buttonSizeInfo.expression?.type === \"Identifier\") {\n const possibleSizes = getPossibleStringLiterals(context, buttonSizeInfo.expression);\n if (possibleSizes && possibleSizes.length > 0) {\n const sizeList = possibleSizes.map(s => `\"${s}\"`).join(\" | \");\n return `{${buttonSizeInfo.value}} (of type ${sizeList})`;\n }\n }\n return `{${buttonSizeInfo.value}}`;\n })()\n : \"expression\",\n iconSize:\n iconSizeInfo.type === \"implicit\"\n ? \"medium (default)\"\n : iconSizeInfo.type === \"literal\"\n ? iconSizeInfo.value\n : iconSizeInfo.type === \"variable\"\n ? `{${iconSizeInfo.value}}`\n : \"expression\",\n },\n fix(fixer) {\n // Don't autofix complex expressions, only variables and literals\n if (buttonSizeInfo.type === \"expression\") {\n return null;\n }\n\n let targetSizeValue: string;\n\n if (buttonSizeInfo.type === \"variable\" && buttonSizeInfo.expression?.type === \"Identifier\") {\n // Analyze the variable's type to determine optimal autofix\n const possibleSizes = getPossibleStringLiterals(context, buttonSizeInfo.expression);\n\n if (possibleSizes) {\n // Check if all possible button sizes map to the same icon size\n const iconSizes = possibleSizes.map(getExpectedIconSize);\n const uniqueIconSizes = [...new Set(iconSizes)];\n\n if (uniqueIconSizes.length === 1) {\n // All possible button sizes map to the same icon size\n targetSizeValue = `\"${uniqueIconSizes[0]}\"`;\n } else {\n // Mixed mapping, use conditional\n targetSizeValue = `{${buttonSizeInfo.value} === \"large\" ? \"medium\" : \"small\"}`;\n }\n } else {\n // Can't determine type, use conditional\n targetSizeValue = `{${buttonSizeInfo.value} === \"large\" ? \"medium\" : \"small\"}`;\n }\n } else {\n // Calculate target icon size based on button size (literal or implicit)\n const buttonEffectiveSize = buttonSizeInfo.value || \"medium\";\n const targetIconSize = getExpectedIconSize(buttonEffectiveSize);\n targetSizeValue = `\"${targetIconSize}\"`;\n }\n\n if (iconSizeAttr) {\n // Replace existing size attribute\n if (!iconSizeAttr.value) return null;\n return fixer.replaceText(iconSizeAttr.value, targetSizeValue);\n } else {\n // Add size attribute\n const lastAttr = iconElement.attributes[iconElement.attributes.length - 1];\n if (lastAttr) {\n return fixer.insertTextAfter(lastAttr, ` size=${targetSizeValue}`);\n } else {\n return fixer.insertTextAfter(iconElement.name, ` size=${targetSizeValue}`);\n }\n }\n },\n });\n }\n }\n });\n }\n },\n };\n },\n});\n"]}
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file documents the no-internal-barrel-files rule.
|
|
3
|
-
*
|
|
4
|
-
* Unlike other ESLint rules that check code patterns, this rule checks FILE LOCATION.
|
|
5
|
-
* The rule triggers on any index.ts or index.tsx file that is NOT the root barrel
|
|
6
|
-
* of an NX project (i.e., not at src/index.ts or src/index.tsx).
|
|
7
|
-
*
|
|
8
|
-
* This examples.ts file itself will NOT trigger the rule because it's not named index.ts.
|
|
9
|
-
*
|
|
10
|
-
* ## ✅ VALID - Root barrel file (allowed)
|
|
11
|
-
*
|
|
12
|
-
* ```
|
|
13
|
-
* libs/my-lib/
|
|
14
|
-
* ├── project.json
|
|
15
|
-
* └── src/
|
|
16
|
-
* └── index.ts ← This is the root barrel, allowed
|
|
17
|
-
* ```
|
|
18
|
-
*
|
|
19
|
-
* Content of src/index.ts:
|
|
20
|
-
* ```ts
|
|
21
|
-
* export { Button } from "./components/Button";
|
|
22
|
-
* export { useHook } from "./hooks/useHook";
|
|
23
|
-
* export type { ButtonProps } from "./components/Button";
|
|
24
|
-
* ```
|
|
25
|
-
*
|
|
26
|
-
* ## ❌ INVALID - Internal barrel files (SHOULD be flagged)
|
|
27
|
-
*
|
|
28
|
-
* ```
|
|
29
|
-
* libs/my-lib/
|
|
30
|
-
* ├── project.json
|
|
31
|
-
* └── src/
|
|
32
|
-
* ├── index.ts ← Root barrel (allowed)
|
|
33
|
-
* ├── components/
|
|
34
|
-
* │ ├── index.ts ← VIOLATION: Internal barrel
|
|
35
|
-
* │ └── Button.tsx
|
|
36
|
-
* └── utils/
|
|
37
|
-
* ├── index.ts ← VIOLATION: Internal barrel
|
|
38
|
-
* └── helpers.ts
|
|
39
|
-
* ```
|
|
40
|
-
*
|
|
41
|
-
* ## ❌ INVALID - Deeply nested barrel files (SHOULD be flagged)
|
|
42
|
-
*
|
|
43
|
-
* ```
|
|
44
|
-
* libs/my-lib/
|
|
45
|
-
* ├── project.json
|
|
46
|
-
* └── src/
|
|
47
|
-
* └── features/
|
|
48
|
-
* └── auth/
|
|
49
|
-
* └── index.ts ← VIOLATION: Internal barrel
|
|
50
|
-
* ```
|
|
51
|
-
*
|
|
52
|
-
* ## How to fix violations
|
|
53
|
-
*
|
|
54
|
-
* Option 1: Use the flatten-barrel-exports tool
|
|
55
|
-
* ```bash
|
|
56
|
-
* yarn ts-node devtools/flatten-barrel-exports/flatten-barrel-exports.ts --project=my-lib
|
|
57
|
-
* ```
|
|
58
|
-
*
|
|
59
|
-
* Option 2: Manually move exports to the root barrel
|
|
60
|
-
*
|
|
61
|
-
* Before (with internal barrel):
|
|
62
|
-
* ```ts
|
|
63
|
-
* // src/components/index.ts
|
|
64
|
-
* export { Button } from "./Button";
|
|
65
|
-
* export { Input } from "./Input";
|
|
66
|
-
*
|
|
67
|
-
* // src/index.ts
|
|
68
|
-
* export * from "./components"; // Re-exports the internal barrel
|
|
69
|
-
* ```
|
|
70
|
-
*
|
|
71
|
-
* After (flattened):
|
|
72
|
-
* ```ts
|
|
73
|
-
* // src/index.ts
|
|
74
|
-
* export { Button } from "./components/Button";
|
|
75
|
-
* export { Input } from "./components/Input";
|
|
76
|
-
*
|
|
77
|
-
* // src/components/index.ts - DELETE THIS FILE
|
|
78
|
-
* ```
|
|
79
|
-
*/
|
|
80
|
-
export {};
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// To test this rule: create an index.ts file in a subdirectory and run lint
|
|
3
|
-
// Note: eslint-disable is not needed here because this file is not named index.ts
|
|
4
|
-
/**
|
|
5
|
-
* This file documents the no-internal-barrel-files rule.
|
|
6
|
-
*
|
|
7
|
-
* Unlike other ESLint rules that check code patterns, this rule checks FILE LOCATION.
|
|
8
|
-
* The rule triggers on any index.ts or index.tsx file that is NOT the root barrel
|
|
9
|
-
* of an NX project (i.e., not at src/index.ts or src/index.tsx).
|
|
10
|
-
*
|
|
11
|
-
* This examples.ts file itself will NOT trigger the rule because it's not named index.ts.
|
|
12
|
-
*
|
|
13
|
-
* ## ✅ VALID - Root barrel file (allowed)
|
|
14
|
-
*
|
|
15
|
-
* ```
|
|
16
|
-
* libs/my-lib/
|
|
17
|
-
* ├── project.json
|
|
18
|
-
* └── src/
|
|
19
|
-
* └── index.ts ← This is the root barrel, allowed
|
|
20
|
-
* ```
|
|
21
|
-
*
|
|
22
|
-
* Content of src/index.ts:
|
|
23
|
-
* ```ts
|
|
24
|
-
* export { Button } from "./components/Button";
|
|
25
|
-
* export { useHook } from "./hooks/useHook";
|
|
26
|
-
* export type { ButtonProps } from "./components/Button";
|
|
27
|
-
* ```
|
|
28
|
-
*
|
|
29
|
-
* ## ❌ INVALID - Internal barrel files (SHOULD be flagged)
|
|
30
|
-
*
|
|
31
|
-
* ```
|
|
32
|
-
* libs/my-lib/
|
|
33
|
-
* ├── project.json
|
|
34
|
-
* └── src/
|
|
35
|
-
* ├── index.ts ← Root barrel (allowed)
|
|
36
|
-
* ├── components/
|
|
37
|
-
* │ ├── index.ts ← VIOLATION: Internal barrel
|
|
38
|
-
* │ └── Button.tsx
|
|
39
|
-
* └── utils/
|
|
40
|
-
* ├── index.ts ← VIOLATION: Internal barrel
|
|
41
|
-
* └── helpers.ts
|
|
42
|
-
* ```
|
|
43
|
-
*
|
|
44
|
-
* ## ❌ INVALID - Deeply nested barrel files (SHOULD be flagged)
|
|
45
|
-
*
|
|
46
|
-
* ```
|
|
47
|
-
* libs/my-lib/
|
|
48
|
-
* ├── project.json
|
|
49
|
-
* └── src/
|
|
50
|
-
* └── features/
|
|
51
|
-
* └── auth/
|
|
52
|
-
* └── index.ts ← VIOLATION: Internal barrel
|
|
53
|
-
* ```
|
|
54
|
-
*
|
|
55
|
-
* ## How to fix violations
|
|
56
|
-
*
|
|
57
|
-
* Option 1: Use the flatten-barrel-exports tool
|
|
58
|
-
* ```bash
|
|
59
|
-
* yarn ts-node devtools/flatten-barrel-exports/flatten-barrel-exports.ts --project=my-lib
|
|
60
|
-
* ```
|
|
61
|
-
*
|
|
62
|
-
* Option 2: Manually move exports to the root barrel
|
|
63
|
-
*
|
|
64
|
-
* Before (with internal barrel):
|
|
65
|
-
* ```ts
|
|
66
|
-
* // src/components/index.ts
|
|
67
|
-
* export { Button } from "./Button";
|
|
68
|
-
* export { Input } from "./Input";
|
|
69
|
-
*
|
|
70
|
-
* // src/index.ts
|
|
71
|
-
* export * from "./components"; // Re-exports the internal barrel
|
|
72
|
-
* ```
|
|
73
|
-
*
|
|
74
|
-
* After (flattened):
|
|
75
|
-
* ```ts
|
|
76
|
-
* // src/index.ts
|
|
77
|
-
* export { Button } from "./components/Button";
|
|
78
|
-
* export { Input } from "./components/Input";
|
|
79
|
-
*
|
|
80
|
-
* // src/components/index.ts - DELETE THIS FILE
|
|
81
|
-
* ```
|
|
82
|
-
*/
|
|
83
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
84
|
-
//# sourceMappingURL=examples.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"examples.js","sourceRoot":"","sources":["../../../../../../../../libs/eslint/plugin-trackunit/src/lib/rules/no-internal-barrel-files/examples.ts"],"names":[],"mappings":";AAAA,4EAA4E;AAC5E,kFAAkF;AAClF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8EG","sourcesContent":["// To test this rule: create an index.ts file in a subdirectory and run lint\n// Note: eslint-disable is not needed here because this file is not named index.ts\n/**\n * This file documents the no-internal-barrel-files rule.\n *\n * Unlike other ESLint rules that check code patterns, this rule checks FILE LOCATION.\n * The rule triggers on any index.ts or index.tsx file that is NOT the root barrel\n * of an NX project (i.e., not at src/index.ts or src/index.tsx).\n *\n * This examples.ts file itself will NOT trigger the rule because it's not named index.ts.\n *\n * ## ✅ VALID - Root barrel file (allowed)\n *\n * ```\n * libs/my-lib/\n * ├── project.json\n * └── src/\n * └── index.ts ← This is the root barrel, allowed\n * ```\n *\n * Content of src/index.ts:\n * ```ts\n * export { Button } from \"./components/Button\";\n * export { useHook } from \"./hooks/useHook\";\n * export type { ButtonProps } from \"./components/Button\";\n * ```\n *\n * ## ❌ INVALID - Internal barrel files (SHOULD be flagged)\n *\n * ```\n * libs/my-lib/\n * ├── project.json\n * └── src/\n * ├── index.ts ← Root barrel (allowed)\n * ├── components/\n * │ ├── index.ts ← VIOLATION: Internal barrel\n * │ └── Button.tsx\n * └── utils/\n * ├── index.ts ← VIOLATION: Internal barrel\n * └── helpers.ts\n * ```\n *\n * ## ❌ INVALID - Deeply nested barrel files (SHOULD be flagged)\n *\n * ```\n * libs/my-lib/\n * ├── project.json\n * └── src/\n * └── features/\n * └── auth/\n * └── index.ts ← VIOLATION: Internal barrel\n * ```\n *\n * ## How to fix violations\n *\n * Option 1: Use the flatten-barrel-exports tool\n * ```bash\n * yarn ts-node devtools/flatten-barrel-exports/flatten-barrel-exports.ts --project=my-lib\n * ```\n *\n * Option 2: Manually move exports to the root barrel\n *\n * Before (with internal barrel):\n * ```ts\n * // src/components/index.ts\n * export { Button } from \"./Button\";\n * export { Input } from \"./Input\";\n *\n * // src/index.ts\n * export * from \"./components\"; // Re-exports the internal barrel\n * ```\n *\n * After (flattened):\n * ```ts\n * // src/index.ts\n * export { Button } from \"./components/Button\";\n * export { Input } from \"./components/Input\";\n *\n * // src/components/index.ts - DELETE THIS FILE\n * ```\n */\n\nexport {};\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"no-internal-barrel-files.js","sourceRoot":"","sources":["../../../../../../../../libs/eslint/plugin-trackunit/src/lib/rules/no-internal-barrel-files/no-internal-barrel-files.ts"],"names":[],"mappings":";;;;AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,oDAAuD;AACvD,+CAAyB;AACzB,mDAA6B;AAC7B,6BAAwB;AACxB,uDAAyD;AAEzD,MAAM,iBAAiB,GAAG,OAAC,CAAC,MAAM,CAAC;IACjC,UAAU,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CAClC,CAAC,CAAC;AAEH,MAAM,cAAc,GAAG,OAAC,CAAC,MAAM,CAAC;IAC9B,eAAe,EAAE,OAAC;SACf,MAAM,CAAC;QACN,KAAK,EAAE,OAAC,CAAC,MAAM,CAAC,OAAC,CAAC,KAAK,CAAC,OAAC,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,QAAQ,EAAE;KAChD,CAAC;SACD,QAAQ,EAAE;CACd,CAAC,CAAC;AAEH;;;;GAIG;AACH,MAAM,yBAAyB,GAAG,IAAI,GAAG,EAAuB,CAAC;AAEjE;;GAEG;AACH,MAAM,iBAAiB,GAAG,CAAC,SAAiB,EAAiB,EAAE;IAC7D,MAAM,UAAU,GAAG,IAAA,4BAAe,EAAC,SAAS,EAAE,SAAS,CAAC,CAAC;IACzD,OAAO,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AACtD,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,uBAAuB,GAAG,CAAC,aAAqB,EAAe,EAAE;IACrE,MAAM,MAAM,GAAG,yBAAyB,CAAC,GAAG,CA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2D;gBAC3D,OAAO,CAAC,MAAM,CAAC;oBACb,IAAI;oBACJ,SAAS,EAAE,kBAAkB;iBAC9B,CAAC,CAAC;YACL,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC","sourcesContent":["/**\n * ESLint rule to disallow internal barrel files.\n *\n * Internal barrel files (any index.ts or index.tsx that is not at the library root) cause:\n * - Multiple import paths to the same module\n * - Slower builds (bundlers must traverse more barrel files)\n * - Confusion about canonical import paths\n * - Potential bundle size issues\n * - Module identity problems\n *\n * EXCEPTION: Secondary entry points configured in tsconfig.base.json are allowed.\n * These are intentional barrel files that provide separate package imports\n * (e.g., @trackunit/react-core-contexts-host-test pointing to src/test/index.ts).\n *\n * @example\n * // Valid - Root barrel file\n * // libs/my-lib/src/index.ts ✅\n *\n * // Valid - Secondary entry point configured in tsconfig.base.json\n * // libs/my-lib/src/test/index.ts ✅ (if configured as @trackunit/my-lib-test)\n *\n * // Invalid - Internal barrel file\n * // libs/my-lib/src/components/index.ts ❌\n * // libs/my-lib/src/utils/helpers/index.ts ❌\n */\nimport { ESLintUtils } from \"@typescript-eslint/utils\";\nimport * as fs from \"fs\";\nimport * as path from \"path\";\nimport { z } from \"zod\";\nimport { findNearestFile } from \"../../utils/file-utils\";\n\nconst projectJsonSchema = z.object({\n sourceRoot: z.string().optional(),\n});\n\nconst tsconfigSchema = z.object({\n compilerOptions: z\n .object({\n paths: z.record(z.array(z.string())).optional(),\n })\n .optional(),\n});\n\n/**\n * Cache for tsconfig.base.json secondary entry points.\n * Key: workspace root path\n * Value: Set of absolute paths to allowed secondary entry points\n */\nconst secondaryEntryPointsCache = new Map<string, Set<string>>();\n\n/**\n * Find the workspace root by looking for nx.json\n */\nconst findWorkspaceRoot = (startPath: string): string | null => {\n const nxJsonPath = findNearestFile(startPath, \"nx.json\");\n return nxJsonPath ? path.dirname(nxJsonPath) : null;\n};\n\n/**\n * Get secondary entry points from tsconfig.base.json.\n * These are path mappings that point to index.ts files inside src/ subdirectories.\n * Results are cached per workspace root.\n */\nconst getSecondaryEntryPoints = (workspaceRoot: string): Set<string> => {\n const cached = secondaryEntryPointsCache.get(workspaceRoot);\n if (cached) {\n return cached;\n }\n\n const entryPoints = new Set<string>();\n const tsconfigPath = path.join(workspaceRoot, \"tsconfig.base.json\");\n\n try {\n const tsconfigContent = fs.readFileSync(tsconfigPath, \"utf-8\");\n const parsed = tsconfigSchema.safeParse(JSON.parse(tsconfigContent));\n\n if (parsed.success && parsed.data.compilerOptions?.paths) {\n const paths = parsed.data.compilerOptions.paths;\n\n for (const pathMappings of Object.values(paths)) {\n for (const mapping of pathMappings) {\n // Only consider mappings that point to index.ts files\n if (mapping.endsWith(\"/index.ts\") || mapping.endsWith(\"/index.tsx\")) {\n const absolutePath = path.normalize(path.join(workspaceRoot, mapping));\n entryPoints.add(absolutePath);\n }\n }\n }\n }\n } catch {\n // If we can't read tsconfig.base.json, return empty set\n }\n\n secondaryEntryPointsCache.set(workspaceRoot, entryPoints);\n return entryPoints;\n};\n\nconst createRule = ESLintUtils.RuleCreator(\n name => `https://github.com/trackunit/manager/blob/main/libs/eslint/plugin-trackunit/src/lib/rules/${name}.ts`\n);\n\ntype MessageIds = \"noInternalBarrel\";\ntype Options = [];\n\n/**\n * Check if a file is a barrel file (index.ts or index.tsx).\n */\nconst isBarrelFile = (filePath: string): boolean => {\n const basename = path.basename(filePath);\n return basename === \"index.ts\" || basename === \"index.tsx\";\n};\n\n/**\n * Normalize file path for comparison (handles potential trailing slashes, etc.)\n */\nconst normalizePath = (filePath: string): string => {\n return path.normalize(filePath);\n};\n\nexport const noInternalBarrelFiles = createRule<Options, MessageIds>({\n name: \"no-internal-barrel-files\",\n meta: {\n type: \"suggestion\",\n docs: {\n description:\n \"Disallow internal barrel files (index.ts) that are not at the library root or configured as secondary entry points\",\n },\n schema: [],\n messages: {\n noInternalBarrel:\n \"Internal barrel files are not allowed. Move exports to the root barrel file (src/index.ts) instead. Use the flatten-barrel-exports tool: yarn ts-node devtools/flatten-barrel-exports/flatten-barrel-exports.ts\",\n },\n },\n defaultOptions: [],\n create(context) {\n return {\n Program(node) {\n const currentFile = context.filename;\n\n // Only analyze barrel files (index.ts/tsx)\n if (!isBarrelFile(currentFile)) {\n return;\n }\n\n // Find the project root by looking for project.json\n const projectJsonPath = findNearestFile(currentFile, \"project.json\");\n if (projectJsonPath === null) {\n // Not in an NX project, skip\n return;\n }\n\n const projectRoot = path.dirname(projectJsonPath);\n const workspaceRoot = findWorkspaceRoot(currentFile);\n\n // Read sourceRoot from project.json, defaulting to \"src\" if not specified\n // sourceRoot in project.json is relative to workspace root (e.g., \"libs/my-lib/src\")\n let sourceRootAbsolute = path.join(projectRoot, \"src\");\n try {\n const projectJsonContent = fs.readFileSync(projectJsonPath, \"utf-8\");\n const parsed = projectJsonSchema.safeParse(JSON.parse(projectJsonContent));\n if (parsed.success && parsed.data.sourceRoot && workspaceRoot) {\n // sourceRoot is relative to workspace root, so resolve it\n sourceRootAbsolute = path.join(workspaceRoot, parsed.data.sourceRoot);\n }\n } catch {\n // If we can't read project.json, fall back to projectRoot/src\n }\n\n // The root barrel is at {sourceRoot}/index.ts or {sourceRoot}/index.tsx\n const rootBarrelTs = normalizePath(path.join(sourceRootAbsolute, \"index.ts\"));\n const rootBarrelTsx = normalizePath(path.join(sourceRootAbsolute, \"index.tsx\"));\n const normalizedCurrentFile = normalizePath(currentFile);\n\n // If this IS the root barrel, it's allowed\n if (normalizedCurrentFile === rootBarrelTs || normalizedCurrentFile === rootBarrelTsx) {\n return;\n }\n\n // Check if this is a secondary entry point configured in tsconfig.base.json\n if (workspaceRoot) {\n const secondaryEntryPoints = getSecondaryEntryPoints(workspaceRoot);\n if (secondaryEntryPoints.has(normalizedCurrentFile)) {\n // This is a configured secondary entry point, allow it\n return;\n }\n }\n\n // This is an internal barrel file - flag it\n // Note: No autofix or suggestion is provided because:\n // 1. The exports need to be moved to the root barrel\n // 2. Imports throughout the codebase may need updating\n // 3. The flatten-barrel-exports tool handles this properly\n context.report({\n node,\n messageId: \"noInternalBarrel\",\n });\n },\n };\n },\n});\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"no-internal-graphql-when-tagged-with-gql-public.js","sourceRoot":"","sources":["../../../../../../../../libs/eslint/plugin-trackunit/src/lib/rules/no-internal-graphql-when-tagged-with-gql-public/no-internal-graphql-when-tagged-with-gql-public.ts"],"names":[],"mappings":";;;;AACA,+CAAyB;AACzB,mDAA6B;AAE7B,MAAM,IAAI,GAAsB;IAC9B,IAAI,EAAE,SAAS;IACf,IAAI,EAAE;QACJ,WAAW,EAAE,yEAAyE;KACvF;IACD,QAAQ,EAAE;QACR,wBAAwB,EAAE,kEAAkE;KAC7F;IACD,MAAM,EAAE,EAAE;CACX,CAAC;AAEF,MAAM,MAAM,GAAG,CAAC,OAAyB,EAAqB,EAAE;IAC9D,MAAM,4BAA4B,GAAG,CAAC,OAAe,EAAE,QAAgB,EAAE,EAAE;QACzE,MAAM,KAAK,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACzD,MAAM,IAAI,GAAG,KAAK,CAAC,MAAM,CAAC;QAC1B,MAAM,MAAM,GAAG,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE,MAAM,IAAI,CAAC,CAAC;QACpD,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;IAC1B,CAAC,CAAC;IAEF,MAAM,qCAAqC,GAAG,CAAC,SAAiB,EAAE,WAAmB,EAAE,EAAE;QACvF,MAAM,KAAK,GAAG,EAAE,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC;QACxC,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACzB,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;YAE5C,0DAA0D;YAC1D,IAAI,IAAc,CAAC;YACnB,IAA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;CACP,CAAC","sourcesContent":["import { Rule } from \"eslint\";\nimport * as fs from \"fs\";\nimport * as path from \"path\";\n\nconst meta: Rule.RuleMetaData = {\n type: \"problem\",\n docs: {\n description: \"Disallow '-internal.graphql' files in projects tagged with 'gql:public'\",\n },\n messages: {\n internalGraphqlFileFound: \"'-internal.graphql' file found in a 'gql:public' tagged project.\",\n },\n schema: [],\n};\n\nconst create = (context: Rule.RuleContext): Rule.RuleListener => {\n const getLineAndColumnFromPosition = (content: string, position: number) => {\n const lines = content.substring(0, position).split(\"\\n\");\n const line = lines.length;\n const column = lines[lines.length - 1]?.length ?? 0;\n return { line, column };\n };\n\n const checkDirectoryForInternalGraphQLFiles = (directory: string, projectJson: string) => {\n const files = fs.readdirSync(directory);\n for (const file of files) {\n const fullPath = path.join(directory, file);\n\n // Handle broken symlinks or inaccessible paths gracefully\n let stat: fs.Stats;\n try {\n stat = fs.statSync(fullPath);\n } catch {\n // Skip paths that can't be accessed (broken symlinks, permission issues, etc.)\n continue;\n }\n\n if (stat.isDirectory()) {\n checkDirectoryForInternalGraphQLFiles(fullPath, projectJson);\n } else if (file.endsWith(\"-internal.graphql\")) {\n context.report({\n message: `'*-internal.graphql' file found in a 'gql:public' tagged project. - ${fullPath}`,\n loc: getLineAndColumnFromPosition(projectJson, projectJson.indexOf(\"gql:public\")),\n });\n return;\n }\n }\n };\n return {\n Program: _node => {\n const sourceFilePath = context.getFilename();\n if (sourceFilePath.endsWith(\"/project.json\")) {\n const projectJsonString = fs.readFileSync(sourceFilePath, \"utf8\");\n const projectJson: { tags?: Array<string> } = JSON.parse(projectJsonString);\n if (Array.isArray(projectJson.tags) && projectJson.tags.includes(\"gql:public\")) {\n const projectDir = path.dirname(sourceFilePath);\n checkDirectoryForInternalGraphQLFiles(projectDir, projectJsonString);\n }\n }\n },\n };\n};\n\nexport const noInternalGraphqlWhenTaggedWithGqlPublic = {\n meta,\n create,\n};\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"no-jest-mock-trackunit-react-core-hooks.js","sourceRoot":"","sources":["../../../../../../../../libs/eslint/plugin-trackunit/src/lib/rules/no-jest-mock-trackunit-react-core-hooks/no-jest-mock-trackunit-react-core-hooks.ts"],"names":[],"mappings":";;;AAEa,QAAA,iCAAiC,GAAoB;IAChE,IAAI,EAAE;QACJ,IAAI,EAAE,SAAS;QACf,IAAI,EAAE;YACJ,WAAW,EAAE,4DAA4D;SAC1E;QACD,QAAQ,EAAE;YACR,YAAY,EACV,oKAAoK;SACvK;QACD,MAAM,EAAE,EAAE;KACX;IACD,MAAM,CAAC,OAAO;QACZ,OAAO;YACL,cAAc,CAAC,IAAI;gBACjB,IACE,IAAI,CAAC,MAAM,CAAC,IAAI,KAAK,kBAAkB;oBACvC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,KAAK,YAAY;oBACxC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,KAAK,MAAM;oBAClC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,KAAK,YAAY;oBAC1C,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,KAAK,MAAM;oBACpC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,IAAI,KAAK,SAAS;oBACrC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,KAAK,KAAK,6BAA6B,EACzD,CAAC;oBACD,OAAO,CAAC,MAAM,CAAC;wBACb,IAAI;wBACJ,SAAS,EAAE,cAAc;qBAC1B,CAAC,CAAC;gBACL,CAAC;YACH,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC","sourcesContent":["import type { Rule } from \"eslint\";\n\nexport const noJestMockTrackunitReactCoreHooks: Rule.RuleModule = {\n meta: {\n type: \"problem\",\n docs: {\n description: \"Disallow direct jest.mock() of @trackunit/react-core-hooks\",\n },\n messages: {\n noDirectMock:\n 'Don\\'t use jest.mock(\"@trackunit/react-core-hooks\"). Use mock builder from trackunitProviders(), trackunitProvidersInternal() or trackunitProvidersHost() instead.',\n },\n schema: [],\n },\n create(context) {\n return {\n CallExpression(node) {\n if (\n node.callee.type === \"MemberExpression\" &&\n node.callee.object.type === \"Identifier\" &&\n node.callee.object.name === \"jest\" &&\n node.callee.property.type === \"Identifier\" &&\n node.callee.property.name === \"mock\" &&\n node.arguments[0]?.type === \"Literal\" &&\n node.arguments[0].value === \"@trackunit/react-core-hooks\"\n ) {\n context.report({\n node,\n messageId: \"noDirectMock\",\n });\n }\n },\n };\n },\n};\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"no-template-strings-in-classname-prop.js","sourceRoot":"","sources":["../../../../../../../../libs/eslint/plugin-trackunit/src/lib/rules/no-template-strings-in-classname-prop/no-template-strings-in-classname-prop.ts"],"names":[],"mappings":";;;AAAA,oDAAiF;AACjF,iEAAmE;AAEnE,MAAM,UAAU,GAAG,mBAAW,CAAC,WAAW,CACxC,IAAI,CAAC,EAAE,CAAC,6FAA6F,IAAI,KAAK,CAC/G,CAAC;AAKF;;;;;;;;;;;GAWG;AACU,QAAA,4BAA4B,GAAG,UAAU,CAAsB;IAC1E,IAAI,EAAE,uCAAuC;IAC7C,IAAI,EAAE;QACJ,IAAI,EAAE,YAAY;QAClB,IAAI,EAAE;YACJ,WAAW,EAAE,8FAA8F;SAC5G;QACD,QAAQ,EAAE;YACR,yBAAyB,EACvB,+LAA+L;SAClM;QACD,MAAM,EAAE,EAAE;KACX;IACD,cAAc,EAAE,EAAE;IAClB,MAAM,CAAC,OAAO;QACZ,OAAO;YACL;;;;;;eAMG;YACH,YAAY,CAAC,IAA2B;gBACtC,8DAA8D;gBAC9D,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,sBAAc,CAAC,aAAa,IAAI,CAAC,IAAA,sCAAoB,EAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;oBAC7F,OAAO;gBACT,CAAC;gBAED,yEAAyE;gBACzE,IACE,IAAI,CAAC,KAAK,EAAE,IAAI,KAAK,sBAAc,CAAC,sBAAsB;oBAC1D,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI,KAAK,sBAAc,CAAC,eAAe,EAC7D,CAAC;oBACD,OAAO,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,2BAA2B,EAAE,CAAC,CAAC;gBACnE,CAAC;YACH,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC","sourcesContent":["import { AST_NODE_TYPES, ESLintUtils, TSESTree } from \"@typescript-eslint/utils\";\nimport { isClassnameAttribute } from \"../../utils/classname-utils\";\n\nconst createRule = ESLintUtils.RuleCreator(\n name => `https://github.com/trackunit/manager/blob/main/libs/eslint/plugin-trackunit/src/lib/rules/${name}.ts`\n);\n\ntype MessageIds = \"templateStringInClassName\";\ntype Options = [];\n\n/**\n * ESLint rule to disallow template strings in className prop.\n *\n * @example\n * // Bad\n * <div className={`${dynamicClass} staticClass`}>Content</div>\n *\n * // Good\n * <div className={twMerge(dynamicClassName, \"staticClassName\")}>Content</div>\n * // or\n * <div className={yourCvaMergeFunction({ yourVariantProp, className: \"extraClassName\" })}>Content</div>\n */\nexport const noTemplateStringsInClassName = createRule<Options, MessageIds>({\n name: \"no-template-strings-in-classname-prop\",\n meta: {\n type: \"suggestion\",\n docs: {\n description: \"Disallow the use of template strings in className prop to encourage better class management.\",\n },\n messages: {\n templateStringInClassName:\n \"Do not use template strings in className prop. If you wish to merge classes from different sources, use twMerge() for simple inline merging or make a cvaMerge() function if it has variants.\",\n },\n schema: [],\n },\n defaultOptions: [],\n create(context) {\n return {\n /**\n * Handle JSXAttribute with className prop that uses template strings.\n *\n * @example\n * // Bad\n * <div className={`${dynamicClass} staticClass`}>Content</div>\n */\n JSXAttribute(node: TSESTree.JSXAttribute) {\n // Check if this is a classname attribute (className or class)\n if (node.name.type !== AST_NODE_TYPES.JSXIdentifier || !isClassnameAttribute(node.name.name)) {\n return;\n }\n\n // Check if the value is a template literal in a JSX expression container\n if (\n node.value?.type === AST_NODE_TYPES.JSXExpressionContainer &&\n node.value.expression.type === AST_NODE_TYPES.TemplateLiteral\n ) {\n context.report({ node, messageId: \"templateStringInClassName\" });\n }\n },\n };\n },\n});\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// To test this rule: comment out the eslint-disable line below and run: yarn nx run eslint-plugin-trackunit:lint
|
|
3
|
-
/* eslint-disable @trackunit/no-typescript-assertion */
|
|
4
|
-
// This file demonstrates the no-typescript-assertion rule
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
// ✅ VALID - Using as const (allowed exception)
|
|
7
|
-
const _config = { name: "test", value: 123 };
|
|
8
|
-
const _colors = ["red", "green", "blue"];
|
|
9
|
-
// ✅ VALID - Using as unknown as intermediate (allowed exception, but still discouraged)
|
|
10
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
|
|
11
|
-
const _data = someValue;
|
|
12
|
-
// ✅ VALID - Proper type guard
|
|
13
|
-
function isString(val) {
|
|
14
|
-
return typeof val === "string";
|
|
15
|
-
}
|
|
16
|
-
const _validValue = isString(something) ? something : "default";
|
|
17
|
-
// ✅ VALID - Explicit null/undefined handling
|
|
18
|
-
const _validOptional = maybeValue ?? "default";
|
|
19
|
-
// ❌ INVALID - Angle bracket assertion (SHOULD be flagged)
|
|
20
|
-
const _angleExample = someValue;
|
|
21
|
-
// ❌ INVALID - 'as' keyword assertion (SHOULD be flagged)
|
|
22
|
-
const _asExample = someValue;
|
|
23
|
-
const _asNumber = userInput;
|
|
24
|
-
const _asObject = response;
|
|
25
|
-
// ❌ INVALID - Non-null assertion (SHOULD be flagged)
|
|
26
|
-
// These are intentionally invalid examples - the rule should catch these
|
|
27
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
28
|
-
const _nonNullExample = maybeNull;
|
|
29
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion, @typescript-eslint/no-unnecessary-type-assertion
|
|
30
|
-
const _chainedNonNull = obj.prop.value;
|
|
31
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion, @typescript-eslint/no-unnecessary-type-assertion
|
|
32
|
-
const _arrayNonNull = arr[0];
|
|
33
|
-
// ❌ INVALID - Multiple assertion types in one file
|
|
34
|
-
const _mixed1 = value;
|
|
35
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
36
|
-
const _mixed2 = anotherValue;
|
|
37
|
-
const _mixed3 = yetAnotherValue;
|
|
38
|
-
// ❌ INVALID - Common real-world cases that should be caught
|
|
39
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
|
|
40
|
-
const _apiResponse = fetch("/api/data");
|
|
41
|
-
const _jsonData = JSON.parse(str);
|
|
42
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
43
|
-
const _element = document.getElementById("root");
|
|
44
|
-
const _typedArray = Array.from(collection);
|
|
45
|
-
//# sourceMappingURL=examples.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"examples.js","sourceRoot":"","sources":["../../../../../../../../libs/eslint/plugin-trackunit/src/lib/rules/no-typescript-assertion/examples.ts"],"names":[],"mappings":";AAAA,iHAAiH;AACjH,uDAAuD;AACvD,0DAA0D;;AAuB1D,+CAA+C;AAC/C,MAAM,OAAO,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,EAAW,CAAC;AACtD,MAAM,OAAO,GAAG,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,CAAU,CAAC;AAElD,wFAAwF;AACxF,4EAA4E;AAC5E,MAAM,KAAK,GAAG,SAAoB,CAAC;AAEnC,8BAA8B;AAC9B,SAAS,QAAQ,CAAC,GAAY;IAC5B,OAAO,OAAO,GAAG,KAAK,QAAQ,CAAC;AACjC,CAAC;AACD,MAAM,WAAW,GAAG,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC;AAEhE,6CAA6C;AAC7C,MAAM,cAAc,GAAG,UAAU,IAAI,SAAS,CAAC;AAE/C,0DAA0D;AAC1D,MAAM,aAAa,GAAW,SAAS,CAAC;AAExC,yDAAyD;AACzD,MAAM,UAAU,GAAG,SAAmB,CAAC;AACvC,MAAM,SAAS,GAAG,SAAmB,CAAC;AACtC,MAAM,SAAS,GAAG,QAAwC,CAAC;AAE3D,qDAAqD;AACrD,yEAAyE;AACzE,oEAAoE;AACpE,MAAM,eAAe,GAAG,SAAU,CAAC;AACnC,sHAAsH;AACtH,MAAM,eAAe,GAAG,GAAI,CAAC,IAAK,CAAC,KAAM,CAAC;AAC1C,sHAAsH;AACtH,MAAM,aAAa,GAAG,GAAI,CAAC,CAAC,CAAC,CAAC;AAE9B,mDAAmD;AACnD,MAAM,OAAO,GAAG,KAAiB,CAAC;AAClC,oEAAoE;AACpE,MAAM,OAAO,GAAG,YAAa,CAAC;AAC9B,MAAM,OAAO,GAAc,eAAe,CAAC;AAE3C,4DAA4D;AAC5D,4EAA4E;AAC5E,MAAM,YAAY,GAAG,KAAK,CAAC,WAAW,CAAsB,CAAC;AAC7D,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAgB,CAAC;AACjD,oEAAoE;AACpE,MAAM,QAAQ,GAAG,QAAQ,CAAC,cAAc,CAAC,MAAM,CAAE,CAAC;AAClD,MAAM,WAAW,GAAG,KAAK,CAAC,IAAI,CAAC,UAAU,CAAqB,CAAC","sourcesContent":["// To test this rule: comment out the eslint-disable line below and run: yarn nx run eslint-plugin-trackunit:lint\n/* eslint-disable @trackunit/no-typescript-assertion */\n// This file demonstrates the no-typescript-assertion rule\n\n// Declare variables used in examples\ndeclare const someValue: unknown;\ndeclare const something: unknown;\ndeclare const maybeValue: unknown;\ndeclare const userInput: unknown;\ndeclare const response: unknown;\ndeclare const maybeNull: unknown;\ndeclare const obj: { prop?: { value?: unknown } };\ndeclare const arr: Array<unknown>;\ndeclare const value: unknown;\ndeclare const anotherValue: unknown;\ndeclare const yetAnotherValue: unknown;\ndeclare const str: string;\ndeclare const collection: Iterable<unknown>;\n\ntype SomeType = Record<string, unknown>;\ntype MyInterface = { id: number; name: string };\ntype _ApiData = { data: unknown };\ntype ThirdType = Record<string, unknown>;\ntype TypedItem = { id: string };\n\n// ✅ VALID - Using as const (allowed exception)\nconst _config = { name: \"test\", value: 123 } as const;\nconst _colors = [\"red\", \"green\", \"blue\"] as const;\n\n// ✅ VALID - Using as unknown as intermediate (allowed exception, but still discouraged)\n// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\nconst _data = someValue as unknown;\n\n// ✅ VALID - Proper type guard\nfunction isString(val: unknown): val is string {\n return typeof val === \"string\";\n}\nconst _validValue = isString(something) ? something : \"default\";\n\n// ✅ VALID - Explicit null/undefined handling\nconst _validOptional = maybeValue ?? \"default\";\n\n// ❌ INVALID - Angle bracket assertion (SHOULD be flagged)\nconst _angleExample = <string>someValue;\n\n// ❌ INVALID - 'as' keyword assertion (SHOULD be flagged)\nconst _asExample = someValue as string;\nconst _asNumber = userInput as number;\nconst _asObject = response as { id: number; name: string };\n\n// ❌ INVALID - Non-null assertion (SHOULD be flagged)\n// These are intentionally invalid examples - the rule should catch these\n// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\nconst _nonNullExample = maybeNull!;\n// eslint-disable-next-line @typescript-eslint/no-non-null-assertion, @typescript-eslint/no-unnecessary-type-assertion\nconst _chainedNonNull = obj!.prop!.value!;\n// eslint-disable-next-line @typescript-eslint/no-non-null-assertion, @typescript-eslint/no-unnecessary-type-assertion\nconst _arrayNonNull = arr![0];\n\n// ❌ INVALID - Multiple assertion types in one file\nconst _mixed1 = value as SomeType;\n// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\nconst _mixed2 = anotherValue!;\nconst _mixed3 = <ThirdType>yetAnotherValue;\n\n// ❌ INVALID - Common real-world cases that should be caught\n// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\nconst _apiResponse = fetch(\"/api/data\") as Promise<Response>;\nconst _jsonData = JSON.parse(str) as MyInterface;\n// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\nconst _element = document.getElementById(\"root\")!;\nconst _typedArray = Array.from(collection) as Array<TypedItem>;\n\nexport {};\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"no-typescript-assertion.js","sourceRoot":"","sources":["../../../../../../../../libs/eslint/plugin-trackunit/src/lib/rules/no-typescript-assertion/no-typescript-assertion.ts"],"names":[],"mappings":";;;AAkBA,MAAM,IAAI,GAAsB;IAC9B,IAAI,EAAE,YAAY;IAClB,IAAI,EAAE;QACJ,WAAW,EAAE,qEAAqE;KACnF;IACD,QAAQ,EAAE;QACR,qBAAqB,EAAE,wEAAwE;QAC/F,WAAW,EAAE,2EAA2E;QACxF,gBAAgB,EAAE,iFAAiF;KACpG;IACD,MAAM,EAAE,EAAE;CACX,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,GAAG,CAAC,OAAyB,EAAqB,EAAE;IAC9D,OAAO;QACL;;;;;;;WAOG;QACH,eAAe,CAAC,IAAS;YACvB,MAAM,EAAE,cAAc,EAAE,GAAG,IAAI,CAAC;YAEhC,IAAI,cAAc,CAAC,IAAI,KAAK,kBAAkB,EAAE,CAAC;gBAC/C,OAAO;YACT,CAAC;YAED,IAAI,cAAc,CAAC,IAAI,KAAK,iBAAiB,EAAE,CAAC;gBAC9C,MAAM,EAAE,QAAQ,EAAE,GAAG,cAAc,CAAC;gBACpC,IAAI,QAAQ,CAAC,IAAI,KAAK,YAAY,IAAI,QAAQ,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;oBAChE,OAAO;gBACT,CAAC;YACH,CAAC;YAED,OAAO,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,uBAAuB,EAAE,CAAC,CAAC;QAC/D,CAAC;QACD;;;;;;;WAOG;QACH,cAAc,CAAC,IAAS;YACtB,MAAM,EAAE,cAAc,EAAE,GAAG,IAAI,CAAC;YAEhC,IAAI,cAAc,CAAC,IAAI,KAAK,kBAAkB,EAAE,CAAC;gBAC/C,OAAO;YACT,CAAC;YAED,IAAI,cAAc,CAAC,IAAI,KAAK,iBAAiB,EAAE,CAAC;gBAC9C,MAAM,EAAE,QAAQ,EAAE,GAAG,cAAc,CAAC;gBACpC,IAAI,QAAQ,CAAC,IAAI,KAAK,YAAY,IAAI,QAAQ,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;oBAChE,OAAO;gBACT,CAAC;YACH,CAAC;YAED,OAAO,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,aAAa,EAAE,CAAC,CAAC;QACrD,CAAC;QACD;;;;;;;WAOG;QACH,mBAAmB,CAAC,IAAS;YAC3B,OAAO,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,kBAAkB,EAAE,CAAC,CAAC;QAC1D,CAAC;KACF,CAAC;AACJ,CAAC,CAAC;AAEW,QAAA,qBAAqB,GAAG;IACnC,IAAI;IACJ,MAAM;CACP,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n/**\n * ESLint rule to disallow type assertions in TypeScript.\n * Initial implementation based on eslint-plugin-no-type-assertion\n * https://github.com/Dremora/eslint-plugin-no-type-assertion/blob/master/lib/rules/no-type-assertion.js\n *\n * @example\n * // Bad - type assertions bypass type checking\n * const foo = <string> bar;\n * const baz = bar as string;\n * const qux = bar!;\n *\n * // Good - proper typing or const assertions\n * const foo = bar;\n * const options = [\"a\", \"b\"] as const;\n */\nimport { Rule } from \"eslint\";\n\nconst meta: Rule.RuleMetaData = {\n type: \"suggestion\",\n docs: {\n description: \"Prevent the use of type assertions to encourage better type safety.\",\n },\n messages: {\n angleBracketAssertion: \"Avoid using angle bracket for type casting. It bypasses type checking.\",\n asAssertion: \"Avoid using the `as` keyword for type casting. It bypasses type checking.\",\n nonNullAssertion: \"Avoid using the non-null assertion operator (!). It can lead to runtime errors.\",\n },\n schema: [],\n};\n\n/**\n * Create ESLint rule listener.\n *\n * @param {Rule.RuleContext} context - The ESLint rule context.\n * @returns {Rule.RuleListener} - The listener object for this rule.\n */\nconst create = (context: Rule.RuleContext): Rule.RuleListener => {\n return {\n /**\n * Handle TypeScript type assertions using angle brackets.\n *\n * @example\n * // Bad\n * const foo = <string> bar;\n * @param {any} node - The AST node.\n */\n TSTypeAssertion(node: any) {\n const { typeAnnotation } = node;\n\n if (typeAnnotation.type === \"TSUnknownKeyword\") {\n return;\n }\n\n if (typeAnnotation.type === \"TSTypeReference\") {\n const { typeName } = typeAnnotation;\n if (typeName.type === \"Identifier\" && typeName.name === \"const\") {\n return;\n }\n }\n\n context.report({ node, messageId: \"angleBracketAssertion\" });\n },\n /**\n * Handle TypeScript 'as' expressions for type assertions.\n *\n * @example\n * // Bad\n * const baz = bar as string;\n * @param {any} node - The AST node.\n */\n TSAsExpression(node: any) {\n const { typeAnnotation } = node;\n\n if (typeAnnotation.type === \"TSUnknownKeyword\") {\n return;\n }\n\n if (typeAnnotation.type === \"TSTypeReference\") {\n const { typeName } = typeAnnotation;\n if (typeName.type === \"Identifier\" && typeName.name === \"const\") {\n return;\n }\n }\n\n context.report({ node, messageId: \"asAssertion\" });\n },\n /**\n * Handle TypeScript non-null expressions using the postfix expression '!'.\n *\n * @example\n * // Bad\n * const qux = bar!;\n * @param {any} node - The AST node.\n */\n TSNonNullExpression(node: any) {\n context.report({ node, messageId: \"nonNullAssertion\" });\n },\n };\n};\n\nexport const noTypescriptAssertion = {\n meta,\n create,\n};\n"]}
|