@tamagui/eslint-plugin 3.0.0-beta.924.1 → 3.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -2
- package/dist/cjs/index.cjs +69 -4
- package/dist/cjs/index.native.cjs +108 -4
- package/dist/cjs/index.native.js +108 -4
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/esm/index.mjs +68 -2
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/index.native.js +107 -2
- package/dist/esm/index.native.js.map +1 -1
- package/package.json +6 -6
- package/src/index.ts +100 -3
- package/types/index.d.ts +1 -1
- package/types/index.d.ts.map +2 -2
package/README.md
CHANGED
|
@@ -6,7 +6,6 @@ parsing, configured candidate validation, and v6 built-in names to
|
|
|
6
6
|
|
|
7
7
|
```ts
|
|
8
8
|
// eslint.config.ts
|
|
9
|
-
import parser from '@typescript-eslint/parser'
|
|
10
9
|
import tamagui from '@tamagui/eslint-plugin'
|
|
11
10
|
import { createGrammarConfigView } from '@tamagui/style-grammar/tooling'
|
|
12
11
|
import config from './tamagui.config'
|
|
@@ -16,7 +15,6 @@ const grammarConfig = createGrammarConfigView(config)
|
|
|
16
15
|
export default [
|
|
17
16
|
{
|
|
18
17
|
files: ['**/*.{ts,tsx}'],
|
|
19
|
-
languageOptions: { parser },
|
|
20
18
|
plugins: { tamagui },
|
|
21
19
|
rules: {
|
|
22
20
|
'tamagui/valid-flat-values': ['error', { config: grammarConfig }],
|
|
@@ -65,3 +63,6 @@ payload validator, and obsolete v6 built-in names. It never fixes those
|
|
|
65
63
|
diagnostics. When a valid value differs only from style-grammar's canonical
|
|
66
64
|
print of the same parsed IR, the rule can safely collapse boundary whitespace
|
|
67
65
|
with ESLint's normal autofix.
|
|
66
|
+
|
|
67
|
+
Pass `strictPayloads: true` to enable strict validation of single-token clause payloads against configured tokens, theme values, and CSS keywords, catching typos like `bg="backgroun"` with did-you-mean suggestions.
|
|
68
|
+
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -22,12 +22,77 @@ var index_exports = {};
|
|
|
22
22
|
__export(index_exports, {
|
|
23
23
|
default: () => index_default,
|
|
24
24
|
rules: () => rules,
|
|
25
|
-
validFlatValues: () =>
|
|
25
|
+
validFlatValues: () => validFlatValues
|
|
26
26
|
});
|
|
27
27
|
module.exports = __toCommonJS(index_exports);
|
|
28
|
-
var
|
|
29
|
-
var
|
|
30
|
-
const
|
|
28
|
+
var import_extract_estree = require("@tamagui/language-service/extract-estree");
|
|
29
|
+
var import_tooling = require("@tamagui/style-grammar/tooling");
|
|
30
|
+
const validFlatValues = {
|
|
31
|
+
meta: {
|
|
32
|
+
type: "problem",
|
|
33
|
+
fixable: "code",
|
|
34
|
+
docs: { description: "validate static Tamagui flat values with @tamagui/style-grammar" },
|
|
35
|
+
schema: [{
|
|
36
|
+
type: "object",
|
|
37
|
+
properties: {
|
|
38
|
+
config: { type: "object" },
|
|
39
|
+
strictPayloads: { type: "boolean" }
|
|
40
|
+
},
|
|
41
|
+
required: ["config"],
|
|
42
|
+
additionalProperties: false
|
|
43
|
+
}],
|
|
44
|
+
messages: {
|
|
45
|
+
invalidFlatValue: "{{message}}",
|
|
46
|
+
nonCanonicalFlatValue: "use the canonical flat value \"{{canonical}}\""
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
create(context) {
|
|
50
|
+
const option = context.options[0];
|
|
51
|
+
const config = option?.config || {};
|
|
52
|
+
const strictPayloads = option?.strictPayloads ?? false;
|
|
53
|
+
const registry = (0, import_tooling.createModifierRegistry)(config).registry;
|
|
54
|
+
const candidates = (0, import_tooling.createCandidatePropertyVocabulary)(config);
|
|
55
|
+
const styleProps = (0, import_tooling.createStylePropSet)(config);
|
|
56
|
+
const sourceCode = context.sourceCode;
|
|
57
|
+
const report = (site) => {
|
|
58
|
+
const node = site.node;
|
|
59
|
+
const diagnostics = (0, import_tooling.diagnoseStyleValueProgram)(site.property, site.value, {
|
|
60
|
+
config,
|
|
61
|
+
registry,
|
|
62
|
+
candidates,
|
|
63
|
+
strictPayloads
|
|
64
|
+
});
|
|
65
|
+
for (const diagnostic of diagnostics) {
|
|
66
|
+
context.report({
|
|
67
|
+
node,
|
|
68
|
+
loc: {
|
|
69
|
+
start: sourceCode.getLocFromIndex(site.start + diagnostic.start),
|
|
70
|
+
end: sourceCode.getLocFromIndex(site.start + diagnostic.end)
|
|
71
|
+
},
|
|
72
|
+
messageId: "invalidFlatValue",
|
|
73
|
+
data: { message: diagnostic.message }
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
if (diagnostics.length > 0) return;
|
|
77
|
+
const formatted = (0, import_tooling.canonicalizeStyleValue)(site.value, registry);
|
|
78
|
+
if (!formatted.ok || formatted.value === site.value) return;
|
|
79
|
+
const canonical = formatted.value;
|
|
80
|
+
context.report({
|
|
81
|
+
node,
|
|
82
|
+
messageId: "nonCanonicalFlatValue",
|
|
83
|
+
data: { canonical },
|
|
84
|
+
fix(fixer) {
|
|
85
|
+
return fixer.replaceText(node, JSON.stringify(canonical));
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
};
|
|
89
|
+
return { "Program:exit"(program) {
|
|
90
|
+
const sites = (0, import_extract_estree.extractStyleSitesFromEstree)(program, { isStyleProp: (name) => styleProps.has(name) });
|
|
91
|
+
for (const site of sites) report(site);
|
|
92
|
+
} };
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
const rules = { "valid-flat-values": validFlatValues };
|
|
31
96
|
const plugin = {
|
|
32
97
|
meta: { name: "@tamagui/eslint-plugin" },
|
|
33
98
|
rules
|
|
@@ -24,12 +24,116 @@ var index_exports = {};
|
|
|
24
24
|
__export(index_exports, {
|
|
25
25
|
default: () => index_default,
|
|
26
26
|
rules: () => rules,
|
|
27
|
-
validFlatValues: () =>
|
|
27
|
+
validFlatValues: () => validFlatValues
|
|
28
28
|
});
|
|
29
29
|
module.exports = __toCommonJS(index_exports);
|
|
30
|
-
var
|
|
31
|
-
var
|
|
32
|
-
var
|
|
30
|
+
var import_extract_estree = require("@tamagui/language-service/extract-estree");
|
|
31
|
+
var import_tooling = require("@tamagui/style-grammar/tooling");
|
|
32
|
+
var validFlatValues = {
|
|
33
|
+
meta: {
|
|
34
|
+
type: "problem",
|
|
35
|
+
fixable: "code",
|
|
36
|
+
docs: { description: "validate static Tamagui flat values with @tamagui/style-grammar" },
|
|
37
|
+
schema: [{
|
|
38
|
+
type: "object",
|
|
39
|
+
properties: {
|
|
40
|
+
config: { type: "object" },
|
|
41
|
+
strictPayloads: { type: "boolean" }
|
|
42
|
+
},
|
|
43
|
+
required: ["config"],
|
|
44
|
+
additionalProperties: false
|
|
45
|
+
}],
|
|
46
|
+
messages: {
|
|
47
|
+
invalidFlatValue: "{{message}}",
|
|
48
|
+
nonCanonicalFlatValue: "use the canonical flat value \"{{canonical}}\""
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
create(context) {
|
|
52
|
+
var option = context.options[0];
|
|
53
|
+
var config = (option === null || option === void 0 ? void 0 : option.config) || {};
|
|
54
|
+
var _option_strictPayloads;
|
|
55
|
+
var strictPayloads = (_option_strictPayloads = option === null || option === void 0 ? void 0 : option.strictPayloads) !== null && _option_strictPayloads !== void 0 ? _option_strictPayloads : false;
|
|
56
|
+
var registry = (0, import_tooling.createModifierRegistry)(config).registry;
|
|
57
|
+
var candidates = (0, import_tooling.createCandidatePropertyVocabulary)(config);
|
|
58
|
+
var styleProps = (0, import_tooling.createStylePropSet)(config);
|
|
59
|
+
var sourceCode = context.sourceCode;
|
|
60
|
+
var report = function(site) {
|
|
61
|
+
var node = site.node;
|
|
62
|
+
var diagnostics = (0, import_tooling.diagnoseStyleValueProgram)(site.property, site.value, {
|
|
63
|
+
config,
|
|
64
|
+
registry,
|
|
65
|
+
candidates,
|
|
66
|
+
strictPayloads
|
|
67
|
+
});
|
|
68
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
69
|
+
try {
|
|
70
|
+
for (var _iterator = diagnostics[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
71
|
+
var diagnostic = _step.value;
|
|
72
|
+
context.report({
|
|
73
|
+
node,
|
|
74
|
+
loc: {
|
|
75
|
+
start: sourceCode.getLocFromIndex(site.start + diagnostic.start),
|
|
76
|
+
end: sourceCode.getLocFromIndex(site.start + diagnostic.end)
|
|
77
|
+
},
|
|
78
|
+
messageId: "invalidFlatValue",
|
|
79
|
+
data: { message: diagnostic.message }
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
} catch (err) {
|
|
83
|
+
_didIteratorError = true;
|
|
84
|
+
_iteratorError = err;
|
|
85
|
+
} finally {
|
|
86
|
+
try {
|
|
87
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
88
|
+
_iterator.return();
|
|
89
|
+
}
|
|
90
|
+
} finally {
|
|
91
|
+
if (_didIteratorError) {
|
|
92
|
+
throw _iteratorError;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
if (diagnostics.length > 0) return;
|
|
97
|
+
var formatted = (0, import_tooling.canonicalizeStyleValue)(site.value, registry);
|
|
98
|
+
if (!formatted.ok || formatted.value === site.value) return;
|
|
99
|
+
var canonical = formatted.value;
|
|
100
|
+
context.report({
|
|
101
|
+
node,
|
|
102
|
+
messageId: "nonCanonicalFlatValue",
|
|
103
|
+
data: { canonical },
|
|
104
|
+
fix(fixer) {
|
|
105
|
+
return fixer.replaceText(node, JSON.stringify(canonical));
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
};
|
|
109
|
+
return { "Program:exit"(program) {
|
|
110
|
+
var sites = (0, import_extract_estree.extractStyleSitesFromEstree)(program, { isStyleProp: function(name) {
|
|
111
|
+
return styleProps.has(name);
|
|
112
|
+
} });
|
|
113
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
114
|
+
try {
|
|
115
|
+
for (var _iterator = sites[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
116
|
+
var site = _step.value;
|
|
117
|
+
report(site);
|
|
118
|
+
}
|
|
119
|
+
} catch (err) {
|
|
120
|
+
_didIteratorError = true;
|
|
121
|
+
_iteratorError = err;
|
|
122
|
+
} finally {
|
|
123
|
+
try {
|
|
124
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
125
|
+
_iterator.return();
|
|
126
|
+
}
|
|
127
|
+
} finally {
|
|
128
|
+
if (_didIteratorError) {
|
|
129
|
+
throw _iteratorError;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
} };
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
var rules = { "valid-flat-values": validFlatValues };
|
|
33
137
|
var plugin = {
|
|
34
138
|
meta: { name: "@tamagui/eslint-plugin" },
|
|
35
139
|
rules
|
package/dist/cjs/index.native.js
CHANGED
|
@@ -24,12 +24,116 @@ var index_exports = {};
|
|
|
24
24
|
__export(index_exports, {
|
|
25
25
|
default: () => index_default,
|
|
26
26
|
rules: () => rules,
|
|
27
|
-
validFlatValues: () =>
|
|
27
|
+
validFlatValues: () => validFlatValues
|
|
28
28
|
});
|
|
29
29
|
module.exports = __toCommonJS(index_exports);
|
|
30
|
-
var
|
|
31
|
-
var
|
|
32
|
-
var
|
|
30
|
+
var import_extract_estree = require("@tamagui/language-service/extract-estree");
|
|
31
|
+
var import_tooling = require("@tamagui/style-grammar/tooling");
|
|
32
|
+
var validFlatValues = {
|
|
33
|
+
meta: {
|
|
34
|
+
type: "problem",
|
|
35
|
+
fixable: "code",
|
|
36
|
+
docs: { description: "validate static Tamagui flat values with @tamagui/style-grammar" },
|
|
37
|
+
schema: [{
|
|
38
|
+
type: "object",
|
|
39
|
+
properties: {
|
|
40
|
+
config: { type: "object" },
|
|
41
|
+
strictPayloads: { type: "boolean" }
|
|
42
|
+
},
|
|
43
|
+
required: ["config"],
|
|
44
|
+
additionalProperties: false
|
|
45
|
+
}],
|
|
46
|
+
messages: {
|
|
47
|
+
invalidFlatValue: "{{message}}",
|
|
48
|
+
nonCanonicalFlatValue: "use the canonical flat value \"{{canonical}}\""
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
create(context) {
|
|
52
|
+
var option = context.options[0];
|
|
53
|
+
var config = (option === null || option === void 0 ? void 0 : option.config) || {};
|
|
54
|
+
var _option_strictPayloads;
|
|
55
|
+
var strictPayloads = (_option_strictPayloads = option === null || option === void 0 ? void 0 : option.strictPayloads) !== null && _option_strictPayloads !== void 0 ? _option_strictPayloads : false;
|
|
56
|
+
var registry = (0, import_tooling.createModifierRegistry)(config).registry;
|
|
57
|
+
var candidates = (0, import_tooling.createCandidatePropertyVocabulary)(config);
|
|
58
|
+
var styleProps = (0, import_tooling.createStylePropSet)(config);
|
|
59
|
+
var sourceCode = context.sourceCode;
|
|
60
|
+
var report = function(site) {
|
|
61
|
+
var node = site.node;
|
|
62
|
+
var diagnostics = (0, import_tooling.diagnoseStyleValueProgram)(site.property, site.value, {
|
|
63
|
+
config,
|
|
64
|
+
registry,
|
|
65
|
+
candidates,
|
|
66
|
+
strictPayloads
|
|
67
|
+
});
|
|
68
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
69
|
+
try {
|
|
70
|
+
for (var _iterator = diagnostics[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
71
|
+
var diagnostic = _step.value;
|
|
72
|
+
context.report({
|
|
73
|
+
node,
|
|
74
|
+
loc: {
|
|
75
|
+
start: sourceCode.getLocFromIndex(site.start + diagnostic.start),
|
|
76
|
+
end: sourceCode.getLocFromIndex(site.start + diagnostic.end)
|
|
77
|
+
},
|
|
78
|
+
messageId: "invalidFlatValue",
|
|
79
|
+
data: { message: diagnostic.message }
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
} catch (err) {
|
|
83
|
+
_didIteratorError = true;
|
|
84
|
+
_iteratorError = err;
|
|
85
|
+
} finally {
|
|
86
|
+
try {
|
|
87
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
88
|
+
_iterator.return();
|
|
89
|
+
}
|
|
90
|
+
} finally {
|
|
91
|
+
if (_didIteratorError) {
|
|
92
|
+
throw _iteratorError;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
if (diagnostics.length > 0) return;
|
|
97
|
+
var formatted = (0, import_tooling.canonicalizeStyleValue)(site.value, registry);
|
|
98
|
+
if (!formatted.ok || formatted.value === site.value) return;
|
|
99
|
+
var canonical = formatted.value;
|
|
100
|
+
context.report({
|
|
101
|
+
node,
|
|
102
|
+
messageId: "nonCanonicalFlatValue",
|
|
103
|
+
data: { canonical },
|
|
104
|
+
fix(fixer) {
|
|
105
|
+
return fixer.replaceText(node, JSON.stringify(canonical));
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
};
|
|
109
|
+
return { "Program:exit"(program) {
|
|
110
|
+
var sites = (0, import_extract_estree.extractStyleSitesFromEstree)(program, { isStyleProp: function(name) {
|
|
111
|
+
return styleProps.has(name);
|
|
112
|
+
} });
|
|
113
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
114
|
+
try {
|
|
115
|
+
for (var _iterator = sites[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
116
|
+
var site = _step.value;
|
|
117
|
+
report(site);
|
|
118
|
+
}
|
|
119
|
+
} catch (err) {
|
|
120
|
+
_didIteratorError = true;
|
|
121
|
+
_iteratorError = err;
|
|
122
|
+
} finally {
|
|
123
|
+
try {
|
|
124
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
125
|
+
_iterator.return();
|
|
126
|
+
}
|
|
127
|
+
} finally {
|
|
128
|
+
if (_didIteratorError) {
|
|
129
|
+
throw _iteratorError;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
} };
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
var rules = { "valid-flat-values": validFlatValues };
|
|
33
137
|
var plugin = {
|
|
34
138
|
meta: { name: "@tamagui/eslint-plugin" },
|
|
35
139
|
rules
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.native.js","names":[],"sources":["cjs/index.native.js"],"sourcesContent":["\"use strict\";\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\nvar index_exports = {};\n__export(index_exports, {\n default: () => index_default,\n rules: () => rules,\n validFlatValues: () =>
|
|
1
|
+
{"version":3,"file":"index.native.js","names":[],"sources":["cjs/index.native.js"],"sourcesContent":["\"use strict\";\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\nvar index_exports = {};\n__export(index_exports, {\n default: () => index_default,\n rules: () => rules,\n validFlatValues: () => validFlatValues\n});\nmodule.exports = __toCommonJS(index_exports);\nvar import_extract_estree = require(\"@tamagui/language-service/extract-estree\");\nvar import_tooling = require(\"@tamagui/style-grammar/tooling\");\nvar validFlatValues = {\n meta: {\n type: \"problem\",\n fixable: \"code\",\n docs: {\n description: \"validate static Tamagui flat values with @tamagui/style-grammar\"\n },\n schema: [\n {\n type: \"object\",\n properties: {\n config: {\n type: \"object\"\n },\n strictPayloads: {\n type: \"boolean\"\n }\n },\n required: [\n \"config\"\n ],\n additionalProperties: false\n }\n ],\n messages: {\n invalidFlatValue: \"{{message}}\",\n nonCanonicalFlatValue: 'use the canonical flat value \"{{canonical}}\"'\n }\n },\n create(context) {\n var option = context.options[0];\n var config = (option === null || option === void 0 ? void 0 : option.config) || {};\n var _option_strictPayloads;\n var strictPayloads = (_option_strictPayloads = option === null || option === void 0 ? void 0 : option.strictPayloads) !== null && _option_strictPayloads !== void 0 ? _option_strictPayloads : false;\n var registry = (0, import_tooling.createModifierRegistry)(config).registry;\n var candidates = (0, import_tooling.createCandidatePropertyVocabulary)(config);\n var styleProps = (0, import_tooling.createStylePropSet)(config);\n var sourceCode = context.sourceCode;\n var report = function(site) {\n var node = site.node;\n var diagnostics = (0, import_tooling.diagnoseStyleValueProgram)(site.property, site.value, {\n config,\n registry,\n candidates,\n strictPayloads\n });\n var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;\n try {\n for (var _iterator = diagnostics[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n var diagnostic = _step.value;\n context.report({\n node,\n // the engine reports value-relative spans; surface them exactly\n loc: {\n start: sourceCode.getLocFromIndex(site.start + diagnostic.start),\n end: sourceCode.getLocFromIndex(site.start + diagnostic.end)\n },\n messageId: \"invalidFlatValue\",\n data: {\n message: diagnostic.message\n }\n });\n }\n } catch (err) {\n _didIteratorError = true;\n _iteratorError = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion && _iterator.return != null) {\n _iterator.return();\n }\n } finally {\n if (_didIteratorError) {\n throw _iteratorError;\n }\n }\n }\n if (diagnostics.length > 0) return;\n var formatted = (0, import_tooling.canonicalizeStyleValue)(site.value, registry);\n if (!formatted.ok || formatted.value === site.value) return;\n var canonical = formatted.value;\n context.report({\n node,\n messageId: \"nonCanonicalFlatValue\",\n data: {\n canonical\n },\n fix(fixer) {\n return fixer.replaceText(node, JSON.stringify(canonical));\n }\n });\n };\n return {\n \"Program:exit\"(program) {\n var sites = (0, import_extract_estree.extractStyleSitesFromEstree)(program, {\n isStyleProp: function(name) {\n return styleProps.has(name);\n }\n });\n var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;\n try {\n for (var _iterator = sites[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n var site = _step.value;\n report(site);\n }\n } catch (err) {\n _didIteratorError = true;\n _iteratorError = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion && _iterator.return != null) {\n _iterator.return();\n }\n } finally {\n if (_didIteratorError) {\n throw _iteratorError;\n }\n }\n }\n }\n };\n }\n};\nvar rules = {\n \"valid-flat-values\": validFlatValues\n};\nvar plugin = {\n meta: {\n name: \"@tamagui/eslint-plugin\"\n },\n rules\n};\nvar index_default = plugin;\n//# sourceMappingURL=index.js.map\n"],"mappings":";;;AACA,IAAI,YAAY,OAAO;AACvB,IAAI,mBAAmB,OAAO;AAC9B,IAAI,oBAAoB,OAAO;AAC/B,IAAI,eAAe,OAAO,UAAU;AACpC,IAAI,YAAY,QAAQ,QAAQ;CAC9B,KAAK,IAAI,QAAQ,KACf,UAAU,QAAQ,MAAM;EAAE,KAAK,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D;GACF,CAAC;EACH;EACA,OAAO,EACL,eAAe,SAAS;GACtB,IAAI,SAAS,GAAG,sBAAsB,4BAA2B,CAAE,SAAS,EAC1E,aAAa,SAAS,MAAM;IAC1B,OAAO,WAAW,IAAI,IAAI;GAC5B,EACF,CAAC;GACD,IAAI,4BAA4B,MAAM,oBAAoB,OAAO,iBAAiB,KAAK;GACvF,IAAI;IACF,KAAK,IAAI,YAAY,MAAM,OAAO,SAAS,CAAC,GAAG,OAAO,EAAE,6BAA6B,QAAQ,UAAU,KAAK,EAAC,CAAE,OAAO,4BAA4B,MAAM;KACtJ,IAAI,OAAO,MAAM;KACjB,OAAO,IAAI;IACb;GACF,SAAS,KAAK;IACZ,oBAAoB;IACpB,iBAAiB;GACnB,UAAU;IACR,IAAI;KACF,IAAI,CAAC,6BAA6B,UAAU,UAAU,MAAM;MAC1D,UAAU,OAAO;KACnB;IACF,UAAU;KACR,IAAI,mBAAmB;MACrB,MAAM;KACR;IACF;GACF;EACF,EACF;CACF;AACF;AACA,IAAI,QAAQ,EACV,qBAAqB,gBACvB;AACA,IAAI,SAAS;CACX,MAAM,EACJ,MAAM,yBACR;CACA;AACF;AACA,IAAI,gBAAgB"}
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1,6 +1,72 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { extractStyleSitesFromEstree } from "@tamagui/language-service/extract-estree";
|
|
2
|
+
import { canonicalizeStyleValue, createCandidatePropertyVocabulary, createModifierRegistry, createStylePropSet, diagnoseStyleValueProgram } from "@tamagui/style-grammar/tooling";
|
|
2
3
|
|
|
3
|
-
const
|
|
4
|
+
const validFlatValues = {
|
|
5
|
+
meta: {
|
|
6
|
+
type: "problem",
|
|
7
|
+
fixable: "code",
|
|
8
|
+
docs: { description: "validate static Tamagui flat values with @tamagui/style-grammar" },
|
|
9
|
+
schema: [{
|
|
10
|
+
type: "object",
|
|
11
|
+
properties: {
|
|
12
|
+
config: { type: "object" },
|
|
13
|
+
strictPayloads: { type: "boolean" }
|
|
14
|
+
},
|
|
15
|
+
required: ["config"],
|
|
16
|
+
additionalProperties: false
|
|
17
|
+
}],
|
|
18
|
+
messages: {
|
|
19
|
+
invalidFlatValue: "{{message}}",
|
|
20
|
+
nonCanonicalFlatValue: "use the canonical flat value \"{{canonical}}\""
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
create(context) {
|
|
24
|
+
const option = context.options[0];
|
|
25
|
+
const config = option?.config || {};
|
|
26
|
+
const strictPayloads = option?.strictPayloads ?? false;
|
|
27
|
+
const registry = createModifierRegistry(config).registry;
|
|
28
|
+
const candidates = createCandidatePropertyVocabulary(config);
|
|
29
|
+
const styleProps = createStylePropSet(config);
|
|
30
|
+
const sourceCode = context.sourceCode;
|
|
31
|
+
const report = (site) => {
|
|
32
|
+
const node = site.node;
|
|
33
|
+
const diagnostics = diagnoseStyleValueProgram(site.property, site.value, {
|
|
34
|
+
config,
|
|
35
|
+
registry,
|
|
36
|
+
candidates,
|
|
37
|
+
strictPayloads
|
|
38
|
+
});
|
|
39
|
+
for (const diagnostic of diagnostics) {
|
|
40
|
+
context.report({
|
|
41
|
+
node,
|
|
42
|
+
loc: {
|
|
43
|
+
start: sourceCode.getLocFromIndex(site.start + diagnostic.start),
|
|
44
|
+
end: sourceCode.getLocFromIndex(site.start + diagnostic.end)
|
|
45
|
+
},
|
|
46
|
+
messageId: "invalidFlatValue",
|
|
47
|
+
data: { message: diagnostic.message }
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
if (diagnostics.length > 0) return;
|
|
51
|
+
const formatted = canonicalizeStyleValue(site.value, registry);
|
|
52
|
+
if (!formatted.ok || formatted.value === site.value) return;
|
|
53
|
+
const canonical = formatted.value;
|
|
54
|
+
context.report({
|
|
55
|
+
node,
|
|
56
|
+
messageId: "nonCanonicalFlatValue",
|
|
57
|
+
data: { canonical },
|
|
58
|
+
fix(fixer) {
|
|
59
|
+
return fixer.replaceText(node, JSON.stringify(canonical));
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
};
|
|
63
|
+
return { "Program:exit"(program) {
|
|
64
|
+
const sites = extractStyleSitesFromEstree(program, { isStyleProp: (name) => styleProps.has(name) });
|
|
65
|
+
for (const site of sites) report(site);
|
|
66
|
+
} };
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
const rules = { "valid-flat-values": validFlatValues };
|
|
4
70
|
const plugin = {
|
|
5
71
|
meta: { name: "@tamagui/eslint-plugin" },
|
|
6
72
|
rules
|
package/dist/esm/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["esm/index.js"],"sourcesContent":["import {\n extractStyleSitesFromEstree\n} from \"@tamagui/language-service/extract-estree\";\nimport {\n canonicalizeStyleValue,\n createCandidatePropertyVocabulary,\n createModifierRegistry,\n createStylePropSet,\n diagnoseStyleValueProgram\n} from \"@tamagui/style-grammar/tooling\";\nconst validFlatValues = {\n meta: {\n type: \"problem\",\n fixable: \"code\",\n docs: {\n description: \"validate static Tamagui flat values with @tamagui/style-grammar\"\n },\n schema: [\n {\n type: \"object\",\n properties: {\n config: {\n type: \"object\"\n },\n strictPayloads: {\n type: \"boolean\"\n }\n },\n required: [\"config\"],\n additionalProperties: false\n }\n ],\n messages: {\n invalidFlatValue: \"{{message}}\",\n nonCanonicalFlatValue: 'use the canonical flat value \"{{canonical}}\"'\n }\n },\n create(context) {\n const option = context.options[0];\n const config = option?.config || {};\n const strictPayloads = option?.strictPayloads ?? false;\n const registry = createModifierRegistry(config).registry;\n const candidates = createCandidatePropertyVocabulary(config);\n const styleProps = createStylePropSet(config);\n const sourceCode = context.sourceCode;\n const report = (site) => {\n const node = site.node;\n const diagnostics = diagnoseStyleValueProgram(site.property, site.value, {\n config,\n registry,\n candidates,\n strictPayloads\n });\n for (const diagnostic of diagnostics) {\n context.report({\n node,\n // the engine reports value-relative spans; surface them exactly\n loc: {\n start: sourceCode.getLocFromIndex(site.start + diagnostic.start),\n end: sourceCode.getLocFromIndex(site.start + diagnostic.end)\n },\n messageId: \"invalidFlatValue\",\n data: { message: diagnostic.message }\n });\n }\n if (diagnostics.length > 0) return;\n const formatted = canonicalizeStyleValue(site.value, registry);\n if (!formatted.ok || formatted.value === site.value) return;\n const canonical = formatted.value;\n context.report({\n node,\n messageId: \"nonCanonicalFlatValue\",\n data: { canonical },\n fix(fixer) {\n return fixer.replaceText(node, JSON.stringify(canonical));\n }\n });\n };\n return {\n \"Program:exit\"(program) {\n const sites = extractStyleSitesFromEstree(program, {\n isStyleProp: (name) => styleProps.has(name)\n });\n for (const site of sites) report(site);\n }\n };\n }\n};\nconst rules = {\n \"valid-flat-values\": validFlatValues\n};\nconst plugin = {\n meta: {\n name: \"@tamagui/eslint-plugin\"\n },\n rules\n};\nvar index_default = plugin;\nexport {\n index_default as default,\n rules,\n validFlatValues\n};\n//# sourceMappingURL=index.js.map\n"],"mappings":";;;;AAUA,MAAM,kBAAkB;CACtB,MAAM;EACJ,MAAM;EACN,SAAS;EACT,MAAM,EACJ,aAAa,kEACf;EACA,QAAQ,CACN;GACE,MAAM;GACN,YAAY;IACV,QAAQ,EACN,MAAM,SACR;IACA,gBAAgB,EACd,MAAM,UACR;GACF;GACA,UAAU,CAAC,QAAQ;GACnB,sBAAsB;EACxB,CACF;EACA,UAAU;GACR,kBAAkB;GAClB,uBAAuB;EACzB;CACF;CACA,OAAO,SAAS;EACd,MAAM,SAAS,QAAQ,QAAQ;EAC/B,MAAM,SAAS,QAAQ,UAAU,CAAC;EAClC,MAAM,iBAAiB,QAAQ,kBAAkB;EACjD,MAAM,WAAW,uBAAuB,MAAM,CAAC,CAAC;EAChD,MAAM,aAAa,kCAAkC,MAAM;EAC3D,MAAM,aAAa,mBAAmB,MAAM;EAC5C,MAAM,aAAa,QAAQ;EAC3B,MAAM,UAAU,SAAS;GACvB,MAAM,OAAO,KAAK;GAClB,MAAM,cAAc,0BAA0B,KAAK,UAAU,KAAK,OAAO;IACvE;IACA;IACA;IACA;GACF,CAAC;GACD,KAAK,MAAM,cAAc,aAAa;IACpC,QAAQ,OAAO;KACb;KAEA,KAAK;MACH,OAAO,WAAW,gBAAgB,KAAK,QAAQ,WAAW,KAAK;MAC/D,KAAK,WAAW,gBAAgB,KAAK,QAAQ,WAAW,GAAG;KAC7D;KACA,WAAW;KACX,MAAM,EAAE,SAAS,WAAW,QAAQ;IACtC,CAAC;GACH;GACA,IAAI,YAAY,SAAS,GAAG;GAC5B,MAAM,YAAY,uBAAuB,KAAK,OAAO,QAAQ;GAC7D,IAAI,CAAC,UAAU,MAAM,UAAU,UAAU,KAAK,OAAO;GACrD,MAAM,YAAY,UAAU;GAC5B,QAAQ,OAAO;IACb;IACA,WAAW;IACX,MAAM,EAAE,UAAU;IAClB,IAAI,OAAO;KACT,OAAO,MAAM,YAAY,MAAM,KAAK,UAAU,SAAS,CAAC;IAC1D;GACF,CAAC;EACH;EACA,OAAO,EACL,eAAe,SAAS;GACtB,MAAM,QAAQ,4BAA4B,SAAS,EACjD,cAAc,SAAS,WAAW,IAAI,IAAI,EAC5C,CAAC;GACD,KAAK,MAAM,QAAQ,OAAO,OAAO,IAAI;EACvC,EACF;CACF;AACF;AACA,MAAM,QAAQ,EACZ,qBAAqB,gBACvB;AACA,MAAM,SAAS;CACb,MAAM,EACJ,MAAM,yBACR;CACA;AACF;AACA,IAAI,gBAAgB"}
|
package/dist/esm/index.native.js
CHANGED
|
@@ -1,6 +1,111 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { extractStyleSitesFromEstree } from "@tamagui/language-service/extract-estree";
|
|
2
|
+
import { canonicalizeStyleValue, createCandidatePropertyVocabulary, createModifierRegistry, createStylePropSet, diagnoseStyleValueProgram } from "@tamagui/style-grammar/tooling";
|
|
2
3
|
|
|
3
|
-
var
|
|
4
|
+
var validFlatValues = {
|
|
5
|
+
meta: {
|
|
6
|
+
type: "problem",
|
|
7
|
+
fixable: "code",
|
|
8
|
+
docs: { description: "validate static Tamagui flat values with @tamagui/style-grammar" },
|
|
9
|
+
schema: [{
|
|
10
|
+
type: "object",
|
|
11
|
+
properties: {
|
|
12
|
+
config: { type: "object" },
|
|
13
|
+
strictPayloads: { type: "boolean" }
|
|
14
|
+
},
|
|
15
|
+
required: ["config"],
|
|
16
|
+
additionalProperties: false
|
|
17
|
+
}],
|
|
18
|
+
messages: {
|
|
19
|
+
invalidFlatValue: "{{message}}",
|
|
20
|
+
nonCanonicalFlatValue: "use the canonical flat value \"{{canonical}}\""
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
create(context) {
|
|
24
|
+
var option = context.options[0];
|
|
25
|
+
var config = (option === null || option === void 0 ? void 0 : option.config) || {};
|
|
26
|
+
var _option_strictPayloads;
|
|
27
|
+
var strictPayloads = (_option_strictPayloads = option === null || option === void 0 ? void 0 : option.strictPayloads) !== null && _option_strictPayloads !== void 0 ? _option_strictPayloads : false;
|
|
28
|
+
var registry = createModifierRegistry(config).registry;
|
|
29
|
+
var candidates = createCandidatePropertyVocabulary(config);
|
|
30
|
+
var styleProps = createStylePropSet(config);
|
|
31
|
+
var sourceCode = context.sourceCode;
|
|
32
|
+
var report = function(site) {
|
|
33
|
+
var node = site.node;
|
|
34
|
+
var diagnostics = diagnoseStyleValueProgram(site.property, site.value, {
|
|
35
|
+
config,
|
|
36
|
+
registry,
|
|
37
|
+
candidates,
|
|
38
|
+
strictPayloads
|
|
39
|
+
});
|
|
40
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
41
|
+
try {
|
|
42
|
+
for (var _iterator = diagnostics[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
43
|
+
var diagnostic = _step.value;
|
|
44
|
+
context.report({
|
|
45
|
+
node,
|
|
46
|
+
loc: {
|
|
47
|
+
start: sourceCode.getLocFromIndex(site.start + diagnostic.start),
|
|
48
|
+
end: sourceCode.getLocFromIndex(site.start + diagnostic.end)
|
|
49
|
+
},
|
|
50
|
+
messageId: "invalidFlatValue",
|
|
51
|
+
data: { message: diagnostic.message }
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
} catch (err) {
|
|
55
|
+
_didIteratorError = true;
|
|
56
|
+
_iteratorError = err;
|
|
57
|
+
} finally {
|
|
58
|
+
try {
|
|
59
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
60
|
+
_iterator.return();
|
|
61
|
+
}
|
|
62
|
+
} finally {
|
|
63
|
+
if (_didIteratorError) {
|
|
64
|
+
throw _iteratorError;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
if (diagnostics.length > 0) return;
|
|
69
|
+
var formatted = canonicalizeStyleValue(site.value, registry);
|
|
70
|
+
if (!formatted.ok || formatted.value === site.value) return;
|
|
71
|
+
var canonical = formatted.value;
|
|
72
|
+
context.report({
|
|
73
|
+
node,
|
|
74
|
+
messageId: "nonCanonicalFlatValue",
|
|
75
|
+
data: { canonical },
|
|
76
|
+
fix(fixer) {
|
|
77
|
+
return fixer.replaceText(node, JSON.stringify(canonical));
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
};
|
|
81
|
+
return { "Program:exit"(program) {
|
|
82
|
+
var sites = extractStyleSitesFromEstree(program, { isStyleProp: function(name) {
|
|
83
|
+
return styleProps.has(name);
|
|
84
|
+
} });
|
|
85
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
86
|
+
try {
|
|
87
|
+
for (var _iterator = sites[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
88
|
+
var site = _step.value;
|
|
89
|
+
report(site);
|
|
90
|
+
}
|
|
91
|
+
} catch (err) {
|
|
92
|
+
_didIteratorError = true;
|
|
93
|
+
_iteratorError = err;
|
|
94
|
+
} finally {
|
|
95
|
+
try {
|
|
96
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
97
|
+
_iterator.return();
|
|
98
|
+
}
|
|
99
|
+
} finally {
|
|
100
|
+
if (_didIteratorError) {
|
|
101
|
+
throw _iteratorError;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
} };
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
var rules = { "valid-flat-values": validFlatValues };
|
|
4
109
|
var plugin = {
|
|
5
110
|
meta: { name: "@tamagui/eslint-plugin" },
|
|
6
111
|
rules
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.native.js","names":[
|
|
1
|
+
{"version":3,"file":"index.native.js","names":[],"sources":["esm/index.native.js"],"sourcesContent":["import { extractStyleSitesFromEstree } from \"@tamagui/language-service/extract-estree\";\nimport { canonicalizeStyleValue, createCandidatePropertyVocabulary, createModifierRegistry, createStylePropSet, diagnoseStyleValueProgram } from \"@tamagui/style-grammar/tooling\";\nvar validFlatValues = {\n meta: {\n type: \"problem\",\n fixable: \"code\",\n docs: {\n description: \"validate static Tamagui flat values with @tamagui/style-grammar\"\n },\n schema: [\n {\n type: \"object\",\n properties: {\n config: {\n type: \"object\"\n },\n strictPayloads: {\n type: \"boolean\"\n }\n },\n required: [\n \"config\"\n ],\n additionalProperties: false\n }\n ],\n messages: {\n invalidFlatValue: \"{{message}}\",\n nonCanonicalFlatValue: 'use the canonical flat value \"{{canonical}}\"'\n }\n },\n create(context) {\n var option = context.options[0];\n var config = (option === null || option === void 0 ? void 0 : option.config) || {};\n var _option_strictPayloads;\n var strictPayloads = (_option_strictPayloads = option === null || option === void 0 ? void 0 : option.strictPayloads) !== null && _option_strictPayloads !== void 0 ? _option_strictPayloads : false;\n var registry = createModifierRegistry(config).registry;\n var candidates = createCandidatePropertyVocabulary(config);\n var styleProps = createStylePropSet(config);\n var sourceCode = context.sourceCode;\n var report = function(site) {\n var node = site.node;\n var diagnostics = diagnoseStyleValueProgram(site.property, site.value, {\n config,\n registry,\n candidates,\n strictPayloads\n });\n var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;\n try {\n for (var _iterator = diagnostics[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n var diagnostic = _step.value;\n context.report({\n node,\n // the engine reports value-relative spans; surface them exactly\n loc: {\n start: sourceCode.getLocFromIndex(site.start + diagnostic.start),\n end: sourceCode.getLocFromIndex(site.start + diagnostic.end)\n },\n messageId: \"invalidFlatValue\",\n data: {\n message: diagnostic.message\n }\n });\n }\n } catch (err) {\n _didIteratorError = true;\n _iteratorError = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion && _iterator.return != null) {\n _iterator.return();\n }\n } finally {\n if (_didIteratorError) {\n throw _iteratorError;\n }\n }\n }\n if (diagnostics.length > 0) return;\n var formatted = canonicalizeStyleValue(site.value, registry);\n if (!formatted.ok || formatted.value === site.value) return;\n var canonical = formatted.value;\n context.report({\n node,\n messageId: \"nonCanonicalFlatValue\",\n data: {\n canonical\n },\n fix(fixer) {\n return fixer.replaceText(node, JSON.stringify(canonical));\n }\n });\n };\n return {\n \"Program:exit\"(program) {\n var sites = extractStyleSitesFromEstree(program, {\n isStyleProp: function(name) {\n return styleProps.has(name);\n }\n });\n var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;\n try {\n for (var _iterator = sites[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n var site = _step.value;\n report(site);\n }\n } catch (err) {\n _didIteratorError = true;\n _iteratorError = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion && _iterator.return != null) {\n _iterator.return();\n }\n } finally {\n if (_didIteratorError) {\n throw _iteratorError;\n }\n }\n }\n }\n };\n }\n};\nvar rules = {\n \"valid-flat-values\": validFlatValues\n};\nvar plugin = {\n meta: {\n name: \"@tamagui/eslint-plugin\"\n },\n rules\n};\nvar index_default = plugin;\nexport {\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,MAAM,yBACR;CACA;AACF;AACA,IAAI,gBAAgB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/eslint-plugin",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -31,15 +31,14 @@
|
|
|
31
31
|
"test:web": "vitest --run test"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@tamagui/style-grammar": "3.0.
|
|
35
|
-
"@tamagui/language-service": "3.0.
|
|
34
|
+
"@tamagui/style-grammar": "3.0.1",
|
|
35
|
+
"@tamagui/language-service": "3.0.1"
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|
|
38
38
|
"eslint": ">=9"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
|
-
"@tamagui/build": "3.0.
|
|
42
|
-
"@typescript-eslint/parser": "8.65.0",
|
|
41
|
+
"@tamagui/build": "3.0.1",
|
|
43
42
|
"eslint": "10.8.0",
|
|
44
43
|
"vitest": "4.1.0"
|
|
45
44
|
},
|
|
@@ -47,5 +46,6 @@
|
|
|
47
46
|
"type": "git",
|
|
48
47
|
"url": "git+https://github.com/tamagui/tamagui.git",
|
|
49
48
|
"directory": "code/core/eslint-plugin"
|
|
50
|
-
}
|
|
49
|
+
},
|
|
50
|
+
"releaseSourceCommit": "c156b7cc55e5a6cc5883ebc8189720850ac32dbd"
|
|
51
51
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,7 +1,104 @@
|
|
|
1
|
-
export { validFlatValues } from './validFlatValues'
|
|
2
|
-
|
|
3
1
|
import type { Rule } from 'eslint'
|
|
4
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
extractStyleSitesFromEstree,
|
|
4
|
+
type EstreeStyleSite,
|
|
5
|
+
} from '@tamagui/language-service/extract-estree'
|
|
6
|
+
import {
|
|
7
|
+
canonicalizeStyleValue,
|
|
8
|
+
createCandidatePropertyVocabulary,
|
|
9
|
+
createModifierRegistry,
|
|
10
|
+
createStylePropSet,
|
|
11
|
+
diagnoseStyleValueProgram,
|
|
12
|
+
type GrammarConfigView,
|
|
13
|
+
} from '@tamagui/style-grammar/tooling'
|
|
14
|
+
|
|
15
|
+
type RuleOption = {
|
|
16
|
+
config: GrammarConfigView
|
|
17
|
+
strictPayloads?: boolean
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export const validFlatValues: Rule.RuleModule = {
|
|
21
|
+
meta: {
|
|
22
|
+
type: 'problem',
|
|
23
|
+
fixable: 'code',
|
|
24
|
+
docs: {
|
|
25
|
+
description: 'validate static Tamagui flat values with @tamagui/style-grammar',
|
|
26
|
+
},
|
|
27
|
+
schema: [
|
|
28
|
+
{
|
|
29
|
+
type: 'object',
|
|
30
|
+
properties: {
|
|
31
|
+
config: {
|
|
32
|
+
type: 'object',
|
|
33
|
+
},
|
|
34
|
+
strictPayloads: {
|
|
35
|
+
type: 'boolean',
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
required: ['config'],
|
|
39
|
+
additionalProperties: false,
|
|
40
|
+
},
|
|
41
|
+
],
|
|
42
|
+
messages: {
|
|
43
|
+
invalidFlatValue: '{{message}}',
|
|
44
|
+
nonCanonicalFlatValue: 'use the canonical flat value "{{canonical}}"',
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
|
|
48
|
+
create(context) {
|
|
49
|
+
const option = context.options[0] as RuleOption | undefined
|
|
50
|
+
const config = option?.config || {}
|
|
51
|
+
const strictPayloads = option?.strictPayloads ?? false
|
|
52
|
+
const registry = createModifierRegistry(config).registry
|
|
53
|
+
const candidates = createCandidatePropertyVocabulary(config)
|
|
54
|
+
const styleProps = createStylePropSet(config)
|
|
55
|
+
const sourceCode = context.sourceCode
|
|
56
|
+
|
|
57
|
+
const report = (site: EstreeStyleSite): void => {
|
|
58
|
+
const node = site.node as Rule.Node
|
|
59
|
+
const diagnostics = diagnoseStyleValueProgram(site.property, site.value, {
|
|
60
|
+
config,
|
|
61
|
+
registry,
|
|
62
|
+
candidates,
|
|
63
|
+
strictPayloads,
|
|
64
|
+
})
|
|
65
|
+
for (const diagnostic of diagnostics) {
|
|
66
|
+
context.report({
|
|
67
|
+
node,
|
|
68
|
+
// the engine reports value-relative spans; surface them exactly
|
|
69
|
+
loc: {
|
|
70
|
+
start: sourceCode.getLocFromIndex(site.start + diagnostic.start),
|
|
71
|
+
end: sourceCode.getLocFromIndex(site.start + diagnostic.end),
|
|
72
|
+
},
|
|
73
|
+
messageId: 'invalidFlatValue',
|
|
74
|
+
data: { message: diagnostic.message },
|
|
75
|
+
})
|
|
76
|
+
}
|
|
77
|
+
if (diagnostics.length > 0) return
|
|
78
|
+
|
|
79
|
+
const formatted = canonicalizeStyleValue(site.value, registry)
|
|
80
|
+
if (!formatted.ok || formatted.value === site.value) return
|
|
81
|
+
const canonical = formatted.value
|
|
82
|
+
context.report({
|
|
83
|
+
node,
|
|
84
|
+
messageId: 'nonCanonicalFlatValue',
|
|
85
|
+
data: { canonical },
|
|
86
|
+
fix(fixer) {
|
|
87
|
+
return fixer.replaceText(node, JSON.stringify(canonical))
|
|
88
|
+
},
|
|
89
|
+
})
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return {
|
|
93
|
+
'Program:exit'(program) {
|
|
94
|
+
const sites = extractStyleSitesFromEstree(program, {
|
|
95
|
+
isStyleProp: (name) => styleProps.has(name),
|
|
96
|
+
})
|
|
97
|
+
for (const site of sites) report(site)
|
|
98
|
+
},
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
}
|
|
5
102
|
|
|
6
103
|
export interface TamaguiEslintRules {
|
|
7
104
|
'valid-flat-values': Rule.RuleModule
|
package/types/index.d.ts
CHANGED
package/types/index.d.ts.map
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
|
-
"mappings": "AAAA,
|
|
2
|
+
"mappings": "AAAA,cAAc,YAAY;AAmB1B,OAAO,cAAM,iBAAiB,KAAK;AAmFnC,iBAAiB,mBAAmB;CAClC,qBAAqB,KAAK;;AAG5B,iBAAiB,oBAAoB;CACnC,MAAM;EACJ;;CAEF,OAAO;;AAGT,OAAO,cAAM,OAAO;AAIpB,cAAM,QAAQ;AAOd,eAAe",
|
|
3
3
|
"names": [],
|
|
4
4
|
"sources": [
|
|
5
5
|
"src/index.ts"
|
|
6
6
|
],
|
|
7
7
|
"version": 3,
|
|
8
8
|
"sourcesContent": [
|
|
9
|
-
"
|
|
9
|
+
"import type { Rule } from 'eslint'\nimport {\n extractStyleSitesFromEstree,\n type EstreeStyleSite,\n} from '@tamagui/language-service/extract-estree'\nimport {\n canonicalizeStyleValue,\n createCandidatePropertyVocabulary,\n createModifierRegistry,\n createStylePropSet,\n diagnoseStyleValueProgram,\n type GrammarConfigView,\n} from '@tamagui/style-grammar/tooling'\n\ntype RuleOption = {\n config: GrammarConfigView\n strictPayloads?: boolean\n}\n\nexport const validFlatValues: Rule.RuleModule = {\n meta: {\n type: 'problem',\n fixable: 'code',\n docs: {\n description: 'validate static Tamagui flat values with @tamagui/style-grammar',\n },\n schema: [\n {\n type: 'object',\n properties: {\n config: {\n type: 'object',\n },\n strictPayloads: {\n type: 'boolean',\n },\n },\n required: ['config'],\n additionalProperties: false,\n },\n ],\n messages: {\n invalidFlatValue: '{{message}}',\n nonCanonicalFlatValue: 'use the canonical flat value \"{{canonical}}\"',\n },\n },\n\n create(context) {\n const option = context.options[0] as RuleOption | undefined\n const config = option?.config || {}\n const strictPayloads = option?.strictPayloads ?? false\n const registry = createModifierRegistry(config).registry\n const candidates = createCandidatePropertyVocabulary(config)\n const styleProps = createStylePropSet(config)\n const sourceCode = context.sourceCode\n\n const report = (site: EstreeStyleSite): void => {\n const node = site.node as Rule.Node\n const diagnostics = diagnoseStyleValueProgram(site.property, site.value, {\n config,\n registry,\n candidates,\n strictPayloads,\n })\n for (const diagnostic of diagnostics) {\n context.report({\n node,\n // the engine reports value-relative spans; surface them exactly\n loc: {\n start: sourceCode.getLocFromIndex(site.start + diagnostic.start),\n end: sourceCode.getLocFromIndex(site.start + diagnostic.end),\n },\n messageId: 'invalidFlatValue',\n data: { message: diagnostic.message },\n })\n }\n if (diagnostics.length > 0) return\n\n const formatted = canonicalizeStyleValue(site.value, registry)\n if (!formatted.ok || formatted.value === site.value) return\n const canonical = formatted.value\n context.report({\n node,\n messageId: 'nonCanonicalFlatValue',\n data: { canonical },\n fix(fixer) {\n return fixer.replaceText(node, JSON.stringify(canonical))\n },\n })\n }\n\n return {\n 'Program:exit'(program) {\n const sites = extractStyleSitesFromEstree(program, {\n isStyleProp: (name) => styleProps.has(name),\n })\n for (const site of sites) report(site)\n },\n }\n },\n}\n\nexport interface TamaguiEslintRules {\n 'valid-flat-values': Rule.RuleModule\n}\n\nexport interface TamaguiEslintPlugin {\n meta: {\n name: string\n }\n rules: TamaguiEslintRules\n}\n\nexport const rules: TamaguiEslintRules = {\n 'valid-flat-values': validFlatValues,\n}\n\nconst plugin: TamaguiEslintPlugin = {\n meta: {\n name: '@tamagui/eslint-plugin',\n },\n rules,\n}\n\nexport default plugin\n"
|
|
10
10
|
]
|
|
11
11
|
}
|