@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 CHANGED
@@ -1 +1,70 @@
1
- # @tamagui/eslint-plugin
1
+ # `@tamagui/eslint-plugin`
2
+
3
+ ESLint diagnostics for Tamagui's flat style values. The rule delegates value
4
+ parsing, configured candidate validation, and v6 built-in names to
5
+ `@tamagui/style-grammar`.
6
+
7
+ ```ts
8
+ // eslint.config.ts
9
+ import parser from '@typescript-eslint/parser'
10
+ import tamagui from '@tamagui/eslint-plugin'
11
+ import { createGrammarConfigView } from '@tamagui/style-grammar/tooling'
12
+ import config from './tamagui.config'
13
+
14
+ const grammarConfig = createGrammarConfigView(config)
15
+
16
+ export default [
17
+ {
18
+ files: ['**/*.{ts,tsx}'],
19
+ languageOptions: { parser },
20
+ plugins: { tamagui },
21
+ rules: {
22
+ 'tamagui/valid-flat-values': ['error', { config: grammarConfig }],
23
+ },
24
+ },
25
+ ]
26
+ ```
27
+
28
+ Oxlint 1.56 and newer can load the same rule as an external JavaScript plugin.
29
+ Point `specifier` at the installed package and pass the serializable grammar
30
+ configuration as the rule option:
31
+
32
+ ```json
33
+ {
34
+ "jsPlugins": [
35
+ {
36
+ "name": "tamagui",
37
+ "specifier": "@tamagui/eslint-plugin"
38
+ }
39
+ ],
40
+ "rules": {
41
+ "tamagui/valid-flat-values": [
42
+ "error",
43
+ {
44
+ "config": {
45
+ "shorthands": {
46
+ "bg": "backgroundColor"
47
+ },
48
+ "mediaNames": ["sm"],
49
+ "themeNames": ["dark"],
50
+ "tokenNames": {
51
+ "color": ["red", "blue"],
52
+ "space": ["4", "6"]
53
+ }
54
+ }
55
+ }
56
+ ]
57
+ }
58
+ }
59
+ ```
60
+
61
+ `valid-flat-values` checks static string values on imported Tamagui components
62
+ and `styled()` configs. It reports invalid clause grammar, configured
63
+ candidate/property mismatches, invalid payload shapes through the shared
64
+ payload validator, and obsolete v6 built-in names. It never fixes those
65
+ diagnostics. When a valid value differs only from style-grammar's canonical
66
+ print of the same parsed IR, the rule can safely collapse boundary whitespace
67
+ with ESLint's normal autofix.
68
+
69
+ 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.
70
+
@@ -0,0 +1,100 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all) __defProp(target, name, {
7
+ get: all[name],
8
+ enumerable: true
9
+ });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
14
+ get: () => from[key],
15
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
16
+ });
17
+ }
18
+ return to;
19
+ };
20
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ default: () => index_default,
24
+ rules: () => rules,
25
+ validFlatValues: () => validFlatValues
26
+ });
27
+ module.exports = __toCommonJS(index_exports);
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 };
96
+ const plugin = {
97
+ meta: { name: "@tamagui/eslint-plugin" },
98
+ rules
99
+ };
100
+ var index_default = plugin;
@@ -0,0 +1,141 @@
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 index_exports = {};
24
+ __export(index_exports, {
25
+ default: () => index_default,
26
+ rules: () => rules,
27
+ validFlatValues: () => validFlatValues
28
+ });
29
+ module.exports = __toCommonJS(index_exports);
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 };
137
+ var plugin = {
138
+ meta: { name: "@tamagui/eslint-plugin" },
139
+ rules
140
+ };
141
+ var index_default = plugin;
@@ -0,0 +1,143 @@
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 index_exports = {};
24
+ __export(index_exports, {
25
+ default: () => index_default,
26
+ rules: () => rules,
27
+ validFlatValues: () => validFlatValues
28
+ });
29
+ module.exports = __toCommonJS(index_exports);
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 };
137
+ var plugin = {
138
+ meta: { name: "@tamagui/eslint-plugin" },
139
+ rules
140
+ };
141
+ var index_default = plugin;
142
+
143
+ //# sourceMappingURL=index.native.js.map
@@ -0,0 +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: () => 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,IAA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AAM,YAAY,MAAM,KAAK,UAAU,SAAS,CAAC;IAC1D;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"}
@@ -0,0 +1,85 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all) __defProp(target, name, {
7
+ get: all[name],
8
+ enumerable: true
9
+ });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
14
+ get: () => from[key],
15
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
16
+ });
17
+ }
18
+ return to;
19
+ };
20
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
21
+ var validFlatValues_exports = {};
22
+ __export(validFlatValues_exports, { validFlatValues: () => validFlatValues });
23
+ module.exports = __toCommonJS(validFlatValues_exports);
24
+ var import_extract_estree = require("@tamagui/language-service/extract-estree");
25
+ var import_tooling = require("@tamagui/style-grammar/tooling");
26
+ const validFlatValues = {
27
+ meta: {
28
+ type: "problem",
29
+ fixable: "code",
30
+ docs: { description: "validate static Tamagui flat values with @tamagui/style-grammar" },
31
+ schema: [{
32
+ type: "object",
33
+ properties: { config: { type: "object" } },
34
+ required: ["config"],
35
+ additionalProperties: false
36
+ }],
37
+ messages: {
38
+ invalidFlatValue: "{{message}}",
39
+ nonCanonicalFlatValue: "use the canonical flat value \"{{canonical}}\""
40
+ }
41
+ },
42
+ create(context) {
43
+ const option = context.options[0];
44
+ const config = option?.config || {};
45
+ const registry = (0, import_tooling.createModifierRegistry)(config).registry;
46
+ const candidates = (0, import_tooling.createCandidatePropertyVocabulary)(config);
47
+ const styleProps = (0, import_tooling.createStylePropSet)(config);
48
+ const sourceCode = context.sourceCode;
49
+ const report = (site) => {
50
+ const node = site.node;
51
+ const diagnostics = (0, import_tooling.diagnoseStyleValueProgram)(site.property, site.value, {
52
+ config,
53
+ registry,
54
+ candidates
55
+ });
56
+ for (const diagnostic of diagnostics) {
57
+ context.report({
58
+ node,
59
+ loc: {
60
+ start: sourceCode.getLocFromIndex(site.start + diagnostic.start),
61
+ end: sourceCode.getLocFromIndex(site.start + diagnostic.end)
62
+ },
63
+ messageId: "invalidFlatValue",
64
+ data: { message: diagnostic.message }
65
+ });
66
+ }
67
+ if (diagnostics.length > 0) return;
68
+ const formatted = (0, import_tooling.canonicalizeStyleValue)(site.value, registry);
69
+ if (!formatted.ok || formatted.value === site.value) return;
70
+ const canonical = formatted.value;
71
+ context.report({
72
+ node,
73
+ messageId: "nonCanonicalFlatValue",
74
+ data: { canonical },
75
+ fix(fixer) {
76
+ return fixer.replaceText(node, JSON.stringify(canonical));
77
+ }
78
+ });
79
+ };
80
+ return { "Program:exit"(program) {
81
+ const sites = (0, import_extract_estree.extractStyleSitesFromEstree)(program, { isStyleProp: (name) => styleProps.has(name) });
82
+ for (const site of sites) report(site);
83
+ } };
84
+ }
85
+ };
@@ -0,0 +1,125 @@
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
+ };