@economic/taco-rules 0.0.0-stage → 2.0.0-alpha-rules.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/README.md +426 -2
  2. package/dist/oxlint/configs/all.d.ts +4 -0
  3. package/dist/oxlint/configs/all.js +5 -0
  4. package/dist/oxlint/configs/recommended.d.ts +4 -0
  5. package/dist/oxlint/configs/recommended.js +10 -0
  6. package/dist/oxlint/configs/styles.d.ts +4 -0
  7. package/dist/oxlint/configs/styles.js +12 -0
  8. package/dist/oxlint/index.d.ts +37 -0
  9. package/dist/oxlint/index.js +18 -0
  10. package/dist/oxlint/lib/create-class-policy-visitors.d.ts +9 -0
  11. package/dist/oxlint/lib/create-class-policy-visitors.js +17 -0
  12. package/dist/oxlint/lib/visit-tailwind-class-sources.d.ts +16 -0
  13. package/dist/oxlint/lib/visit-tailwind-class-sources.js +21 -0
  14. package/dist/oxlint/rules/consistent-clsx-import/consistent-clsx-import.d.ts +2 -0
  15. package/dist/oxlint/rules/consistent-clsx-import/consistent-clsx-import.js +66 -0
  16. package/dist/oxlint/rules/data-taco-kebab-case/data-taco-kebab-case.d.ts +2 -0
  17. package/dist/oxlint/rules/data-taco-kebab-case/data-taco-kebab-case.js +73 -0
  18. package/dist/oxlint/rules/index.d.ts +2 -0
  19. package/dist/oxlint/rules/index.js +30 -0
  20. package/dist/oxlint/rules/no-component-margin/no-component-margin.d.ts +2 -0
  21. package/dist/oxlint/rules/no-component-margin/no-component-margin.js +93 -0
  22. package/dist/oxlint/rules/no-cross-boundary-relative-imports/no-cross-boundary-relative-imports.d.ts +2 -0
  23. package/dist/oxlint/rules/no-cross-boundary-relative-imports/no-cross-boundary-relative-imports.js +131 -0
  24. package/dist/oxlint/rules/no-data-taco-attribute/no-data-taco-attribute.d.ts +2 -0
  25. package/dist/oxlint/rules/no-data-taco-attribute/no-data-taco-attribute.js +28 -0
  26. package/dist/oxlint/rules/no-disallowed-color-classes/no-disallowed-color-classes.d.ts +2 -0
  27. package/dist/oxlint/rules/no-disallowed-color-classes/no-disallowed-color-classes.js +23 -0
  28. package/dist/oxlint/rules/no-disallowed-radius-classes/no-disallowed-radius-classes.d.ts +2 -0
  29. package/dist/oxlint/rules/no-disallowed-radius-classes/no-disallowed-radius-classes.js +19 -0
  30. package/dist/oxlint/rules/no-disallowed-shadow-classes/no-disallowed-shadow-classes.d.ts +2 -0
  31. package/dist/oxlint/rules/no-disallowed-shadow-classes/no-disallowed-shadow-classes.js +20 -0
  32. package/dist/oxlint/rules/no-disallowed-spacing-classes/no-disallowed-spacing-classes.d.ts +2 -0
  33. package/dist/oxlint/rules/no-disallowed-spacing-classes/no-disallowed-spacing-classes.js +21 -0
  34. package/dist/oxlint/rules/no-display-value-key/no-display-value-key.d.ts +2 -0
  35. package/dist/oxlint/rules/no-display-value-key/no-display-value-key.js +114 -0
  36. package/dist/oxlint/rules/no-leaked-render/no-leaked-render.d.ts +2 -0
  37. package/dist/oxlint/rules/no-leaked-render/no-leaked-render.js +72 -0
  38. package/dist/oxlint/rules/no-react-useid/no-react-useid.d.ts +2 -0
  39. package/dist/oxlint/rules/no-react-useid/no-react-useid.js +56 -0
  40. package/dist/oxlint/rules/no-separate-size-classes/no-separate-size-classes.d.ts +2 -0
  41. package/dist/oxlint/rules/no-separate-size-classes/no-separate-size-classes.js +218 -0
  42. package/dist/oxlint/rules/no-unnecessary-template-literal/no-unnecessary-template-literal.d.ts +2 -0
  43. package/dist/oxlint/rules/no-unnecessary-template-literal/no-unnecessary-template-literal.js +63 -0
  44. package/dist/policies/classes.d.ts +12 -0
  45. package/dist/policies/classes.js +36 -0
  46. package/dist/policies/color.d.ts +11 -0
  47. package/dist/policies/color.js +217 -0
  48. package/dist/policies/radius.d.ts +4 -0
  49. package/dist/policies/radius.js +30 -0
  50. package/dist/policies/shadow.d.ts +2 -0
  51. package/dist/policies/shadow.js +23 -0
  52. package/dist/policies/spacing.d.ts +4 -0
  53. package/dist/policies/spacing.js +32 -0
  54. package/dist/policies/theme.d.ts +6 -0
  55. package/dist/policies/theme.js +14 -0
  56. package/dist/stylelint/index.d.ts +3 -0
  57. package/dist/stylelint/index.js +36 -0
  58. package/dist/stylelint/lib/create-policy-plugin.d.ts +16 -0
  59. package/dist/stylelint/lib/create-policy-plugin.js +36 -0
  60. package/dist/stylelint/lib/walk-css-sources.d.ts +15 -0
  61. package/dist/stylelint/lib/walk-css-sources.js +28 -0
  62. package/dist/stylelint/rules/color-token/color-token.d.ts +2 -0
  63. package/dist/stylelint/rules/color-token/color-token.js +4 -0
  64. package/dist/stylelint/rules/color-value/color-value.d.ts +2 -0
  65. package/dist/stylelint/rules/color-value/color-value.js +19 -0
  66. package/dist/stylelint/rules/radius/radius.d.ts +2 -0
  67. package/dist/stylelint/rules/radius/radius.js +8 -0
  68. package/dist/stylelint/rules/shadow/shadow.d.ts +2 -0
  69. package/dist/stylelint/rules/shadow/shadow.js +4 -0
  70. package/dist/stylelint/rules/spacing/spacing.d.ts +2 -0
  71. package/dist/stylelint/rules/spacing/spacing.js +8 -0
  72. package/oxlint/styles.json +11 -0
  73. package/package.json +67 -5
@@ -0,0 +1,66 @@
1
+ import { defineRule } from '@oxlint/plugins';
2
+ // Enforces a single canonical way of importing clsx: `import cn from 'clsx';`.
3
+ // Disallows the default import under its own name, named imports (`{ clsx }`),
4
+ // and namespace imports — all of which currently coexist in the codebase.
5
+ const MESSAGE = "Import clsx's default export as `cn`: `import cn from 'clsx';`.";
6
+ const CANONICAL_IMPORT_TEXT = "import cn from 'clsx';";
7
+ function isCanonicalImport(node) {
8
+ const [specifier, ...rest] = node.specifiers;
9
+ return rest.length === 0 && specifier?.type === 'ImportDefaultSpecifier' && specifier.local.name === 'cn';
10
+ }
11
+ function hasNamespaceSpecifier(node) {
12
+ return node.specifiers.some(specifier => specifier.type === 'ImportNamespaceSpecifier');
13
+ }
14
+ // Renaming every reference of this import's specifiers to `cn` is only safe if no *other*
15
+ // variable named `cn` exists anywhere in the file — otherwise the rename could silently
16
+ // shadow or collide with it. A pre-existing `cn` that belongs to this same import (e.g. the
17
+ // `cn` in `import cn, { clsx } from 'clsx'`) is fine, since renaming it to itself is a no-op.
18
+ function hasForeignCnBinding(context, node) {
19
+ const ownVariables = new Set(node.specifiers.flatMap(specifier => context.sourceCode.getDeclaredVariables(specifier)));
20
+ return context.sourceCode.scopeManager.scopes.some(scope => {
21
+ const variable = scope.set.get('cn');
22
+ return variable !== undefined && !ownVariables.has(variable);
23
+ });
24
+ }
25
+ function buildFix(context, node) {
26
+ return function fix(fixer) {
27
+ const fixes = [fixer.replaceTextRange(node.range, CANONICAL_IMPORT_TEXT)];
28
+ for (const specifier of node.specifiers) {
29
+ if (specifier.local.name === 'cn')
30
+ continue;
31
+ const [variable] = context.sourceCode.getDeclaredVariables(specifier);
32
+ if (!variable)
33
+ continue;
34
+ for (const reference of variable.references) {
35
+ fixes.push(fixer.replaceTextRange(reference.identifier.range, 'cn'));
36
+ }
37
+ }
38
+ return fixes;
39
+ };
40
+ }
41
+ export default defineRule({
42
+ meta: {
43
+ type: 'problem',
44
+ fixable: 'code',
45
+ docs: {
46
+ description: "Enforce `import cn from 'clsx';` as the only way to import clsx.",
47
+ recommended: false,
48
+ },
49
+ schema: [],
50
+ },
51
+ createOnce(context) {
52
+ return {
53
+ ImportDeclaration(node) {
54
+ if (node.source.value !== 'clsx')
55
+ return;
56
+ if (isCanonicalImport(node))
57
+ return;
58
+ const diagnostic = { node, message: MESSAGE };
59
+ if (!hasNamespaceSpecifier(node) && !hasForeignCnBinding(context, node)) {
60
+ diagnostic.fix = buildFix(context, node);
61
+ }
62
+ context.report(diagnostic);
63
+ },
64
+ };
65
+ },
66
+ });
@@ -0,0 +1,2 @@
1
+ declare const _default: import("@oxlint/plugins").Rule;
2
+ export default _default;
@@ -0,0 +1,73 @@
1
+ import { defineRule } from '@oxlint/plugins';
2
+ // Enforces lowercase kebab-case values for the `data-taco` component-marker
3
+ // attribute: `data-taco="column-header"`, not `data-taco="Select2"`.
4
+ //
5
+ // Deliberately not autofixable: `data-taco` values pair with CSS/DOM selectors
6
+ // (`[data-taco="…"]`) in taco and in consumer apps, so rewriting the value
7
+ // silently breaks those lookups — renames must be coordinated by hand.
8
+ const MESSAGE = 'data-taco values must be lowercase kebab-case (e.g. "column-header").';
9
+ const KEBAB_CASE = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
10
+ function checkValue(context, node, value) {
11
+ if (!KEBAB_CASE.test(value)) {
12
+ context.report({ node, message: MESSAGE });
13
+ }
14
+ }
15
+ // Validates every statically-knowable string the attribute may resolve to.
16
+ // `undefined` / `null` branches are allowed (attribute omitted); genuinely
17
+ // dynamic expressions are skipped.
18
+ function checkExpression(context, node) {
19
+ switch (node.type) {
20
+ case 'Literal':
21
+ if (typeof node.value === 'string')
22
+ checkValue(context, node, node.value);
23
+ return;
24
+ case 'TemplateLiteral': {
25
+ const [quasi] = node.quasis;
26
+ if (node.expressions.length === 0 && quasi !== undefined) {
27
+ checkValue(context, quasi, quasi.value.cooked ?? quasi.value.raw);
28
+ }
29
+ return;
30
+ }
31
+ case 'ConditionalExpression':
32
+ // `data-taco={isGroup ? 'grouped-column-header' : 'column-header'}`
33
+ checkExpression(context, node.consequent);
34
+ checkExpression(context, node.alternate);
35
+ return;
36
+ case 'ParenthesizedExpression':
37
+ checkExpression(context, node.expression);
38
+ return;
39
+ default:
40
+ return;
41
+ }
42
+ }
43
+ export default defineRule({
44
+ meta: {
45
+ type: 'problem',
46
+ docs: {
47
+ description: 'Enforce lowercase kebab-case values for the data-taco attribute.',
48
+ recommended: true,
49
+ },
50
+ schema: [],
51
+ },
52
+ createOnce(context) {
53
+ return {
54
+ JSXAttribute(node) {
55
+ if (node.name.type !== 'JSXIdentifier' || node.name.name !== 'data-taco')
56
+ return;
57
+ if (node.value === null) {
58
+ // bare `data-taco` carries no component name
59
+ context.report({ node, message: MESSAGE });
60
+ return;
61
+ }
62
+ if (node.value.type === 'Literal') {
63
+ if (typeof node.value.value === 'string')
64
+ checkValue(context, node.value, node.value.value);
65
+ return;
66
+ }
67
+ if (node.value.type === 'JSXExpressionContainer' && node.value.expression.type !== 'JSXEmptyExpression') {
68
+ checkExpression(context, node.value.expression);
69
+ }
70
+ },
71
+ };
72
+ },
73
+ });
@@ -0,0 +1,2 @@
1
+ import type { Rule } from '@oxlint/plugins';
2
+ export declare const rules: Record<string, Rule>;
@@ -0,0 +1,30 @@
1
+ import consistentClsxImport from "./consistent-clsx-import/consistent-clsx-import.js";
2
+ import dataTacoKebabCase from "./data-taco-kebab-case/data-taco-kebab-case.js";
3
+ import noComponentMargin from "./no-component-margin/no-component-margin.js";
4
+ import noCrossBoundaryRelativeImports from "./no-cross-boundary-relative-imports/no-cross-boundary-relative-imports.js";
5
+ import noDataTacoAttribute from "./no-data-taco-attribute/no-data-taco-attribute.js";
6
+ import noDisallowedColorClasses from "./no-disallowed-color-classes/no-disallowed-color-classes.js";
7
+ import noDisallowedRadiusClasses from "./no-disallowed-radius-classes/no-disallowed-radius-classes.js";
8
+ import noDisallowedShadowClasses from "./no-disallowed-shadow-classes/no-disallowed-shadow-classes.js";
9
+ import noDisallowedSpacingClasses from "./no-disallowed-spacing-classes/no-disallowed-spacing-classes.js";
10
+ import noDisplayValueKey from "./no-display-value-key/no-display-value-key.js";
11
+ import noLeakedRender from "./no-leaked-render/no-leaked-render.js";
12
+ import noReactUseId from "./no-react-useid/no-react-useid.js";
13
+ import noSeparateSizeClasses from "./no-separate-size-classes/no-separate-size-classes.js";
14
+ import noUnnecessaryTemplateLiteral from "./no-unnecessary-template-literal/no-unnecessary-template-literal.js";
15
+ export const rules = {
16
+ 'consistent-clsx-import': consistentClsxImport,
17
+ 'data-taco-kebab-case': dataTacoKebabCase,
18
+ 'no-component-margin': noComponentMargin,
19
+ 'no-cross-boundary-relative-imports': noCrossBoundaryRelativeImports,
20
+ 'no-data-taco-attribute': noDataTacoAttribute,
21
+ 'no-disallowed-color-classes': noDisallowedColorClasses,
22
+ 'no-disallowed-radius-classes': noDisallowedRadiusClasses,
23
+ 'no-disallowed-shadow-classes': noDisallowedShadowClasses,
24
+ 'no-disallowed-spacing-classes': noDisallowedSpacingClasses,
25
+ 'no-display-value-key': noDisplayValueKey,
26
+ 'no-leaked-render': noLeakedRender,
27
+ 'no-react-useid': noReactUseId,
28
+ 'no-separate-size-classes': noSeparateSizeClasses,
29
+ 'no-unnecessary-template-literal': noUnnecessaryTemplateLiteral,
30
+ };
@@ -0,0 +1,2 @@
1
+ declare const _default: import("@oxlint/plugins").Rule;
2
+ export default _default;
@@ -0,0 +1,93 @@
1
+ import { defineRule } from '@oxlint/plugins';
2
+ import { createTailwindClassSourceVisitors } from "../../lib/visit-tailwind-class-sources.js";
3
+ // Prevents external margins on the root element a component returns. A component's
4
+ // outer spacing belongs to its consumer (gap-*, space-*, or padding on the parent);
5
+ // baking margins into the root makes the component unusable in contexts with
6
+ // different spacing needs.
7
+ //
8
+ // function Badge() { return <span className="mt-4" />; } // ✗
9
+ // function Badge() { return <span className="p-2" />; } // ✓ padding is internal
10
+ // <div className="mt-4"><Badge /></div> // ✓ consumer decides
11
+ const MESSAGE = 'Avoid defining external margins on the root element of a component. Let the consumer control outer spacing (e.g. gap-*, space-*, or padding on the parent).';
12
+ // Margin utilities: m, mx, my, ms, me, mt, mr, mb, ml with a spacing-scale value
13
+ // (digits, px, auto, or arbitrary [...]), allowing variant prefixes (md:, hover:),
14
+ // important (!), and negative (-) markers. The value set is restricted so custom
15
+ // classes that merely start with `m…-` (e.g. `mr-widget`) don't match.
16
+ const MARGIN_TOKEN = /^(?:[\w-]+:)*!?-?m[xytblrse]?-(?:\d|px$|auto$|\[)/;
17
+ function containsMarginToken(value) {
18
+ return value.split(/\s+/).some(token => MARGIN_TOKEN.test(token));
19
+ }
20
+ // Expression wrappers a returned JSX element may sit inside without ceasing to be
21
+ // the component's root: `return cond ? <div/> : null`, `return (<div/>)`, casts.
22
+ const RETURN_PASS_THROUGH = new Set([
23
+ 'ConditionalExpression',
24
+ 'LogicalExpression',
25
+ 'ParenthesizedExpression',
26
+ 'TSAsExpression',
27
+ 'TSNonNullExpression',
28
+ 'TSSatisfiesExpression',
29
+ ]);
30
+ // Whether this JSX element is the root a function returns — either via a return
31
+ // statement or as an arrow function's implicit-return body. Deliberately strict:
32
+ // JSX passed as a call argument (`wrap(<div/>)`) or assigned to a variable is not
33
+ // considered a root, and children of a root fragment are not checked.
34
+ function isComponentRootElement(element) {
35
+ let current = element;
36
+ let parent = current.parent;
37
+ while (parent !== null) {
38
+ if (parent.type === 'ReturnStatement')
39
+ return true;
40
+ if (parent.type === 'ArrowFunctionExpression')
41
+ return parent.body === current;
42
+ if (!RETURN_PASS_THROUGH.has(parent.type))
43
+ return false;
44
+ current = parent;
45
+ parent = current.parent;
46
+ }
47
+ return false;
48
+ }
49
+ // The nearest enclosing `className` JSX attribute, or null when the node is not
50
+ // inside one. Bails at any JSX element boundary so only the attribute's own
51
+ // expression is considered.
52
+ function findClassNameAttribute(node) {
53
+ let current = node.parent;
54
+ while (current !== null) {
55
+ if (current.type === 'JSXAttribute') {
56
+ const isClassName = current.name.type === 'JSXIdentifier' && current.name.name === 'className';
57
+ return isClassName ? current : null;
58
+ }
59
+ if (current.type === 'JSXElement' || current.type === 'JSXFragment' || current.type === 'Program')
60
+ return null;
61
+ current = current.parent;
62
+ }
63
+ return null;
64
+ }
65
+ function check(context, node, value) {
66
+ if (typeof value !== 'string' || !containsMarginToken(value))
67
+ return;
68
+ // Comparison operands (`size === 'm-4'`) and computed keys (`STYLES['m-4']`)
69
+ // are lookups, not applied classes.
70
+ if (node.type === 'Literal' && (node.parent.type === 'BinaryExpression' || node.parent.type === 'MemberExpression'))
71
+ return;
72
+ const attribute = findClassNameAttribute(node);
73
+ if (attribute === null)
74
+ return;
75
+ // JSXAttribute -> JSXOpeningElement -> JSXElement
76
+ const element = attribute.parent.parent;
77
+ if (element === null || !isComponentRootElement(element))
78
+ return;
79
+ context.report({ node, message: MESSAGE });
80
+ }
81
+ export default defineRule({
82
+ meta: {
83
+ type: 'problem',
84
+ docs: {
85
+ description: 'Disallow external margin utilities on the root element a component returns.',
86
+ recommended: true,
87
+ },
88
+ schema: [],
89
+ },
90
+ createOnce(context) {
91
+ return createTailwindClassSourceVisitors(context, check);
92
+ },
93
+ });
@@ -0,0 +1,2 @@
1
+ declare const _default: import("@oxlint/plugins").Rule;
2
+ export default _default;
@@ -0,0 +1,131 @@
1
+ import { defineRule } from '@oxlint/plugins';
2
+ // Relative imports are for staying inside your own module folder; anything that reaches
3
+ // further must go through an alias, so a file's dependencies on the rest of the repo are
4
+ // legible without counting `../` segments — and so moving a folder doesn't rewrite every
5
+ // import in it.
6
+ //
7
+ // A module's boundary is its folder under `src` — one level deep (`src/hooks`, `src/utils`),
8
+ // or two for the container folders that only hold modules (`src/components/Alert`,
9
+ // `src/primitives/Table`, `src/charts/utils`). Relative imports *within* a boundary are
10
+ // untouched, however deep the folder nests. Crossing a boundary is rewritten to `@/…`
11
+ // (package `src`), `@/scripts/…` (the package's own scripts folder) or `~/…` (repo root),
12
+ // matching the tsconfig/vite/vitest/storybook alias setup.
13
+ // Container folders whose direct children are the actual module roots.
14
+ const CONTAINER_FOLDERS = new Set(['components', 'primitives', 'charts']);
15
+ const SRC_SEGMENT = '/src/';
16
+ // Folders outside `src` that the package aliases under `@/` in its tsconfig.
17
+ const PACKAGE_ALIASED_FOLDERS = ['scripts'];
18
+ // Mirrors the `@/* -> ./src/*`, `@/scripts/* -> ./scripts/*` and `~/* -> ../../*` mappings in
19
+ // the package's tsconfig: `~` is the repo root, two levels above a package in `packages/<name>`.
20
+ function layoutOf(filename) {
21
+ const posix = filename.replaceAll('\\', '/');
22
+ const index = posix.lastIndexOf(SRC_SEGMENT);
23
+ if (index === -1)
24
+ return null;
25
+ const packageRoot = posix.slice(0, index);
26
+ return { srcRoot: `${packageRoot}/src`, packageRoot, repoRoot: packageRoot.split('/').slice(0, -2).join('/') };
27
+ }
28
+ // `null` for files sitting directly in `src` (e.g. `src/index.tsx`), which belong to no module.
29
+ function boundaryOf(srcRelativePath) {
30
+ const segments = srcRelativePath.split('/');
31
+ if (segments.length < 2)
32
+ return null;
33
+ const depth = CONTAINER_FOLDERS.has(segments[0] ?? '') && segments.length > 2 ? 2 : 1;
34
+ return segments.slice(0, depth).join('/');
35
+ }
36
+ function resolveSpecifier(fromDirectory, specifier) {
37
+ const segments = fromDirectory.split('/');
38
+ for (const part of specifier.split('/')) {
39
+ if (part === '.' || part === '')
40
+ continue;
41
+ if (part === '..')
42
+ segments.pop();
43
+ else
44
+ segments.push(part);
45
+ }
46
+ return segments.join('/');
47
+ }
48
+ function relativeTo(root, path) {
49
+ return path.startsWith(`${root}/`) ? path.slice(root.length + 1) : null;
50
+ }
51
+ function report(context, source, message, aliased) {
52
+ context.report({
53
+ node: source,
54
+ message,
55
+ ...(aliased === undefined ? {} : { fix: (fixer) => fixer.replaceTextRange(source.range, `'${aliased}'`) }),
56
+ });
57
+ }
58
+ function checkSource(context, source) {
59
+ const specifier = source.value;
60
+ const isRelative = specifier.startsWith('../');
61
+ // `~/` specifiers are checked too: reaching back into your own package through the repo-root
62
+ // alias resolves fine but spells out the package path, so `@/` is always the shorter form.
63
+ if (!isRelative && !specifier.startsWith('~/'))
64
+ return;
65
+ const filename = context.filename.replaceAll('\\', '/');
66
+ const layout = layoutOf(filename);
67
+ if (layout === null)
68
+ return;
69
+ const filePath = relativeTo(layout.srcRoot, filename);
70
+ if (filePath === null)
71
+ return;
72
+ const from = boundaryOf(filePath);
73
+ if (from === null)
74
+ return;
75
+ const target = isRelative
76
+ ? resolveSpecifier(filename.split('/').slice(0, -1).join('/'), specifier)
77
+ : `${layout.repoRoot}/${specifier.slice('~/'.length)}`;
78
+ const preferAlias = (aliased) => report(context, source, isRelative
79
+ ? `Relative import "${specifier}" leaves \`${from}\`. Use the \`${aliased}\` alias instead.`
80
+ : `"${specifier}" points inside this package. Use the \`${aliased}\` alias instead.`, aliased);
81
+ const targetInSrc = relativeTo(layout.srcRoot, target);
82
+ if (targetInSrc !== null) {
83
+ if (isRelative && boundaryOf(targetInSrc) === from)
84
+ return;
85
+ preferAlias(`@/${targetInSrc}`);
86
+ return;
87
+ }
88
+ const targetInPackage = relativeTo(layout.packageRoot, target);
89
+ if (targetInPackage !== null && PACKAGE_ALIASED_FOLDERS.some(folder => targetInPackage.startsWith(`${folder}/`))) {
90
+ preferAlias(`@/${targetInPackage}`);
91
+ return;
92
+ }
93
+ if (!isRelative)
94
+ return;
95
+ const targetInRepo = relativeTo(layout.repoRoot, target);
96
+ if (targetInRepo !== null) {
97
+ report(context, source, `Relative import "${specifier}" leaves the package. Use the \`~/\` alias instead.`, `~/${targetInRepo}`);
98
+ return;
99
+ }
100
+ report(context, source, `Relative import "${specifier}" leaves the repository.`);
101
+ }
102
+ export default defineRule({
103
+ meta: {
104
+ type: 'problem',
105
+ fixable: 'code',
106
+ docs: {
107
+ description: 'Enforce the shortest alias (`@/`, `@/scripts/`, `~/`) for imports that cross a module boundary.',
108
+ recommended: false,
109
+ },
110
+ schema: [],
111
+ },
112
+ createOnce(context) {
113
+ return {
114
+ ImportDeclaration(node) {
115
+ checkSource(context, node.source);
116
+ },
117
+ ExportNamedDeclaration(node) {
118
+ if (node.source)
119
+ checkSource(context, node.source);
120
+ },
121
+ ExportAllDeclaration(node) {
122
+ checkSource(context, node.source);
123
+ },
124
+ ImportExpression(node) {
125
+ if (node.source.type === 'Literal' && typeof node.source.value === 'string') {
126
+ checkSource(context, node.source);
127
+ }
128
+ },
129
+ };
130
+ },
131
+ });
@@ -0,0 +1,2 @@
1
+ declare const _default: import("@oxlint/plugins").Rule;
2
+ export default _default;
@@ -0,0 +1,28 @@
1
+ import { defineRule } from '@oxlint/plugins';
2
+ // Consumer-facing rule: `data-taco` is the taco design system's component-marker
3
+ // namespace, set by taco's own components to identify themselves in the DOM.
4
+ // Application code must not add it — a hand-written `data-taco` masquerades as a
5
+ // taco component to selectors, tests, and tooling that rely on the marker.
6
+ //
7
+ // Not enabled inside taco itself (which legitimately sets the attribute); ships in
8
+ // the `recommended` config for consumer apps.
9
+ const MESSAGE = 'data-taco is reserved for taco design system internals. Use data-testid or an application-specific data-* attribute instead.';
10
+ export default defineRule({
11
+ meta: {
12
+ type: 'problem',
13
+ docs: {
14
+ description: 'Disallow setting the reserved data-taco attribute outside the taco design system.',
15
+ recommended: true,
16
+ },
17
+ schema: [],
18
+ },
19
+ createOnce(context) {
20
+ return {
21
+ JSXAttribute(node) {
22
+ if (node.name.type === 'JSXIdentifier' && node.name.name === 'data-taco') {
23
+ context.report({ node, message: MESSAGE });
24
+ }
25
+ },
26
+ };
27
+ },
28
+ });
@@ -0,0 +1,2 @@
1
+ declare const _default: import("@oxlint/plugins").Rule;
2
+ export default _default;
@@ -0,0 +1,23 @@
1
+ import { defineRule } from '@oxlint/plugins';
2
+ import { createClassPolicyVisitors } from "../../lib/create-class-policy-visitors.js";
3
+ import { checkColorClass } from "../../../policies/color.js";
4
+ // Bans non–design-token color usage in Tailwind classes:
5
+ // 1) Color utilities whose color isn't defined in taco's tailwind.theme.colors.js (e.g. bg-orange-500,
6
+ // text-blue-400, bg-pink — the theme replaces Tailwind's palette, so these generate no CSS).
7
+ // 2) Arbitrary text-[…] and bg-[…] color literals — hex, color functions, named colors
8
+ // (use token utilities instead). Non-color values like bg-[inherit] pass.
9
+ // `grey-*` passes via its alias in tailwind.theme.colors.js — consumers still use that spelling widely.
10
+ // Matching lives in `src/policies/color.ts`.
11
+ export default defineRule({
12
+ meta: {
13
+ type: 'problem',
14
+ docs: {
15
+ description: 'Disallow non–design-token color utilities.',
16
+ recommended: true,
17
+ },
18
+ schema: [],
19
+ },
20
+ createOnce(context) {
21
+ return createClassPolicyVisitors(context, checkColorClass);
22
+ },
23
+ });
@@ -0,0 +1,2 @@
1
+ declare const _default: import("@oxlint/plugins").Rule;
2
+ export default _default;
@@ -0,0 +1,19 @@
1
+ import { defineRule } from '@oxlint/plugins';
2
+ import { createClassPolicyVisitors } from "../../lib/create-class-policy-visitors.js";
3
+ import { checkRadiusClass } from "../../../policies/radius.js";
4
+ // Bans border-radius utilities whose size isn't in taco's theme (`borderRadius` in
5
+ // tailwind.theme.js), with or without a side/corner prefix, and arbitrary rounded-[…] values.
6
+ // Matching lives in `src/policies/radius.ts`.
7
+ export default defineRule({
8
+ meta: {
9
+ type: 'problem',
10
+ docs: {
11
+ description: 'Disallow non–design-token border-radius Tailwind utilities.',
12
+ recommended: true,
13
+ },
14
+ schema: [],
15
+ },
16
+ createOnce(context) {
17
+ return createClassPolicyVisitors(context, checkRadiusClass);
18
+ },
19
+ });
@@ -0,0 +1,2 @@
1
+ declare const _default: import("@oxlint/plugins").Rule;
2
+ export default _default;
@@ -0,0 +1,20 @@
1
+ import { defineRule } from '@oxlint/plugins';
2
+ import { createClassPolicyVisitors } from "../../lib/create-class-policy-visitors.js";
3
+ import { checkShadowClass } from "../../../policies/shadow.js";
4
+ // Bans box-shadow utilities whose size isn't in taco's theme (`boxShadow` in tailwind.theme.js),
5
+ // e.g. shadow-2xl and shadow-inner, and arbitrary shadow-[…] values. Shadow colors
6
+ // (shadow-blue-500) are left to no-disallowed-color-classes.
7
+ // Matching lives in `src/policies/shadow.ts`.
8
+ export default defineRule({
9
+ meta: {
10
+ type: 'problem',
11
+ docs: {
12
+ description: 'Disallow non–design-token box-shadow Tailwind utilities.',
13
+ recommended: true,
14
+ },
15
+ schema: [],
16
+ },
17
+ createOnce(context) {
18
+ return createClassPolicyVisitors(context, checkShadowClass);
19
+ },
20
+ });
@@ -0,0 +1,2 @@
1
+ declare const _default: import("@oxlint/plugins").Rule;
2
+ export default _default;
@@ -0,0 +1,21 @@
1
+ import { defineRule } from '@oxlint/plugins';
2
+ import { createClassPolicyVisitors } from "../../lib/create-class-policy-visitors.js";
3
+ import { checkSpacingClass } from "../../../policies/spacing.js";
4
+ // Bans non–design-token spacing in padding, margin, gap and space-between utilities.
5
+ // Only the taco-tokens spacing scale is allowed (and margin `auto`); arbitrary values
6
+ // (p-[3px]) are banned, matching the radius rule. Look-alikes such as `scroll-mt-5` pass.
7
+ // Matching lives in `src/policies/spacing.ts`.
8
+ export default defineRule({
9
+ meta: {
10
+ type: 'problem',
11
+ docs: {
12
+ description: 'Disallow non–design-token spacing Tailwind utilities.',
13
+ // taco-internal: consumers keep the full Tailwind spacing scale.
14
+ recommended: false,
15
+ },
16
+ schema: [],
17
+ },
18
+ createOnce(context) {
19
+ return createClassPolicyVisitors(context, checkSpacingClass);
20
+ },
21
+ });
@@ -0,0 +1,2 @@
1
+ declare const _default: import("@oxlint/plugins").Rule;
2
+ export default _default;