@economic/taco-rules 2.1.0 → 2.2.0-EC-006789-test-combobox-valuerenderer.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.
- package/README.md +16 -0
- package/dist/oxlint/lib/create-class-policy-visitors.js +1 -1
- package/dist/oxlint/rules/consistent-clsx-import/consistent-clsx-import.js +5 -2
- package/dist/oxlint/rules/data-taco-kebab-case/data-taco-kebab-case.js +6 -3
- package/dist/oxlint/rules/index.js +2 -0
- package/dist/oxlint/rules/no-component-margin/no-component-margin.js +5 -2
- package/dist/oxlint/rules/no-cross-boundary-relative-imports/no-cross-boundary-relative-imports.js +13 -7
- package/dist/oxlint/rules/no-data-taco-attribute/no-data-taco-attribute.js +5 -2
- package/dist/oxlint/rules/no-disallowed-color-classes/no-disallowed-color-classes.js +2 -0
- package/dist/oxlint/rules/no-disallowed-radius-classes/no-disallowed-radius-classes.js +2 -0
- package/dist/oxlint/rules/no-disallowed-shadow-classes/no-disallowed-shadow-classes.js +2 -0
- package/dist/oxlint/rules/no-disallowed-spacing-classes/no-disallowed-spacing-classes.js +2 -0
- package/dist/oxlint/rules/no-display-value-key/no-display-value-key.js +5 -2
- package/dist/oxlint/rules/no-leaked-render/no-leaked-render.js +5 -2
- package/dist/oxlint/rules/no-react-useid/no-react-useid.js +6 -3
- package/dist/oxlint/rules/no-separate-size-classes/no-separate-size-classes.js +7 -4
- package/dist/oxlint/rules/no-template-literal-class-name/no-template-literal-class-name.d.ts +2 -0
- package/dist/oxlint/rules/no-template-literal-class-name/no-template-literal-class-name.js +33 -0
- package/dist/oxlint/rules/no-unnecessary-template-literal/no-unnecessary-template-literal.js +5 -2
- package/dist/oxlint/rules/require-timer-cleanup/require-timer-cleanup.js +9 -4
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -382,6 +382,22 @@ Auto-fixable (`fixable: 'code'`): `oxlint --fix`, the editor's Quick Fix, or
|
|
|
382
382
|
|
|
383
383
|
See https://v3.tailwindcss.com/docs/size.
|
|
384
384
|
|
|
385
|
+
### `taco/no-template-literal-class-name`
|
|
386
|
+
|
|
387
|
+
Flags a JSX `className` whose value is a template literal with `${…}`
|
|
388
|
+
interpolations. Combine classes with `cn` (`clsx`) instead:
|
|
389
|
+
|
|
390
|
+
```tsx
|
|
391
|
+
<div className={`${classNameOne} ${classNameTwo}`} /> // ✗
|
|
392
|
+
<div className={cn(classNameOne, classNameTwo)} /> // ✓
|
|
393
|
+
```
|
|
394
|
+
|
|
395
|
+
Left alone: templates without interpolations (see
|
|
396
|
+
`no-unnecessary-template-literal`), other attributes, and templates that are
|
|
397
|
+
not the direct `className` expression (e.g. nested inside `cn(...)` or a
|
|
398
|
+
ternary). Report-only — there is no auto-fix, since it would need `cn`
|
|
399
|
+
imported.
|
|
400
|
+
|
|
385
401
|
### `taco/no-unnecessary-template-literal`
|
|
386
402
|
|
|
387
403
|
Flags template literals with no `${…}` interpolations — plain strings dressed
|
|
@@ -11,7 +11,7 @@ export function createClassPolicyVisitors(context, check) {
|
|
|
11
11
|
return;
|
|
12
12
|
const [violation] = findViolations(value, check);
|
|
13
13
|
if (violation !== undefined) {
|
|
14
|
-
ctx.report({ node, message: violation.message });
|
|
14
|
+
ctx.report({ node, messageId: 'disallowedClass', data: { message: violation.message } });
|
|
15
15
|
}
|
|
16
16
|
});
|
|
17
17
|
}
|
|
@@ -2,7 +2,6 @@ import { defineRule } from '@oxlint/plugins';
|
|
|
2
2
|
// Enforces a single canonical way of importing clsx: `import cn from 'clsx';`.
|
|
3
3
|
// Disallows the default import under its own name, named imports (`{ clsx }`),
|
|
4
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
5
|
const CANONICAL_IMPORT_TEXT = "import cn from 'clsx';";
|
|
7
6
|
function isCanonicalImport(node) {
|
|
8
7
|
const [specifier, ...rest] = node.specifiers;
|
|
@@ -45,6 +44,10 @@ export default defineRule({
|
|
|
45
44
|
docs: {
|
|
46
45
|
description: "Enforce `import cn from 'clsx';` as the only way to import clsx.",
|
|
47
46
|
recommended: false,
|
|
47
|
+
requiresTypeChecking: false,
|
|
48
|
+
},
|
|
49
|
+
messages: {
|
|
50
|
+
consistentClsxImport: "Import clsx's default export as `cn`: `import cn from 'clsx';`.",
|
|
48
51
|
},
|
|
49
52
|
schema: [],
|
|
50
53
|
},
|
|
@@ -55,7 +58,7 @@ export default defineRule({
|
|
|
55
58
|
return;
|
|
56
59
|
if (isCanonicalImport(node))
|
|
57
60
|
return;
|
|
58
|
-
const diagnostic = { node,
|
|
61
|
+
const diagnostic = { node, messageId: 'consistentClsxImport' };
|
|
59
62
|
if (!hasNamespaceSpecifier(node) && !hasForeignCnBinding(context, node)) {
|
|
60
63
|
diagnostic.fix = buildFix(context, node);
|
|
61
64
|
}
|
|
@@ -5,11 +5,10 @@ import { defineRule } from '@oxlint/plugins';
|
|
|
5
5
|
// Deliberately not autofixable: `data-taco` values pair with CSS/DOM selectors
|
|
6
6
|
// (`[data-taco="…"]`) in taco and in consumer apps, so rewriting the value
|
|
7
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
8
|
const KEBAB_CASE = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
10
9
|
function checkValue(context, node, value) {
|
|
11
10
|
if (!KEBAB_CASE.test(value)) {
|
|
12
|
-
context.report({ node,
|
|
11
|
+
context.report({ node, messageId: 'dataTacoKebabCase' });
|
|
13
12
|
}
|
|
14
13
|
}
|
|
15
14
|
// Validates every statically-knowable string the attribute may resolve to.
|
|
@@ -46,6 +45,10 @@ export default defineRule({
|
|
|
46
45
|
docs: {
|
|
47
46
|
description: 'Enforce lowercase kebab-case values for the data-taco attribute.',
|
|
48
47
|
recommended: true,
|
|
48
|
+
requiresTypeChecking: false,
|
|
49
|
+
},
|
|
50
|
+
messages: {
|
|
51
|
+
dataTacoKebabCase: 'data-taco values must be lowercase kebab-case (e.g. "column-header").',
|
|
49
52
|
},
|
|
50
53
|
schema: [],
|
|
51
54
|
},
|
|
@@ -56,7 +59,7 @@ export default defineRule({
|
|
|
56
59
|
return;
|
|
57
60
|
if (node.value === null) {
|
|
58
61
|
// bare `data-taco` carries no component name
|
|
59
|
-
context.report({ node,
|
|
62
|
+
context.report({ node, messageId: 'dataTacoKebabCase' });
|
|
60
63
|
return;
|
|
61
64
|
}
|
|
62
65
|
if (node.value.type === 'Literal') {
|
|
@@ -11,6 +11,7 @@ import noDisplayValueKey from "./no-display-value-key/no-display-value-key.js";
|
|
|
11
11
|
import noLeakedRender from "./no-leaked-render/no-leaked-render.js";
|
|
12
12
|
import noReactUseId from "./no-react-useid/no-react-useid.js";
|
|
13
13
|
import noSeparateSizeClasses from "./no-separate-size-classes/no-separate-size-classes.js";
|
|
14
|
+
import noTemplateLiteralClassName from "./no-template-literal-class-name/no-template-literal-class-name.js";
|
|
14
15
|
import noUnnecessaryTemplateLiteral from "./no-unnecessary-template-literal/no-unnecessary-template-literal.js";
|
|
15
16
|
import requireTimerCleanup from "./require-timer-cleanup/require-timer-cleanup.js";
|
|
16
17
|
export const rules = {
|
|
@@ -27,6 +28,7 @@ export const rules = {
|
|
|
27
28
|
'no-leaked-render': noLeakedRender,
|
|
28
29
|
'no-react-useid': noReactUseId,
|
|
29
30
|
'no-separate-size-classes': noSeparateSizeClasses,
|
|
31
|
+
'no-template-literal-class-name': noTemplateLiteralClassName,
|
|
30
32
|
'no-unnecessary-template-literal': noUnnecessaryTemplateLiteral,
|
|
31
33
|
'require-timer-cleanup': requireTimerCleanup,
|
|
32
34
|
};
|
|
@@ -8,7 +8,6 @@ import { createTailwindClassSourceVisitors } from "../../lib/visit-tailwind-clas
|
|
|
8
8
|
// function Badge() { return <span className="mt-4" />; } // ✗
|
|
9
9
|
// function Badge() { return <span className="p-2" />; } // ✓ padding is internal
|
|
10
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
11
|
// Margin utilities: m, mx, my, ms, me, mt, mr, mb, ml with a spacing-scale value
|
|
13
12
|
// (digits, px, auto, or arbitrary [...]), allowing variant prefixes (md:, hover:),
|
|
14
13
|
// important (!), and negative (-) markers. The value set is restricted so custom
|
|
@@ -76,7 +75,7 @@ function check(context, node, value) {
|
|
|
76
75
|
const element = attribute.parent.parent;
|
|
77
76
|
if (element === null || !isComponentRootElement(element))
|
|
78
77
|
return;
|
|
79
|
-
context.report({ node,
|
|
78
|
+
context.report({ node, messageId: 'noComponentMargin' });
|
|
80
79
|
}
|
|
81
80
|
export default defineRule({
|
|
82
81
|
meta: {
|
|
@@ -84,6 +83,10 @@ export default defineRule({
|
|
|
84
83
|
docs: {
|
|
85
84
|
description: 'Disallow external margin utilities on the root element a component returns.',
|
|
86
85
|
recommended: true,
|
|
86
|
+
requiresTypeChecking: false,
|
|
87
|
+
},
|
|
88
|
+
messages: {
|
|
89
|
+
noComponentMargin: '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).',
|
|
87
90
|
},
|
|
88
91
|
schema: [],
|
|
89
92
|
},
|
package/dist/oxlint/rules/no-cross-boundary-relative-imports/no-cross-boundary-relative-imports.js
CHANGED
|
@@ -48,10 +48,11 @@ function resolveSpecifier(fromDirectory, specifier) {
|
|
|
48
48
|
function relativeTo(root, path) {
|
|
49
49
|
return path.startsWith(`${root}/`) ? path.slice(root.length + 1) : null;
|
|
50
50
|
}
|
|
51
|
-
function report(context, source,
|
|
51
|
+
function report(context, source, messageId, data, aliased) {
|
|
52
52
|
context.report({
|
|
53
53
|
node: source,
|
|
54
|
-
|
|
54
|
+
messageId,
|
|
55
|
+
data,
|
|
55
56
|
...(aliased === undefined ? {} : { fix: (fixer) => fixer.replaceTextRange(source.range, `'${aliased}'`) }),
|
|
56
57
|
});
|
|
57
58
|
}
|
|
@@ -75,9 +76,7 @@ function checkSource(context, source) {
|
|
|
75
76
|
const target = isRelative
|
|
76
77
|
? resolveSpecifier(filename.split('/').slice(0, -1).join('/'), specifier)
|
|
77
78
|
: `${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);
|
|
79
|
+
const preferAlias = (aliased) => report(context, source, isRelative ? 'leavesBoundary' : 'selfPackageAlias', { specifier, from, aliased }, aliased);
|
|
81
80
|
const targetInSrc = relativeTo(layout.srcRoot, target);
|
|
82
81
|
if (targetInSrc !== null) {
|
|
83
82
|
if (isRelative && boundaryOf(targetInSrc) === from)
|
|
@@ -94,10 +93,10 @@ function checkSource(context, source) {
|
|
|
94
93
|
return;
|
|
95
94
|
const targetInRepo = relativeTo(layout.repoRoot, target);
|
|
96
95
|
if (targetInRepo !== null) {
|
|
97
|
-
report(context, source,
|
|
96
|
+
report(context, source, 'leavesPackage', { specifier }, `~/${targetInRepo}`);
|
|
98
97
|
return;
|
|
99
98
|
}
|
|
100
|
-
report(context, source,
|
|
99
|
+
report(context, source, 'leavesRepository', { specifier });
|
|
101
100
|
}
|
|
102
101
|
export default defineRule({
|
|
103
102
|
meta: {
|
|
@@ -106,6 +105,13 @@ export default defineRule({
|
|
|
106
105
|
docs: {
|
|
107
106
|
description: 'Enforce the shortest alias (`@/`, `@/scripts/`, `~/`) for imports that cross a module boundary.',
|
|
108
107
|
recommended: false,
|
|
108
|
+
requiresTypeChecking: false,
|
|
109
|
+
},
|
|
110
|
+
messages: {
|
|
111
|
+
leavesBoundary: 'Relative import "{{specifier}}" leaves `{{from}}`. Use the `{{aliased}}` alias instead.',
|
|
112
|
+
selfPackageAlias: '"{{specifier}}" points inside this package. Use the `{{aliased}}` alias instead.',
|
|
113
|
+
leavesPackage: 'Relative import "{{specifier}}" leaves the package. Use the `~/` alias instead.',
|
|
114
|
+
leavesRepository: 'Relative import "{{specifier}}" leaves the repository.',
|
|
109
115
|
},
|
|
110
116
|
schema: [],
|
|
111
117
|
},
|
|
@@ -6,13 +6,16 @@ import { defineRule } from '@oxlint/plugins';
|
|
|
6
6
|
//
|
|
7
7
|
// Not enabled inside taco itself (which legitimately sets the attribute); ships in
|
|
8
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
9
|
export default defineRule({
|
|
11
10
|
meta: {
|
|
12
11
|
type: 'problem',
|
|
13
12
|
docs: {
|
|
14
13
|
description: 'Disallow setting the reserved data-taco attribute outside the taco design system.',
|
|
15
14
|
recommended: true,
|
|
15
|
+
requiresTypeChecking: false,
|
|
16
|
+
},
|
|
17
|
+
messages: {
|
|
18
|
+
noDataTacoAttribute: 'data-taco is reserved for taco design system internals. Use data-testid or an application-specific data-* attribute instead.',
|
|
16
19
|
},
|
|
17
20
|
schema: [],
|
|
18
21
|
},
|
|
@@ -20,7 +23,7 @@ export default defineRule({
|
|
|
20
23
|
return {
|
|
21
24
|
JSXAttribute(node) {
|
|
22
25
|
if (node.name.type === 'JSXIdentifier' && node.name.name === 'data-taco') {
|
|
23
|
-
context.report({ node,
|
|
26
|
+
context.report({ node, messageId: 'noDataTacoAttribute' });
|
|
24
27
|
}
|
|
25
28
|
},
|
|
26
29
|
};
|
|
@@ -10,7 +10,9 @@ export default defineRule({
|
|
|
10
10
|
docs: {
|
|
11
11
|
description: 'Disallow non–design-token border-radius Tailwind utilities.',
|
|
12
12
|
recommended: true,
|
|
13
|
+
requiresTypeChecking: false,
|
|
13
14
|
},
|
|
15
|
+
messages: { disallowedClass: '{{message}}' },
|
|
14
16
|
schema: [],
|
|
15
17
|
},
|
|
16
18
|
createOnce(context) {
|
|
@@ -11,7 +11,9 @@ export default defineRule({
|
|
|
11
11
|
docs: {
|
|
12
12
|
description: 'Disallow non–design-token box-shadow Tailwind utilities.',
|
|
13
13
|
recommended: true,
|
|
14
|
+
requiresTypeChecking: false,
|
|
14
15
|
},
|
|
16
|
+
messages: { disallowedClass: '{{message}}' },
|
|
15
17
|
schema: [],
|
|
16
18
|
},
|
|
17
19
|
createOnce(context) {
|
|
@@ -12,7 +12,9 @@ export default defineRule({
|
|
|
12
12
|
description: 'Disallow non–design-token spacing Tailwind utilities.',
|
|
13
13
|
// taco-internal: consumers keep the full Tailwind spacing scale.
|
|
14
14
|
recommended: false,
|
|
15
|
+
requiresTypeChecking: false,
|
|
15
16
|
},
|
|
17
|
+
messages: { disallowedClass: '{{message}}' },
|
|
16
18
|
schema: [],
|
|
17
19
|
},
|
|
18
20
|
createOnce(context) {
|
|
@@ -4,7 +4,6 @@ import { defineRule } from '@oxlint/plugins';
|
|
|
4
4
|
// guarantee — two chart segments labelled "Jan", two rows named "Total" — so React
|
|
5
5
|
// silently reconciles them as the same element. A stable id, or the map index mixed
|
|
6
6
|
// into the key, is what actually makes siblings distinguishable.
|
|
7
|
-
const MESSAGE = "Don't key by a display value — labels/names/titles aren't guaranteed unique across siblings. Use a stable id, or mix in the map index (e.g. `${index}-${item.label}`).";
|
|
8
7
|
const DISPLAY_NAMES = new Set([
|
|
9
8
|
'caption',
|
|
10
9
|
'content',
|
|
@@ -87,6 +86,10 @@ export default defineRule({
|
|
|
87
86
|
docs: {
|
|
88
87
|
description: 'Disallow React keys derived solely from display values such as labels, names or titles.',
|
|
89
88
|
recommended: false,
|
|
89
|
+
requiresTypeChecking: false,
|
|
90
|
+
},
|
|
91
|
+
messages: {
|
|
92
|
+
noDisplayValueKey: "Don't key by a display value — labels/names/titles aren't guaranteed unique across siblings. Use a stable id, or mix in the map index (e.g. `${index}-${item.label}`).",
|
|
90
93
|
},
|
|
91
94
|
schema: [],
|
|
92
95
|
},
|
|
@@ -107,7 +110,7 @@ export default defineRule({
|
|
|
107
110
|
return categories.includes('display');
|
|
108
111
|
});
|
|
109
112
|
if (unsafe)
|
|
110
|
-
context.report({ node,
|
|
113
|
+
context.report({ node, messageId: 'noDisplayValueKey' });
|
|
111
114
|
},
|
|
112
115
|
};
|
|
113
116
|
},
|
|
@@ -7,7 +7,6 @@ import { defineRule } from '@oxlint/plugins';
|
|
|
7
7
|
// only expressions that are numeric by construction are flagged — `.length`
|
|
8
8
|
// access, numeric literals, arithmetic and bitwise operators. A bare identifier
|
|
9
9
|
// that merely has a number type cannot be detected without type information.
|
|
10
|
-
const MESSAGE = 'Potential leaked value that might cause unintentionally rendered values or rendering crashes. Coerce to boolean (e.g. `items.length > 0`) or use a ternary.';
|
|
11
10
|
// `+` is excluded: it may be string concatenation.
|
|
12
11
|
const NUMERIC_BINARY_OPERATORS = new Set(['-', '*', '/', '%', '**', '&', '|', '^', '<<', '>>', '>>>']);
|
|
13
12
|
const NUMERIC_UNARY_OPERATORS = new Set(['-', '+', '~']);
|
|
@@ -49,7 +48,7 @@ function checkConditions(context, node) {
|
|
|
49
48
|
return;
|
|
50
49
|
}
|
|
51
50
|
if (isNumericByConstruction(node)) {
|
|
52
|
-
context.report({ node,
|
|
51
|
+
context.report({ node, messageId: 'noLeakedRender' });
|
|
53
52
|
}
|
|
54
53
|
}
|
|
55
54
|
export default defineRule({
|
|
@@ -58,6 +57,10 @@ export default defineRule({
|
|
|
58
57
|
docs: {
|
|
59
58
|
description: 'Prevent problematic leaked values from being rendered in JSX.',
|
|
60
59
|
recommended: true,
|
|
60
|
+
requiresTypeChecking: false,
|
|
61
|
+
},
|
|
62
|
+
messages: {
|
|
63
|
+
noLeakedRender: 'Potential leaked value that might cause unintentionally rendered values or rendering crashes. Coerce to boolean (e.g. `items.length > 0`) or use a ternary.',
|
|
61
64
|
},
|
|
62
65
|
schema: [],
|
|
63
66
|
},
|
|
@@ -4,7 +4,6 @@ import { defineRule } from '@oxlint/plugins';
|
|
|
4
4
|
// elsewhere. Covers both the named import (`import { useId } from 'react'`) and
|
|
5
5
|
// member access through any local binding of the react module (`React.useId()`),
|
|
6
6
|
// without flagging react imports that never touch useId.
|
|
7
|
-
const MESSAGE = "Use `useId` from '@/hooks/useId' instead, which supports a native id fallback and a prefix.";
|
|
8
7
|
function isUseIdImportName(imported) {
|
|
9
8
|
return imported.type === 'Identifier' ? imported.name === 'useId' : imported.value === 'useId';
|
|
10
9
|
}
|
|
@@ -19,6 +18,10 @@ export default defineRule({
|
|
|
19
18
|
docs: {
|
|
20
19
|
description: "Disallow React's useId in favour of `useId` from '@/hooks/useId'.",
|
|
21
20
|
recommended: false,
|
|
21
|
+
requiresTypeChecking: false,
|
|
22
|
+
},
|
|
23
|
+
messages: {
|
|
24
|
+
noReactUseId: "Use `useId` from '@/hooks/useId' instead, which supports a native id fallback and a prefix.",
|
|
22
25
|
},
|
|
23
26
|
schema: [],
|
|
24
27
|
},
|
|
@@ -36,7 +39,7 @@ export default defineRule({
|
|
|
36
39
|
for (const specifier of node.specifiers) {
|
|
37
40
|
if (specifier.type === 'ImportSpecifier') {
|
|
38
41
|
if (isUseIdImportName(specifier.imported)) {
|
|
39
|
-
context.report({ node: specifier,
|
|
42
|
+
context.report({ node: specifier, messageId: 'noReactUseId' });
|
|
40
43
|
}
|
|
41
44
|
}
|
|
42
45
|
else {
|
|
@@ -49,7 +52,7 @@ export default defineRule({
|
|
|
49
52
|
return;
|
|
50
53
|
if (node.object.type !== 'Identifier' || !reactBindings.has(node.object.name))
|
|
51
54
|
return;
|
|
52
|
-
context.report({ node,
|
|
55
|
+
context.report({ node, messageId: 'noReactUseId' });
|
|
53
56
|
},
|
|
54
57
|
};
|
|
55
58
|
},
|
|
@@ -14,7 +14,6 @@ import { createTailwindClassSourceVisitors } from "../../lib/visit-tailwind-clas
|
|
|
14
14
|
const WIDTH_HEIGHT = /^((?:[\w-]+:)*)(!?)(w|h)-(.+)$/;
|
|
15
15
|
// Viewport-relative values differ per axis, so there is no size-* equivalent.
|
|
16
16
|
const NO_SIZE_EQUIVALENT = /screen|^\d*(?:v[wh]|[sld]v[wh])$/;
|
|
17
|
-
const MESSAGE = 'Separate equal width and height utilities. Use the combined size-* utility instead (e.g. size-5).';
|
|
18
17
|
function tokenize(chunk) {
|
|
19
18
|
const tokens = [];
|
|
20
19
|
const re = /\S+/g;
|
|
@@ -130,14 +129,13 @@ function check(context, node, value) {
|
|
|
130
129
|
return;
|
|
131
130
|
context.report({
|
|
132
131
|
node,
|
|
133
|
-
|
|
132
|
+
messageId: 'separateSizeClasses',
|
|
134
133
|
fix: fixer => buildFixes(fixer, pairs),
|
|
135
134
|
});
|
|
136
135
|
}
|
|
137
136
|
// Class-combining callees whose string arguments are joined at runtime, so a
|
|
138
137
|
// w-/h- pair may be split across arguments: cn('foo w-5', 'bar h-5').
|
|
139
138
|
const CLASS_FN_CALLEES = new Set(['cn', 'clsx']);
|
|
140
|
-
const CROSS_ARG_MESSAGE = 'Separate equal width and height utilities split across arguments. Use the combined size-* utility instead (e.g. size-5).';
|
|
141
139
|
function isStringLiteralArgument(node) {
|
|
142
140
|
return node.type === 'Literal' && typeof node.value === 'string';
|
|
143
141
|
}
|
|
@@ -193,7 +191,7 @@ function checkCallArguments(context, node) {
|
|
|
193
191
|
return;
|
|
194
192
|
context.report({
|
|
195
193
|
node,
|
|
196
|
-
|
|
194
|
+
messageId: 'separateSizeClassesAcrossArguments',
|
|
197
195
|
fix: fixer => buildFixes(fixer, pairs),
|
|
198
196
|
});
|
|
199
197
|
}
|
|
@@ -204,6 +202,11 @@ export default defineRule({
|
|
|
204
202
|
docs: {
|
|
205
203
|
description: 'Disallow separate equal width/height Tailwind utilities in favour of size-*.',
|
|
206
204
|
recommended: false,
|
|
205
|
+
requiresTypeChecking: false,
|
|
206
|
+
},
|
|
207
|
+
messages: {
|
|
208
|
+
separateSizeClasses: 'Separate equal width and height utilities. Use the combined size-* utility instead (e.g. size-5).',
|
|
209
|
+
separateSizeClassesAcrossArguments: 'Separate equal width and height utilities split across arguments. Use the combined size-* utility instead (e.g. size-5).',
|
|
207
210
|
},
|
|
208
211
|
schema: [],
|
|
209
212
|
},
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { defineRule } from '@oxlint/plugins';
|
|
2
|
+
// Report-only: a fix would need `cn` imported and the template's static text split
|
|
3
|
+
// into arguments, and neither can be done safely without knowing the file's imports.
|
|
4
|
+
export default defineRule({
|
|
5
|
+
meta: {
|
|
6
|
+
type: 'problem',
|
|
7
|
+
docs: {
|
|
8
|
+
description: 'Disallow template literals with interpolations in `className` in favour of `cn`/`clsx`.',
|
|
9
|
+
recommended: true,
|
|
10
|
+
requiresTypeChecking: false,
|
|
11
|
+
},
|
|
12
|
+
messages: {
|
|
13
|
+
noTemplateLiteralClassNames: 'Do not build `className` with a template literal — combine classes with `cn(...)` instead.',
|
|
14
|
+
},
|
|
15
|
+
schema: [],
|
|
16
|
+
},
|
|
17
|
+
createOnce(context) {
|
|
18
|
+
return {
|
|
19
|
+
JSXAttribute(node) {
|
|
20
|
+
if (node.name.type !== 'JSXIdentifier' || node.name.name !== 'className')
|
|
21
|
+
return;
|
|
22
|
+
if (node.value?.type !== 'JSXExpressionContainer')
|
|
23
|
+
return;
|
|
24
|
+
const { expression } = node.value;
|
|
25
|
+
if (expression.type !== 'TemplateLiteral')
|
|
26
|
+
return;
|
|
27
|
+
if (expression.expressions.length === 0)
|
|
28
|
+
return;
|
|
29
|
+
context.report({ node: expression, messageId: 'noTemplateLiteralClassNames' });
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
},
|
|
33
|
+
});
|
package/dist/oxlint/rules/no-unnecessary-template-literal/no-unnecessary-template-literal.js
CHANGED
|
@@ -8,7 +8,6 @@ import { defineRule } from '@oxlint/plugins';
|
|
|
8
8
|
// - multiline templates (backticks are the cleanest multiline syntax)
|
|
9
9
|
// - content containing BOTH quote styles — any quoted form would need escaping,
|
|
10
10
|
// so backticks remain the cleanest way to write it
|
|
11
|
-
const MESSAGE = 'Template literal has no dynamic parts — use a regular string literal instead.';
|
|
12
11
|
// Rebuild the string from the cooked value rather than the raw text so existing
|
|
13
12
|
// escape sequences (\`, \\, …) are regenerated correctly for the new quote
|
|
14
13
|
// style instead of being copied through. Content with both quote styles never
|
|
@@ -31,6 +30,10 @@ export default defineRule({
|
|
|
31
30
|
docs: {
|
|
32
31
|
description: 'Disallow template literals without dynamic parts in favour of regular string literals.',
|
|
33
32
|
recommended: false,
|
|
33
|
+
requiresTypeChecking: false,
|
|
34
|
+
},
|
|
35
|
+
messages: {
|
|
36
|
+
noUnnecessaryTemplateLiteral: 'Template literal has no dynamic parts — use a regular string literal instead.',
|
|
34
37
|
},
|
|
35
38
|
schema: [],
|
|
36
39
|
},
|
|
@@ -54,7 +57,7 @@ export default defineRule({
|
|
|
54
57
|
return;
|
|
55
58
|
context.report({
|
|
56
59
|
node,
|
|
57
|
-
|
|
60
|
+
messageId: 'noUnnecessaryTemplateLiteral',
|
|
58
61
|
fix: fixer => fixer.replaceTextRange(node.range, requote(cooked)),
|
|
59
62
|
});
|
|
60
63
|
},
|
|
@@ -21,8 +21,6 @@ const TIMER_TO_CLEAR = new Map([
|
|
|
21
21
|
]);
|
|
22
22
|
const CLEAR_NAMES = new Set(TIMER_TO_CLEAR.values());
|
|
23
23
|
const NESTED_FUNCTION_TYPES = new Set(['ArrowFunctionExpression', 'FunctionExpression', 'FunctionDeclaration']);
|
|
24
|
-
const REASSIGNED_HANDLE_MESSAGE = (handle, timerName) => `\`${handle}\` is reassigned to another \`${timerName}\` before this one is cleared; the cleanup only clears the last timer stored in it.`;
|
|
25
|
-
const UNCLEARED_TIMER_MESSAGE = (timerName, clearName) => `\`${timerName}\` started in an effect must be stored in a handle and cleared with \`${clearName}\` in the effect's cleanup function.`;
|
|
26
24
|
function isNode(value) {
|
|
27
25
|
return typeof value === 'object' && value !== null && typeof value.type === 'string';
|
|
28
26
|
}
|
|
@@ -310,7 +308,8 @@ function checkEffect(context, effectCallback) {
|
|
|
310
308
|
if (previous && !inExclusiveBranches(previous, event)) {
|
|
311
309
|
context.report({
|
|
312
310
|
node: previous.call,
|
|
313
|
-
|
|
311
|
+
messageId: 'reassignedHandle',
|
|
312
|
+
data: { handle: event.handle, timerName: event.timerName },
|
|
314
313
|
});
|
|
315
314
|
}
|
|
316
315
|
outstanding.set(event.handle, event);
|
|
@@ -326,7 +325,8 @@ function checkEffect(context, effectCallback) {
|
|
|
326
325
|
if (!cleared) {
|
|
327
326
|
context.report({
|
|
328
327
|
node: call,
|
|
329
|
-
|
|
328
|
+
messageId: 'unclearedTimer',
|
|
329
|
+
data: { timerName, clearName },
|
|
330
330
|
});
|
|
331
331
|
}
|
|
332
332
|
}
|
|
@@ -337,6 +337,11 @@ export default defineRule({
|
|
|
337
337
|
docs: {
|
|
338
338
|
description: 'Require timers and animation frames started in useEffect/useLayoutEffect to be cleared in the cleanup function.',
|
|
339
339
|
recommended: true,
|
|
340
|
+
requiresTypeChecking: false,
|
|
341
|
+
},
|
|
342
|
+
messages: {
|
|
343
|
+
reassignedHandle: '`{{handle}}` is reassigned to another `{{timerName}}` before this one is cleared; the cleanup only clears the last timer stored in it.',
|
|
344
|
+
unclearedTimer: "`{{timerName}}` started in an effect must be stored in a handle and cleared with `{{clearName}}` in the effect's cleanup function.",
|
|
340
345
|
},
|
|
341
346
|
schema: [
|
|
342
347
|
{
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@economic/taco-rules",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.0-EC-006789-test-combobox-valuerenderer.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -35,13 +35,13 @@
|
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@economic/taco-tokens": "^4.0.0",
|
|
38
|
-
"@oxlint/plugins": "^1.
|
|
38
|
+
"@oxlint/plugins": "^1.94.0",
|
|
39
39
|
"postcss-value-parser": "^4.2.0"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
42
|
"@economic/taco": "*",
|
|
43
43
|
"eslint": "^9.0.0 || ^10.0.0",
|
|
44
|
-
"oxlint": "^1.
|
|
44
|
+
"oxlint": "^1.94.0",
|
|
45
45
|
"stylelint": "^17.16.0",
|
|
46
46
|
"tailwindcss": "^3.4.19"
|
|
47
47
|
},
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"postcss": "^8.5.33",
|
|
63
63
|
"stylelint": "^17.16.0",
|
|
64
64
|
"typescript": "^5.9.3",
|
|
65
|
-
"vitest": "^
|
|
65
|
+
"vitest": "^5.1.1"
|
|
66
66
|
},
|
|
67
|
-
"gitHead": "
|
|
67
|
+
"gitHead": "496bb0b45a63fad69b10561532c5c801e964c23b"
|
|
68
68
|
}
|