@tamagui/eslint-plugin 0.0.0-bootstrap.0 → 3.0.0-beta.1097.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 +70 -1
- package/dist/cjs/index.cjs +100 -0
- package/dist/cjs/index.native.cjs +141 -0
- package/dist/cjs/index.native.js +143 -0
- package/dist/cjs/index.native.js.map +1 -0
- package/dist/cjs/validFlatValues.cjs +85 -0
- package/dist/cjs/validFlatValues.native.cjs +125 -0
- package/dist/cjs/validFlatValues.native.js +127 -0
- package/dist/cjs/validFlatValues.native.js.map +1 -0
- package/dist/esm/index.mjs +77 -0
- package/dist/esm/index.mjs.map +1 -0
- package/dist/esm/index.native.js +116 -0
- package/dist/esm/index.native.js.map +1 -0
- package/dist/esm/validFlatValues.mjs +66 -0
- package/dist/esm/validFlatValues.mjs.map +1 -0
- package/dist/esm/validFlatValues.native.js +104 -0
- package/dist/esm/validFlatValues.native.js.map +1 -0
- package/package.json +42 -7
- package/src/index.ts +125 -0
- package/src/validFlatValues.ts +95 -0
- package/types/index.d.ts +16 -0
- package/types/index.d.ts.map +11 -0
- package/types/validFlatValues.d.ts +4 -0
- package/types/validFlatValues.d.ts.map +11 -0
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all) __defProp(target, name, {
|
|
9
|
+
get: all[name],
|
|
10
|
+
enumerable: true
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
16
|
+
get: () => from[key],
|
|
17
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
22
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
23
|
+
var validFlatValues_exports = {};
|
|
24
|
+
__export(validFlatValues_exports, { validFlatValues: () => validFlatValues });
|
|
25
|
+
module.exports = __toCommonJS(validFlatValues_exports);
|
|
26
|
+
var import_extract_estree = require("@tamagui/language-service/extract-estree");
|
|
27
|
+
var import_tooling = require("@tamagui/style-grammar/tooling");
|
|
28
|
+
var validFlatValues = {
|
|
29
|
+
meta: {
|
|
30
|
+
type: "problem",
|
|
31
|
+
fixable: "code",
|
|
32
|
+
docs: { description: "validate static Tamagui flat values with @tamagui/style-grammar" },
|
|
33
|
+
schema: [{
|
|
34
|
+
type: "object",
|
|
35
|
+
properties: { config: { type: "object" } },
|
|
36
|
+
required: ["config"],
|
|
37
|
+
additionalProperties: false
|
|
38
|
+
}],
|
|
39
|
+
messages: {
|
|
40
|
+
invalidFlatValue: "{{message}}",
|
|
41
|
+
nonCanonicalFlatValue: "use the canonical flat value \"{{canonical}}\""
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
create(context) {
|
|
45
|
+
var option = context.options[0];
|
|
46
|
+
var config = (option === null || option === void 0 ? void 0 : option.config) || {};
|
|
47
|
+
var registry = (0, import_tooling.createModifierRegistry)(config).registry;
|
|
48
|
+
var candidates = (0, import_tooling.createCandidatePropertyVocabulary)(config);
|
|
49
|
+
var styleProps = (0, import_tooling.createStylePropSet)(config);
|
|
50
|
+
var sourceCode = context.sourceCode;
|
|
51
|
+
var report = function(site) {
|
|
52
|
+
var node = site.node;
|
|
53
|
+
var diagnostics = (0, import_tooling.diagnoseStyleValueProgram)(site.property, site.value, {
|
|
54
|
+
config,
|
|
55
|
+
registry,
|
|
56
|
+
candidates
|
|
57
|
+
});
|
|
58
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
59
|
+
try {
|
|
60
|
+
for (var _iterator = diagnostics[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
61
|
+
var diagnostic = _step.value;
|
|
62
|
+
context.report({
|
|
63
|
+
node,
|
|
64
|
+
loc: {
|
|
65
|
+
start: sourceCode.getLocFromIndex(site.start + diagnostic.start),
|
|
66
|
+
end: sourceCode.getLocFromIndex(site.start + diagnostic.end)
|
|
67
|
+
},
|
|
68
|
+
messageId: "invalidFlatValue",
|
|
69
|
+
data: { message: diagnostic.message }
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
} catch (err) {
|
|
73
|
+
_didIteratorError = true;
|
|
74
|
+
_iteratorError = err;
|
|
75
|
+
} finally {
|
|
76
|
+
try {
|
|
77
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
78
|
+
_iterator.return();
|
|
79
|
+
}
|
|
80
|
+
} finally {
|
|
81
|
+
if (_didIteratorError) {
|
|
82
|
+
throw _iteratorError;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
if (diagnostics.length > 0) return;
|
|
87
|
+
var formatted = (0, import_tooling.canonicalizeStyleValue)(site.value, registry);
|
|
88
|
+
if (!formatted.ok || formatted.value === site.value) return;
|
|
89
|
+
var canonical = formatted.value;
|
|
90
|
+
context.report({
|
|
91
|
+
node,
|
|
92
|
+
messageId: "nonCanonicalFlatValue",
|
|
93
|
+
data: { canonical },
|
|
94
|
+
fix(fixer) {
|
|
95
|
+
return fixer.replaceText(node, JSON.stringify(canonical));
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
};
|
|
99
|
+
return { "Program:exit"(program) {
|
|
100
|
+
var sites = (0, import_extract_estree.extractStyleSitesFromEstree)(program, { isStyleProp: function(name) {
|
|
101
|
+
return styleProps.has(name);
|
|
102
|
+
} });
|
|
103
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
104
|
+
try {
|
|
105
|
+
for (var _iterator = sites[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
106
|
+
var site = _step.value;
|
|
107
|
+
report(site);
|
|
108
|
+
}
|
|
109
|
+
} catch (err) {
|
|
110
|
+
_didIteratorError = true;
|
|
111
|
+
_iteratorError = err;
|
|
112
|
+
} finally {
|
|
113
|
+
try {
|
|
114
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
115
|
+
_iterator.return();
|
|
116
|
+
}
|
|
117
|
+
} finally {
|
|
118
|
+
if (_didIteratorError) {
|
|
119
|
+
throw _iteratorError;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
} };
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
//# sourceMappingURL=validFlatValues.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validFlatValues.native.js","names":[],"sources":["cjs/validFlatValues.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 validFlatValues_exports = {};\n__export(validFlatValues_exports, {\n validFlatValues: () => validFlatValues\n});\nmodule.exports = __toCommonJS(validFlatValues_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 },\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 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 });\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};\n//# sourceMappingURL=validFlatValues.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,IAAI;EAAO,YAAY;CAAK,CAAC;AAChE;AACA,IAAI,eAAe,IAAI,MAAM,QAAQ,SAAS;CAC5C,IAAI,QAAQ,OAAO,SAAS,YAAY,OAAO,SAAS,YAAY;EAClE,KAAK,IAAI,OAAO,kBAAkB,IAAI,GACpC,IAAI,CAAC,aAAa,KAAK,IAAI,GAAG,KAAK,QAAQ,QACzC,UAAU,IAAI,KAAK;GAAE,WAAW,KAAK;GAAM,YAAY,EAAE,OAAO,iBAAiB,MAAM,GAAG,MAAM,KAAK;EAAW,CAAC;CACvH;CACA,OAAO;AACT;AACA,IAAI,gBAAgB,QAAQ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,mBAAmB;MACrB,MAAM;KACR;IACF;GACF;EACF,EACF;CACF;AACF"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { extractStyleSitesFromEstree } from "@tamagui/language-service/extract-estree";
|
|
2
|
+
import { canonicalizeStyleValue, createCandidatePropertyVocabulary, createModifierRegistry, createStylePropSet, diagnoseStyleValueProgram } from "@tamagui/style-grammar/tooling";
|
|
3
|
+
|
|
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 };
|
|
70
|
+
const plugin = {
|
|
71
|
+
meta: { name: "@tamagui/eslint-plugin" },
|
|
72
|
+
rules
|
|
73
|
+
};
|
|
74
|
+
var index_default = plugin;
|
|
75
|
+
|
|
76
|
+
export { index_default as default, rules, validFlatValues };
|
|
77
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
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,MA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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"}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { extractStyleSitesFromEstree } from "@tamagui/language-service/extract-estree";
|
|
2
|
+
import { canonicalizeStyleValue, createCandidatePropertyVocabulary, createModifierRegistry, createStylePropSet, diagnoseStyleValueProgram } from "@tamagui/style-grammar/tooling";
|
|
3
|
+
|
|
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 };
|
|
109
|
+
var plugin = {
|
|
110
|
+
meta: { name: "@tamagui/eslint-plugin" },
|
|
111
|
+
rules
|
|
112
|
+
};
|
|
113
|
+
var index_default = plugin;
|
|
114
|
+
|
|
115
|
+
export { index_default as default, rules, validFlatValues };
|
|
116
|
+
//# sourceMappingURL=index.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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 {\n index_default as default,\n rules,\n validFlatValues\n};\n//# sourceMappingURL=index.js.map\n"],"mappings":";;;;AAEA,IAAI,kBAAkB;CACpB,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,CACR,QACF;GACA,sBAAsB;EACxB,CACF;EACA,UAAU;GACR,kBAAkB;GAClB,uBAAuB;EACzB;CACF;CACA,OAAO,SAAS;EACd,IAAI,SAAS,QAAQ,QAAQ;EAC7B,IAAI,UAAU,WAAW,QAAQ,WAAW,KAAK,IAAI,KAAK,IAAI,OAAO,WAAW,CAAC;EACjF,IAAI;EACJ,IAAI,kBAAkB,yBAAyB,WAAW,QAAQ,WAAW,KAAK,IAAI,KAAK,IAAI,OAAO,oBAAoB,QAAQ,2BAA2B,KAAK,IAAI,yBAAyB;EAC/L,IAAI,WAAW,uBAAuB,MAAM,CA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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"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { extractStyleSitesFromEstree } from "@tamagui/language-service/extract-estree";
|
|
2
|
+
import { canonicalizeStyleValue, createCandidatePropertyVocabulary, createModifierRegistry, createStylePropSet, diagnoseStyleValueProgram } from "@tamagui/style-grammar/tooling";
|
|
3
|
+
|
|
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: { config: { type: "object" } },
|
|
12
|
+
required: ["config"],
|
|
13
|
+
additionalProperties: false
|
|
14
|
+
}],
|
|
15
|
+
messages: {
|
|
16
|
+
invalidFlatValue: "{{message}}",
|
|
17
|
+
nonCanonicalFlatValue: "use the canonical flat value \"{{canonical}}\""
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
create(context) {
|
|
21
|
+
const option = context.options[0];
|
|
22
|
+
const config = option?.config || {};
|
|
23
|
+
const registry = createModifierRegistry(config).registry;
|
|
24
|
+
const candidates = createCandidatePropertyVocabulary(config);
|
|
25
|
+
const styleProps = createStylePropSet(config);
|
|
26
|
+
const sourceCode = context.sourceCode;
|
|
27
|
+
const report = (site) => {
|
|
28
|
+
const node = site.node;
|
|
29
|
+
const diagnostics = diagnoseStyleValueProgram(site.property, site.value, {
|
|
30
|
+
config,
|
|
31
|
+
registry,
|
|
32
|
+
candidates
|
|
33
|
+
});
|
|
34
|
+
for (const diagnostic of diagnostics) {
|
|
35
|
+
context.report({
|
|
36
|
+
node,
|
|
37
|
+
loc: {
|
|
38
|
+
start: sourceCode.getLocFromIndex(site.start + diagnostic.start),
|
|
39
|
+
end: sourceCode.getLocFromIndex(site.start + diagnostic.end)
|
|
40
|
+
},
|
|
41
|
+
messageId: "invalidFlatValue",
|
|
42
|
+
data: { message: diagnostic.message }
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
if (diagnostics.length > 0) return;
|
|
46
|
+
const formatted = canonicalizeStyleValue(site.value, registry);
|
|
47
|
+
if (!formatted.ok || formatted.value === site.value) return;
|
|
48
|
+
const canonical = formatted.value;
|
|
49
|
+
context.report({
|
|
50
|
+
node,
|
|
51
|
+
messageId: "nonCanonicalFlatValue",
|
|
52
|
+
data: { canonical },
|
|
53
|
+
fix(fixer) {
|
|
54
|
+
return fixer.replaceText(node, JSON.stringify(canonical));
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
};
|
|
58
|
+
return { "Program:exit"(program) {
|
|
59
|
+
const sites = extractStyleSitesFromEstree(program, { isStyleProp: (name) => styleProps.has(name) });
|
|
60
|
+
for (const site of sites) report(site);
|
|
61
|
+
} };
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
export { validFlatValues };
|
|
66
|
+
//# sourceMappingURL=validFlatValues.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validFlatValues.js","names":[],"sources":["esm/validFlatValues.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 },\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 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 });\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 }\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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"}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { extractStyleSitesFromEstree } from "@tamagui/language-service/extract-estree";
|
|
2
|
+
import { canonicalizeStyleValue, createCandidatePropertyVocabulary, createModifierRegistry, createStylePropSet, diagnoseStyleValueProgram } from "@tamagui/style-grammar/tooling";
|
|
3
|
+
|
|
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: { config: { type: "object" } },
|
|
12
|
+
required: ["config"],
|
|
13
|
+
additionalProperties: false
|
|
14
|
+
}],
|
|
15
|
+
messages: {
|
|
16
|
+
invalidFlatValue: "{{message}}",
|
|
17
|
+
nonCanonicalFlatValue: "use the canonical flat value \"{{canonical}}\""
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
create(context) {
|
|
21
|
+
var option = context.options[0];
|
|
22
|
+
var config = (option === null || option === void 0 ? void 0 : option.config) || {};
|
|
23
|
+
var registry = createModifierRegistry(config).registry;
|
|
24
|
+
var candidates = createCandidatePropertyVocabulary(config);
|
|
25
|
+
var styleProps = createStylePropSet(config);
|
|
26
|
+
var sourceCode = context.sourceCode;
|
|
27
|
+
var report = function(site) {
|
|
28
|
+
var node = site.node;
|
|
29
|
+
var diagnostics = diagnoseStyleValueProgram(site.property, site.value, {
|
|
30
|
+
config,
|
|
31
|
+
registry,
|
|
32
|
+
candidates
|
|
33
|
+
});
|
|
34
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
35
|
+
try {
|
|
36
|
+
for (var _iterator = diagnostics[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
37
|
+
var diagnostic = _step.value;
|
|
38
|
+
context.report({
|
|
39
|
+
node,
|
|
40
|
+
loc: {
|
|
41
|
+
start: sourceCode.getLocFromIndex(site.start + diagnostic.start),
|
|
42
|
+
end: sourceCode.getLocFromIndex(site.start + diagnostic.end)
|
|
43
|
+
},
|
|
44
|
+
messageId: "invalidFlatValue",
|
|
45
|
+
data: { message: diagnostic.message }
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
} catch (err) {
|
|
49
|
+
_didIteratorError = true;
|
|
50
|
+
_iteratorError = err;
|
|
51
|
+
} finally {
|
|
52
|
+
try {
|
|
53
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
54
|
+
_iterator.return();
|
|
55
|
+
}
|
|
56
|
+
} finally {
|
|
57
|
+
if (_didIteratorError) {
|
|
58
|
+
throw _iteratorError;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
if (diagnostics.length > 0) return;
|
|
63
|
+
var formatted = canonicalizeStyleValue(site.value, registry);
|
|
64
|
+
if (!formatted.ok || formatted.value === site.value) return;
|
|
65
|
+
var canonical = formatted.value;
|
|
66
|
+
context.report({
|
|
67
|
+
node,
|
|
68
|
+
messageId: "nonCanonicalFlatValue",
|
|
69
|
+
data: { canonical },
|
|
70
|
+
fix(fixer) {
|
|
71
|
+
return fixer.replaceText(node, JSON.stringify(canonical));
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
};
|
|
75
|
+
return { "Program:exit"(program) {
|
|
76
|
+
var sites = extractStyleSitesFromEstree(program, { isStyleProp: function(name) {
|
|
77
|
+
return styleProps.has(name);
|
|
78
|
+
} });
|
|
79
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
80
|
+
try {
|
|
81
|
+
for (var _iterator = sites[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
82
|
+
var site = _step.value;
|
|
83
|
+
report(site);
|
|
84
|
+
}
|
|
85
|
+
} catch (err) {
|
|
86
|
+
_didIteratorError = true;
|
|
87
|
+
_iteratorError = err;
|
|
88
|
+
} finally {
|
|
89
|
+
try {
|
|
90
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
91
|
+
_iterator.return();
|
|
92
|
+
}
|
|
93
|
+
} finally {
|
|
94
|
+
if (_didIteratorError) {
|
|
95
|
+
throw _iteratorError;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
} };
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
export { validFlatValues };
|
|
104
|
+
//# sourceMappingURL=validFlatValues.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validFlatValues.native.js","names":[],"sources":["esm/validFlatValues.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 },\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 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 });\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};\nexport {\n validFlatValues\n};\n//# sourceMappingURL=validFlatValues.js.map\n"],"mappings":";;;;AAEA,IAAI,kBAAkB;CACpB,MA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GACF;GACA,IAAI,YAAY,SAAS,GAAG;GAC5B,IAAI,YAAY,uBAAuB,KAAK,OAAO,QAAQ;GAC3D,IAAI,CAAC,UAAU,MAAM,UAAU,UAAU,KAAK,OAAO;GACrD,IAAI,YAAY,UAAU;GAC1B,QAAQ,OAAO;IACb;IACA,WAAW;IACX,MAAM,EACJ,UACF;IACA,IAAI,OAAO;KACT,OAAO,MAAM,YAAY,MAAM,KAAK,UAAU,SAAS,CAAC;IAC1D;GACF,CAAC;EACH;EACA,OAAO,EACL,eAAe,SAAS;GACtB,IAAI,QAAQ,4BAA4B,SAAS,EAC/C,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"}
|
package/package.json
CHANGED
|
@@ -1,16 +1,51 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/eslint-plugin",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "Tamagui v3 package bootstrap",
|
|
5
|
-
"repository": {
|
|
6
|
-
"type": "git",
|
|
7
|
-
"url": "git+https://github.com/tamagui/tamagui.git"
|
|
8
|
-
},
|
|
3
|
+
"version": "3.0.0-beta.1097.1",
|
|
9
4
|
"license": "MIT",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"sideEffects": false,
|
|
7
|
+
"source": "src/index.ts",
|
|
10
8
|
"files": [
|
|
11
|
-
"
|
|
9
|
+
"src",
|
|
10
|
+
"types",
|
|
11
|
+
"dist"
|
|
12
12
|
],
|
|
13
|
+
"main": "dist/cjs/index.cjs",
|
|
14
|
+
"module": "dist/esm/index.mjs",
|
|
15
|
+
"types": "types/index.d.ts",
|
|
16
|
+
"exports": {
|
|
17
|
+
"./package.json": "./package.json",
|
|
18
|
+
".": {
|
|
19
|
+
"types": "./types/index.d.ts",
|
|
20
|
+
"import": "./dist/esm/index.mjs",
|
|
21
|
+
"require": "./dist/cjs/index.cjs",
|
|
22
|
+
"default": "./dist/esm/index.mjs"
|
|
23
|
+
}
|
|
24
|
+
},
|
|
13
25
|
"publishConfig": {
|
|
14
26
|
"access": "public"
|
|
27
|
+
},
|
|
28
|
+
"scripts": {
|
|
29
|
+
"build": "tamagui-build --exclude test",
|
|
30
|
+
"test": "vitest --run test",
|
|
31
|
+
"test:web": "vitest --run test"
|
|
32
|
+
},
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"@tamagui/style-grammar": "3.0.0-beta.1097.1",
|
|
35
|
+
"@tamagui/language-service": "3.0.0-beta.1097.1"
|
|
36
|
+
},
|
|
37
|
+
"peerDependencies": {
|
|
38
|
+
"eslint": ">=9"
|
|
39
|
+
},
|
|
40
|
+
"devDependencies": {
|
|
41
|
+
"@tamagui/build": "3.0.0-beta.1097.1",
|
|
42
|
+
"@typescript-eslint/parser": "8.65.0",
|
|
43
|
+
"eslint": "10.8.0",
|
|
44
|
+
"vitest": "4.1.0"
|
|
45
|
+
},
|
|
46
|
+
"repository": {
|
|
47
|
+
"type": "git",
|
|
48
|
+
"url": "git+https://github.com/tamagui/tamagui.git",
|
|
49
|
+
"directory": "code/core/eslint-plugin"
|
|
15
50
|
}
|
|
16
51
|
}
|