@tenphi/eslint-plugin-tasty 0.4.1 → 0.4.2
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 +5 -10
- package/dist/configs.js +5 -5
- package/dist/configs.js.map +1 -1
- package/dist/index.js +0 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/rules/no-duplicate-state.js +0 -52
- package/dist/rules/no-duplicate-state.js.map +0 -1
package/README.md
CHANGED
|
@@ -86,32 +86,27 @@ export default {
|
|
|
86
86
|
| `tasty/valid-sub-element` | error | Sub-element values must be style objects |
|
|
87
87
|
| `tasty/valid-directional-modifier` | error | Directional modifiers on wrong properties |
|
|
88
88
|
| `tasty/valid-radius-shape` | error | Unknown radius shape keywords |
|
|
89
|
+
| `tasty/valid-preset` | error | Unknown preset names |
|
|
90
|
+
| `tasty/valid-recipe` | error | Unknown recipe names |
|
|
91
|
+
| `tasty/valid-transition` | warn | Unknown transition property names |
|
|
89
92
|
| `tasty/no-nested-selector` | warn | `&`-prefixed nested selectors (use sub-elements) |
|
|
90
93
|
| `tasty/static-no-dynamic-values` | error | Dynamic values in `tastyStatic()` |
|
|
91
94
|
| `tasty/static-valid-selector` | error | Invalid selector in `tastyStatic(selector, ...)` |
|
|
95
|
+
| `tasty/require-default-state` | error | Missing default (`''`) key in state mappings (skipped for extending calls) |
|
|
92
96
|
|
|
93
97
|
### Strict (includes all recommended rules)
|
|
94
98
|
|
|
95
99
|
| Rule | Severity | Description |
|
|
96
100
|
|------|----------|-------------|
|
|
97
101
|
| `tasty/prefer-shorthand-property` | warn | Use tasty shorthand over native CSS |
|
|
98
|
-
| `tasty/valid-preset` | error | Unknown preset names |
|
|
99
|
-
| `tasty/valid-recipe` | error | Unknown recipe names |
|
|
100
|
-
| `tasty/valid-transition` | warn | Unknown transition names |
|
|
101
102
|
| `tasty/valid-custom-property` | warn | Unknown `$name` custom properties |
|
|
103
|
+
| `tasty/valid-state-definition` | warn | Invalid state definition values in `configure()` or `tasty.config` |
|
|
102
104
|
| `tasty/no-unknown-state-alias` | warn | Unknown `@name` state aliases |
|
|
103
|
-
| `tasty/no-duplicate-state` | warn | Duplicate state keys in mappings |
|
|
104
105
|
| `tasty/no-styles-prop` | warn | Direct `styles` prop usage |
|
|
105
106
|
| `tasty/no-raw-color-values` | warn | Raw hex/rgb instead of tokens |
|
|
106
107
|
| `tasty/consistent-token-usage` | warn | Raw px values when tokens exist |
|
|
107
108
|
| `tasty/no-runtime-styles-mutation` | warn | Dynamic values in style objects |
|
|
108
109
|
|
|
109
|
-
### Off by Default
|
|
110
|
-
|
|
111
|
-
| Rule | Description |
|
|
112
|
-
|------|-------------|
|
|
113
|
-
| `tasty/require-default-state` | Missing `''` key in state mappings |
|
|
114
|
-
|
|
115
110
|
## License
|
|
116
111
|
|
|
117
112
|
MIT
|
package/dist/configs.js
CHANGED
|
@@ -14,17 +14,17 @@ const recommended = {
|
|
|
14
14
|
"tasty/valid-radius-shape": "error",
|
|
15
15
|
"tasty/no-nested-selector": "warn",
|
|
16
16
|
"tasty/static-no-dynamic-values": "error",
|
|
17
|
-
"tasty/static-valid-selector": "error"
|
|
17
|
+
"tasty/static-valid-selector": "error",
|
|
18
|
+
"tasty/valid-preset": "error",
|
|
19
|
+
"tasty/valid-recipe": "error",
|
|
20
|
+
"tasty/valid-transition": "warn",
|
|
21
|
+
"tasty/require-default-state": "error"
|
|
18
22
|
};
|
|
19
23
|
const strict = {
|
|
20
24
|
...recommended,
|
|
21
25
|
"tasty/prefer-shorthand-property": "warn",
|
|
22
|
-
"tasty/valid-preset": "error",
|
|
23
|
-
"tasty/valid-recipe": "error",
|
|
24
|
-
"tasty/valid-transition": "warn",
|
|
25
26
|
"tasty/valid-custom-property": "warn",
|
|
26
27
|
"tasty/no-unknown-state-alias": "warn",
|
|
27
|
-
"tasty/no-duplicate-state": "warn",
|
|
28
28
|
"tasty/no-styles-prop": "warn",
|
|
29
29
|
"tasty/no-raw-color-values": "warn",
|
|
30
30
|
"tasty/consistent-token-usage": "warn",
|
package/dist/configs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configs.js","names":[],"sources":["../src/configs.ts"],"sourcesContent":["import type { TSESLint } from '@typescript-eslint/utils';\n\nexport const recommended: TSESLint.SharedConfig.RulesRecord = {\n 'tasty/known-property': 'warn',\n 'tasty/valid-value': 'error',\n 'tasty/valid-color-token': 'error',\n 'tasty/valid-custom-unit': 'error',\n 'tasty/valid-boolean-property': 'error',\n 'tasty/valid-state-key': 'error',\n 'tasty/valid-styles-structure': 'error',\n 'tasty/no-nested-state-map': 'error',\n 'tasty/no-important': 'error',\n 'tasty/valid-sub-element': 'error',\n 'tasty/valid-directional-modifier': 'error',\n 'tasty/valid-radius-shape': 'error',\n 'tasty/no-nested-selector': 'warn',\n 'tasty/static-no-dynamic-values': 'error',\n 'tasty/static-valid-selector': 'error',\n
|
|
1
|
+
{"version":3,"file":"configs.js","names":[],"sources":["../src/configs.ts"],"sourcesContent":["import type { TSESLint } from '@typescript-eslint/utils';\n\nexport const recommended: TSESLint.SharedConfig.RulesRecord = {\n 'tasty/known-property': 'warn',\n 'tasty/valid-value': 'error',\n 'tasty/valid-color-token': 'error',\n 'tasty/valid-custom-unit': 'error',\n 'tasty/valid-boolean-property': 'error',\n 'tasty/valid-state-key': 'error',\n 'tasty/valid-styles-structure': 'error',\n 'tasty/no-nested-state-map': 'error',\n 'tasty/no-important': 'error',\n 'tasty/valid-sub-element': 'error',\n 'tasty/valid-directional-modifier': 'error',\n 'tasty/valid-radius-shape': 'error',\n 'tasty/no-nested-selector': 'warn',\n 'tasty/static-no-dynamic-values': 'error',\n 'tasty/static-valid-selector': 'error',\n 'tasty/valid-preset': 'error',\n 'tasty/valid-recipe': 'error',\n 'tasty/valid-transition': 'warn',\n 'tasty/require-default-state': 'error',\n};\n\nexport const strict: TSESLint.SharedConfig.RulesRecord = {\n ...recommended,\n 'tasty/prefer-shorthand-property': 'warn',\n 'tasty/valid-custom-property': 'warn',\n 'tasty/no-unknown-state-alias': 'warn',\n 'tasty/no-styles-prop': 'warn',\n 'tasty/no-raw-color-values': 'warn',\n 'tasty/consistent-token-usage': 'warn',\n 'tasty/no-runtime-styles-mutation': 'warn',\n 'tasty/valid-state-definition': 'warn',\n};\n"],"mappings":";AAEA,MAAa,cAAiD;CAC5D,wBAAwB;CACxB,qBAAqB;CACrB,2BAA2B;CAC3B,2BAA2B;CAC3B,gCAAgC;CAChC,yBAAyB;CACzB,gCAAgC;CAChC,6BAA6B;CAC7B,sBAAsB;CACtB,2BAA2B;CAC3B,oCAAoC;CACpC,4BAA4B;CAC5B,4BAA4B;CAC5B,kCAAkC;CAClC,+BAA+B;CAC/B,sBAAsB;CACtB,sBAAsB;CACtB,0BAA0B;CAC1B,+BAA+B;CAChC;AAED,MAAa,SAA4C;CACvD,GAAG;CACH,mCAAmC;CACnC,+BAA+B;CAC/B,gCAAgC;CAChC,wBAAwB;CACxB,6BAA6B;CAC7B,gCAAgC;CAChC,oCAAoC;CACpC,gCAAgC;CACjC"}
|
package/dist/index.js
CHANGED
|
@@ -19,7 +19,6 @@ import static_valid_selector_default from "./rules/static-valid-selector.js";
|
|
|
19
19
|
import prefer_shorthand_property_default from "./rules/prefer-shorthand-property.js";
|
|
20
20
|
import valid_transition_default from "./rules/valid-transition.js";
|
|
21
21
|
import require_default_state_default from "./rules/require-default-state.js";
|
|
22
|
-
import no_duplicate_state_default from "./rules/no-duplicate-state.js";
|
|
23
22
|
import no_unknown_state_alias_default from "./rules/no-unknown-state-alias.js";
|
|
24
23
|
import no_raw_color_values_default from "./rules/no-raw-color-values.js";
|
|
25
24
|
import no_styles_prop_default from "./rules/no-styles-prop.js";
|
|
@@ -56,7 +55,6 @@ const plugin = {
|
|
|
56
55
|
"prefer-shorthand-property": prefer_shorthand_property_default,
|
|
57
56
|
"valid-transition": valid_transition_default,
|
|
58
57
|
"require-default-state": require_default_state_default,
|
|
59
|
-
"no-duplicate-state": no_duplicate_state_default,
|
|
60
58
|
"no-unknown-state-alias": no_unknown_state_alias_default,
|
|
61
59
|
"no-raw-color-values": no_raw_color_values_default,
|
|
62
60
|
"no-styles-prop": no_styles_prop_default,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["rules.knownProperty","rules.validValue","rules.validColorToken","rules.validCustomUnit","rules.validStateKey","rules.validStylesStructure","rules.noNestedSelector","rules.validCustomProperty","rules.validPreset","rules.validRecipe","rules.validBooleanProperty","rules.validDirectionalModifier","rules.validRadiusShape","rules.noImportant","rules.validSubElement","rules.noNestedStateMap","rules.staticNoDynamicValues","rules.staticValidSelector","rules.preferShorthandProperty","rules.validTransition","rules.requireDefaultState","rules.
|
|
1
|
+
{"version":3,"file":"index.js","names":["rules.knownProperty","rules.validValue","rules.validColorToken","rules.validCustomUnit","rules.validStateKey","rules.validStylesStructure","rules.noNestedSelector","rules.validCustomProperty","rules.validPreset","rules.validRecipe","rules.validBooleanProperty","rules.validDirectionalModifier","rules.validRadiusShape","rules.noImportant","rules.validSubElement","rules.noNestedStateMap","rules.staticNoDynamicValues","rules.staticValidSelector","rules.preferShorthandProperty","rules.validTransition","rules.requireDefaultState","rules.noUnknownStateAlias","rules.noRawColorValues","rules.noStylesProp","rules.consistentTokenUsage","rules.noRuntimeStylesMutation","rules.validStateDefinition"],"sources":["../src/index.ts"],"sourcesContent":["import type { TSESLint } from '@typescript-eslint/utils';\nimport * as rules from './rules/index.js';\nimport { recommended, strict } from './configs.js';\n\nconst ruleMap: Record<string, TSESLint.RuleModule<string, unknown[]>> = {\n 'known-property': rules.knownProperty,\n 'valid-value': rules.validValue,\n 'valid-color-token': rules.validColorToken,\n 'valid-custom-unit': rules.validCustomUnit,\n 'valid-state-key': rules.validStateKey,\n 'valid-styles-structure': rules.validStylesStructure,\n 'no-nested-selector': rules.noNestedSelector,\n 'valid-custom-property': rules.validCustomProperty,\n 'valid-preset': rules.validPreset,\n 'valid-recipe': rules.validRecipe,\n 'valid-boolean-property': rules.validBooleanProperty,\n 'valid-directional-modifier': rules.validDirectionalModifier,\n 'valid-radius-shape': rules.validRadiusShape,\n 'no-important': rules.noImportant,\n 'valid-sub-element': rules.validSubElement,\n 'no-nested-state-map': rules.noNestedStateMap,\n 'static-no-dynamic-values': rules.staticNoDynamicValues,\n 'static-valid-selector': rules.staticValidSelector,\n 'prefer-shorthand-property': rules.preferShorthandProperty,\n 'valid-transition': rules.validTransition,\n 'require-default-state': rules.requireDefaultState,\n 'no-unknown-state-alias': rules.noUnknownStateAlias,\n 'no-raw-color-values': rules.noRawColorValues,\n 'no-styles-prop': rules.noStylesProp,\n 'consistent-token-usage': rules.consistentTokenUsage,\n 'no-runtime-styles-mutation': rules.noRuntimeStylesMutation,\n 'valid-state-definition': rules.validStateDefinition,\n};\n\nconst plugin = {\n meta: {\n name: '@tenphi/eslint-plugin-tasty',\n version: '0.1.0',\n },\n rules: ruleMap,\n configs: {\n recommended: {\n plugins: {\n get tasty() {\n return plugin;\n },\n },\n rules: recommended,\n },\n strict: {\n plugins: {\n get tasty() {\n return plugin;\n },\n },\n rules: strict,\n },\n },\n} satisfies TSESLint.FlatConfig.Plugin & {\n configs: Record<string, TSESLint.FlatConfig.Config>;\n};\n\nexport default plugin;\n\nexport { recommended, strict } from './configs.js';\nexport type { TastyValidationConfig, ResolvedConfig } from './types.js';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCA,MAAM,SAAS;CACb,MAAM;EACJ,MAAM;EACN,SAAS;EACV;CACD,OAnCsE;EACtE,kBAAkBA;EAClB,eAAeC;EACf,qBAAqBC;EACrB,qBAAqBC;EACrB,mBAAmBC;EACnB,0BAA0BC;EAC1B,sBAAsBC;EACtB,yBAAyBC;EACzB,gBAAgBC;EAChB,gBAAgBC;EAChB,0BAA0BC;EAC1B,8BAA8BC;EAC9B,sBAAsBC;EACtB,gBAAgBC;EAChB,qBAAqBC;EACrB,uBAAuBC;EACvB,4BAA4BC;EAC5B,yBAAyBC;EACzB,6BAA6BC;EAC7B,oBAAoBC;EACpB,yBAAyBC;EACzB,0BAA0BC;EAC1B,uBAAuBC;EACvB,kBAAkBC;EAClB,0BAA0BC;EAC1B,8BAA8BC;EAC9B,0BAA0BC;EAC3B;CAQC,SAAS;EACP,aAAa;GACX,SAAS,EACP,IAAI,QAAQ;AACV,WAAO;MAEV;GACD,OAAO;GACR;EACD,QAAQ;GACN,SAAS,EACP,IAAI,QAAQ;AACV,WAAO;MAEV;GACD,OAAO;GACR;EACF;CACF"}
|
package/package.json
CHANGED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { createRule } from "../create-rule.js";
|
|
2
|
-
import { getKeyName, getStringValue } from "../utils.js";
|
|
3
|
-
import { TastyContext, styleObjectListeners } from "../context.js";
|
|
4
|
-
|
|
5
|
-
//#region src/rules/no-duplicate-state.ts
|
|
6
|
-
var no_duplicate_state_default = createRule({
|
|
7
|
-
name: "no-duplicate-state",
|
|
8
|
-
meta: {
|
|
9
|
-
type: "suggestion",
|
|
10
|
-
docs: { description: "Warn when the same state key appears more than once in a style mapping" },
|
|
11
|
-
messages: { duplicateState: "Duplicate state key '{{key}}'." },
|
|
12
|
-
schema: []
|
|
13
|
-
},
|
|
14
|
-
defaultOptions: [],
|
|
15
|
-
create(context) {
|
|
16
|
-
const ctx = new TastyContext(context);
|
|
17
|
-
function checkDuplicates(obj) {
|
|
18
|
-
const seen = /* @__PURE__ */ new Map();
|
|
19
|
-
for (const prop of obj.properties) {
|
|
20
|
-
if (prop.type !== "Property") continue;
|
|
21
|
-
const key = !prop.computed ? getKeyName(prop.key) : getStringValue(prop.key);
|
|
22
|
-
if (key === null) continue;
|
|
23
|
-
if (seen.has(key)) context.report({
|
|
24
|
-
node: prop.key,
|
|
25
|
-
messageId: "duplicateState",
|
|
26
|
-
data: { key }
|
|
27
|
-
});
|
|
28
|
-
else seen.set(key, prop.key);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
function handleStyleObject(node) {
|
|
32
|
-
if (!ctx.isStyleObject(node)) return;
|
|
33
|
-
for (const prop of node.properties) {
|
|
34
|
-
if (prop.type !== "Property" || prop.computed) continue;
|
|
35
|
-
const key = getKeyName(prop.key);
|
|
36
|
-
if (key === null) continue;
|
|
37
|
-
if (/^[A-Z@&]/.test(key)) continue;
|
|
38
|
-
if (prop.value.type === "ObjectExpression") checkDuplicates(prop.value);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
return {
|
|
42
|
-
ImportDeclaration(node) {
|
|
43
|
-
ctx.trackImport(node);
|
|
44
|
-
},
|
|
45
|
-
...styleObjectListeners(handleStyleObject)
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
//#endregion
|
|
51
|
-
export { no_duplicate_state_default as default };
|
|
52
|
-
//# sourceMappingURL=no-duplicate-state.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"no-duplicate-state.js","names":[],"sources":["../../src/rules/no-duplicate-state.ts"],"sourcesContent":["import type { TSESTree } from '@typescript-eslint/utils';\nimport { createRule } from '../create-rule.js';\nimport { TastyContext, styleObjectListeners } from '../context.js';\nimport { getKeyName, getStringValue } from '../utils.js';\n\ntype MessageIds = 'duplicateState';\n\nexport default createRule<[], MessageIds>({\n name: 'no-duplicate-state',\n meta: {\n type: 'suggestion',\n docs: {\n description:\n 'Warn when the same state key appears more than once in a style mapping',\n },\n messages: {\n duplicateState: \"Duplicate state key '{{key}}'.\",\n },\n schema: [],\n },\n defaultOptions: [],\n create(context) {\n const ctx = new TastyContext(context);\n\n function checkDuplicates(obj: TSESTree.ObjectExpression): void {\n const seen = new Map<string, TSESTree.Node>();\n\n for (const prop of obj.properties) {\n if (prop.type !== 'Property') continue;\n\n const key = !prop.computed\n ? getKeyName(prop.key)\n : getStringValue(prop.key);\n\n if (key === null) continue;\n\n if (seen.has(key)) {\n context.report({\n node: prop.key,\n messageId: 'duplicateState',\n data: { key },\n });\n } else {\n seen.set(key, prop.key);\n }\n }\n }\n\n function handleStyleObject(node: TSESTree.ObjectExpression) {\n if (!ctx.isStyleObject(node)) return;\n\n for (const prop of node.properties) {\n if (prop.type !== 'Property' || prop.computed) continue;\n\n const key = getKeyName(prop.key);\n if (key === null) continue;\n\n // Skip sub-elements and special keys\n if (/^[A-Z@&]/.test(key)) continue;\n\n // Check state map objects for duplicates\n if (prop.value.type === 'ObjectExpression') {\n checkDuplicates(prop.value);\n }\n }\n }\n\n return {\n ImportDeclaration(node) {\n ctx.trackImport(node);\n },\n ...styleObjectListeners(handleStyleObject),\n };\n },\n});\n"],"mappings":";;;;;AAOA,iCAAe,WAA2B;CACxC,MAAM;CACN,MAAM;EACJ,MAAM;EACN,MAAM,EACJ,aACE,0EACH;EACD,UAAU,EACR,gBAAgB,kCACjB;EACD,QAAQ,EAAE;EACX;CACD,gBAAgB,EAAE;CAClB,OAAO,SAAS;EACd,MAAM,MAAM,IAAI,aAAa,QAAQ;EAErC,SAAS,gBAAgB,KAAsC;GAC7D,MAAM,uBAAO,IAAI,KAA4B;AAE7C,QAAK,MAAM,QAAQ,IAAI,YAAY;AACjC,QAAI,KAAK,SAAS,WAAY;IAE9B,MAAM,MAAM,CAAC,KAAK,WACd,WAAW,KAAK,IAAI,GACpB,eAAe,KAAK,IAAI;AAE5B,QAAI,QAAQ,KAAM;AAElB,QAAI,KAAK,IAAI,IAAI,CACf,SAAQ,OAAO;KACb,MAAM,KAAK;KACX,WAAW;KACX,MAAM,EAAE,KAAK;KACd,CAAC;QAEF,MAAK,IAAI,KAAK,KAAK,IAAI;;;EAK7B,SAAS,kBAAkB,MAAiC;AAC1D,OAAI,CAAC,IAAI,cAAc,KAAK,CAAE;AAE9B,QAAK,MAAM,QAAQ,KAAK,YAAY;AAClC,QAAI,KAAK,SAAS,cAAc,KAAK,SAAU;IAE/C,MAAM,MAAM,WAAW,KAAK,IAAI;AAChC,QAAI,QAAQ,KAAM;AAGlB,QAAI,WAAW,KAAK,IAAI,CAAE;AAG1B,QAAI,KAAK,MAAM,SAAS,mBACtB,iBAAgB,KAAK,MAAM;;;AAKjC,SAAO;GACL,kBAAkB,MAAM;AACtB,QAAI,YAAY,KAAK;;GAEvB,GAAG,qBAAqB,kBAAkB;GAC3C;;CAEJ,CAAC"}
|