@tamagui/eslint-plugin 0.0.0-bootstrap.0 → 3.0.0-beta.643.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,67 @@
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'
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.
@@ -0,0 +1,36 @@
1
+
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all) __defProp(target, name, {
8
+ get: all[name],
9
+ enumerable: true
10
+ });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
15
+ get: () => from[key],
16
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
17
+ });
18
+ }
19
+ return to;
20
+ };
21
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
22
+ var index_exports = {};
23
+ __export(index_exports, {
24
+ default: () => index_default,
25
+ rules: () => rules,
26
+ validFlatValues: () => import_validFlatValues.validFlatValues
27
+ });
28
+ module.exports = __toCommonJS(index_exports);
29
+ var import_validFlatValues = require("./validFlatValues.cjs");
30
+ var import_validFlatValues2 = require("./validFlatValues.cjs");
31
+ const rules = { "valid-flat-values": import_validFlatValues2.validFlatValues };
32
+ const plugin = {
33
+ meta: { name: "@tamagui/eslint-plugin" },
34
+ rules
35
+ };
36
+ var index_default = plugin;
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+
3
+
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all) __defProp(target, name, {
10
+ get: all[name],
11
+ enumerable: true
12
+ });
13
+ };
14
+ var __copyProps = (to, from, except, desc) => {
15
+ if (from && typeof from === "object" || typeof from === "function") {
16
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
17
+ get: () => from[key],
18
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
19
+ });
20
+ }
21
+ return to;
22
+ };
23
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
24
+ var index_exports = {};
25
+ __export(index_exports, {
26
+ default: () => index_default,
27
+ rules: () => rules,
28
+ validFlatValues: () => import_validFlatValues.validFlatValues
29
+ });
30
+ module.exports = __toCommonJS(index_exports);
31
+ var import_validFlatValues = require("./validFlatValues.native.js");
32
+ var import_validFlatValues2 = require("./validFlatValues.native.js");
33
+ var rules = { "valid-flat-values": import_validFlatValues2.validFlatValues };
34
+ var plugin = {
35
+ meta: { name: "@tamagui/eslint-plugin" },
36
+ rules
37
+ };
38
+ var index_default = plugin;
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+
3
+
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all) __defProp(target, name, {
10
+ get: all[name],
11
+ enumerable: true
12
+ });
13
+ };
14
+ var __copyProps = (to, from, except, desc) => {
15
+ if (from && typeof from === "object" || typeof from === "function") {
16
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
17
+ get: () => from[key],
18
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
19
+ });
20
+ }
21
+ return to;
22
+ };
23
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
24
+ var index_exports = {};
25
+ __export(index_exports, {
26
+ default: () => index_default,
27
+ rules: () => rules,
28
+ validFlatValues: () => import_validFlatValues.validFlatValues
29
+ });
30
+ module.exports = __toCommonJS(index_exports);
31
+ var import_validFlatValues = require("./validFlatValues.native.js");
32
+ var import_validFlatValues2 = require("./validFlatValues.native.js");
33
+ var rules = { "valid-flat-values": import_validFlatValues2.validFlatValues };
34
+ var plugin = {
35
+ meta: { name: "@tamagui/eslint-plugin" },
36
+ rules
37
+ };
38
+ var index_default = plugin;
39
+
40
+ //# 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: () => import_validFlatValues.validFlatValues\n});\nmodule.exports = __toCommonJS(index_exports);\nvar import_validFlatValues = require(\"./validFlatValues\");\nvar import_validFlatValues2 = require(\"./validFlatValues\");\nvar rules = {\n \"valid-flat-values\": import_validFlatValues2.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,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,YAAY,UAAU,CAAC,GAAG,cAAc,EAAE,OAAO,KAAK,CAAC,GAAG,GAAG;AACzF,IAAI,gBAAgB,CAAC;AACrB,SAAS,eAAe;CACtB,eAAe;CACf,aAAa;CACb,uBAAuB,uBAAuB;AAChD,CAAC;AACD,OAAO,UAAU,aAAa,aAAa;AAC3C,IAAI,yBAAyB,QAAQ,6BAAmB;AACxD,IAAI,0BAA0B,QAAQ,6BAAmB;AACzD,IAAI,QAAQ,EACV,qBAAqB,wBAAwB,gBAC/C;AACA,IAAI,SAAS;CACX,MAAM,EACJ,MAAM,yBACR;CACA;AACF;AACA,IAAI,gBAAgB"}
@@ -0,0 +1,86 @@
1
+
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all) __defProp(target, name, {
8
+ get: all[name],
9
+ enumerable: true
10
+ });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
15
+ get: () => from[key],
16
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
17
+ });
18
+ }
19
+ return to;
20
+ };
21
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
22
+ var validFlatValues_exports = {};
23
+ __export(validFlatValues_exports, { validFlatValues: () => validFlatValues });
24
+ module.exports = __toCommonJS(validFlatValues_exports);
25
+ var import_extract_estree = require("@tamagui/language-service/extract-estree");
26
+ var import_tooling = require("@tamagui/style-grammar/tooling");
27
+ const validFlatValues = {
28
+ meta: {
29
+ type: "problem",
30
+ fixable: "code",
31
+ docs: { description: "validate static Tamagui flat values with @tamagui/style-grammar" },
32
+ schema: [{
33
+ type: "object",
34
+ properties: { config: { type: "object" } },
35
+ required: ["config"],
36
+ additionalProperties: false
37
+ }],
38
+ messages: {
39
+ invalidFlatValue: "{{message}}",
40
+ nonCanonicalFlatValue: "use the canonical flat value \"{{canonical}}\""
41
+ }
42
+ },
43
+ create(context) {
44
+ const option = context.options[0];
45
+ const config = option?.config || {};
46
+ const registry = (0, import_tooling.createModifierRegistry)(config).registry;
47
+ const candidates = (0, import_tooling.createCandidatePropertyVocabulary)(config);
48
+ const styleProps = (0, import_tooling.createStylePropSet)(config);
49
+ const sourceCode = context.sourceCode;
50
+ const report = (site) => {
51
+ const node = site.node;
52
+ const diagnostics = (0, import_tooling.diagnoseStyleValueProgram)(site.property, site.value, {
53
+ config,
54
+ registry,
55
+ candidates
56
+ });
57
+ for (const diagnostic of diagnostics) {
58
+ context.report({
59
+ node,
60
+ loc: {
61
+ start: sourceCode.getLocFromIndex(site.start + diagnostic.start),
62
+ end: sourceCode.getLocFromIndex(site.start + diagnostic.end)
63
+ },
64
+ messageId: "invalidFlatValue",
65
+ data: { message: diagnostic.message }
66
+ });
67
+ }
68
+ if (diagnostics.length > 0) return;
69
+ const formatted = (0, import_tooling.canonicalizeStyleValue)(site.value, registry);
70
+ if (!formatted.ok || formatted.value === site.value) return;
71
+ const 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
+ const sites = (0, import_extract_estree.extractStyleSitesFromEstree)(program, { isStyleProp: (name) => styleProps.has(name) });
83
+ for (const site of sites) report(site);
84
+ } };
85
+ }
86
+ };
@@ -0,0 +1,126 @@
1
+ "use strict";
2
+
3
+
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all) __defProp(target, name, {
10
+ get: all[name],
11
+ enumerable: true
12
+ });
13
+ };
14
+ var __copyProps = (to, from, except, desc) => {
15
+ if (from && typeof from === "object" || typeof from === "function") {
16
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
17
+ get: () => from[key],
18
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
19
+ });
20
+ }
21
+ return to;
22
+ };
23
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
24
+ var validFlatValues_exports = {};
25
+ __export(validFlatValues_exports, { validFlatValues: () => validFlatValues });
26
+ module.exports = __toCommonJS(validFlatValues_exports);
27
+ var import_extract_estree = require("@tamagui/language-service/extract-estree");
28
+ var import_tooling = require("@tamagui/style-grammar/tooling");
29
+ var validFlatValues = {
30
+ meta: {
31
+ type: "problem",
32
+ fixable: "code",
33
+ docs: { description: "validate static Tamagui flat values with @tamagui/style-grammar" },
34
+ schema: [{
35
+ type: "object",
36
+ properties: { config: { type: "object" } },
37
+ required: ["config"],
38
+ additionalProperties: false
39
+ }],
40
+ messages: {
41
+ invalidFlatValue: "{{message}}",
42
+ nonCanonicalFlatValue: "use the canonical flat value \"{{canonical}}\""
43
+ }
44
+ },
45
+ create(context) {
46
+ var option = context.options[0];
47
+ var config = (option === null || option === void 0 ? void 0 : option.config) || {};
48
+ var registry = (0, import_tooling.createModifierRegistry)(config).registry;
49
+ var candidates = (0, import_tooling.createCandidatePropertyVocabulary)(config);
50
+ var styleProps = (0, import_tooling.createStylePropSet)(config);
51
+ var sourceCode = context.sourceCode;
52
+ var report = function(site) {
53
+ var node = site.node;
54
+ var diagnostics = (0, import_tooling.diagnoseStyleValueProgram)(site.property, site.value, {
55
+ config,
56
+ registry,
57
+ candidates
58
+ });
59
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
60
+ try {
61
+ for (var _iterator = diagnostics[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
62
+ var diagnostic = _step.value;
63
+ context.report({
64
+ node,
65
+ loc: {
66
+ start: sourceCode.getLocFromIndex(site.start + diagnostic.start),
67
+ end: sourceCode.getLocFromIndex(site.start + diagnostic.end)
68
+ },
69
+ messageId: "invalidFlatValue",
70
+ data: { message: diagnostic.message }
71
+ });
72
+ }
73
+ } catch (err) {
74
+ _didIteratorError = true;
75
+ _iteratorError = err;
76
+ } finally {
77
+ try {
78
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
79
+ _iterator.return();
80
+ }
81
+ } finally {
82
+ if (_didIteratorError) {
83
+ throw _iteratorError;
84
+ }
85
+ }
86
+ }
87
+ if (diagnostics.length > 0) return;
88
+ var formatted = (0, import_tooling.canonicalizeStyleValue)(site.value, registry);
89
+ if (!formatted.ok || formatted.value === site.value) return;
90
+ var canonical = formatted.value;
91
+ context.report({
92
+ node,
93
+ messageId: "nonCanonicalFlatValue",
94
+ data: { canonical },
95
+ fix(fixer) {
96
+ return fixer.replaceText(node, JSON.stringify(canonical));
97
+ }
98
+ });
99
+ };
100
+ return { "Program:exit"(program) {
101
+ var sites = (0, import_extract_estree.extractStyleSitesFromEstree)(program, { isStyleProp: function(name) {
102
+ return styleProps.has(name);
103
+ } });
104
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
105
+ try {
106
+ for (var _iterator = sites[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
107
+ var site = _step.value;
108
+ report(site);
109
+ }
110
+ } catch (err) {
111
+ _didIteratorError = true;
112
+ _iteratorError = err;
113
+ } finally {
114
+ try {
115
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
116
+ _iterator.return();
117
+ }
118
+ } finally {
119
+ if (_didIteratorError) {
120
+ throw _iteratorError;
121
+ }
122
+ }
123
+ }
124
+ } };
125
+ }
126
+ };
@@ -0,0 +1,128 @@
1
+ "use strict";
2
+
3
+
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all) __defProp(target, name, {
10
+ get: all[name],
11
+ enumerable: true
12
+ });
13
+ };
14
+ var __copyProps = (to, from, except, desc) => {
15
+ if (from && typeof from === "object" || typeof from === "function") {
16
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
17
+ get: () => from[key],
18
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
19
+ });
20
+ }
21
+ return to;
22
+ };
23
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
24
+ var validFlatValues_exports = {};
25
+ __export(validFlatValues_exports, { validFlatValues: () => validFlatValues });
26
+ module.exports = __toCommonJS(validFlatValues_exports);
27
+ var import_extract_estree = require("@tamagui/language-service/extract-estree");
28
+ var import_tooling = require("@tamagui/style-grammar/tooling");
29
+ var validFlatValues = {
30
+ meta: {
31
+ type: "problem",
32
+ fixable: "code",
33
+ docs: { description: "validate static Tamagui flat values with @tamagui/style-grammar" },
34
+ schema: [{
35
+ type: "object",
36
+ properties: { config: { type: "object" } },
37
+ required: ["config"],
38
+ additionalProperties: false
39
+ }],
40
+ messages: {
41
+ invalidFlatValue: "{{message}}",
42
+ nonCanonicalFlatValue: "use the canonical flat value \"{{canonical}}\""
43
+ }
44
+ },
45
+ create(context) {
46
+ var option = context.options[0];
47
+ var config = (option === null || option === void 0 ? void 0 : option.config) || {};
48
+ var registry = (0, import_tooling.createModifierRegistry)(config).registry;
49
+ var candidates = (0, import_tooling.createCandidatePropertyVocabulary)(config);
50
+ var styleProps = (0, import_tooling.createStylePropSet)(config);
51
+ var sourceCode = context.sourceCode;
52
+ var report = function(site) {
53
+ var node = site.node;
54
+ var diagnostics = (0, import_tooling.diagnoseStyleValueProgram)(site.property, site.value, {
55
+ config,
56
+ registry,
57
+ candidates
58
+ });
59
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
60
+ try {
61
+ for (var _iterator = diagnostics[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
62
+ var diagnostic = _step.value;
63
+ context.report({
64
+ node,
65
+ loc: {
66
+ start: sourceCode.getLocFromIndex(site.start + diagnostic.start),
67
+ end: sourceCode.getLocFromIndex(site.start + diagnostic.end)
68
+ },
69
+ messageId: "invalidFlatValue",
70
+ data: { message: diagnostic.message }
71
+ });
72
+ }
73
+ } catch (err) {
74
+ _didIteratorError = true;
75
+ _iteratorError = err;
76
+ } finally {
77
+ try {
78
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
79
+ _iterator.return();
80
+ }
81
+ } finally {
82
+ if (_didIteratorError) {
83
+ throw _iteratorError;
84
+ }
85
+ }
86
+ }
87
+ if (diagnostics.length > 0) return;
88
+ var formatted = (0, import_tooling.canonicalizeStyleValue)(site.value, registry);
89
+ if (!formatted.ok || formatted.value === site.value) return;
90
+ var canonical = formatted.value;
91
+ context.report({
92
+ node,
93
+ messageId: "nonCanonicalFlatValue",
94
+ data: { canonical },
95
+ fix(fixer) {
96
+ return fixer.replaceText(node, JSON.stringify(canonical));
97
+ }
98
+ });
99
+ };
100
+ return { "Program:exit"(program) {
101
+ var sites = (0, import_extract_estree.extractStyleSitesFromEstree)(program, { isStyleProp: function(name) {
102
+ return styleProps.has(name);
103
+ } });
104
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
105
+ try {
106
+ for (var _iterator = sites[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
107
+ var site = _step.value;
108
+ report(site);
109
+ }
110
+ } catch (err) {
111
+ _didIteratorError = true;
112
+ _iteratorError = err;
113
+ } finally {
114
+ try {
115
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
116
+ _iterator.return();
117
+ }
118
+ } finally {
119
+ if (_didIteratorError) {
120
+ throw _iteratorError;
121
+ }
122
+ }
123
+ }
124
+ } };
125
+ }
126
+ };
127
+
128
+ //# 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,CAA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AM;KACR;IACF;GACF;EACF,EACF;CACF;AACF"}
@@ -0,0 +1,11 @@
1
+ import { validFlatValues, validFlatValues as validFlatValues$1 } from "./validFlatValues.mjs";
2
+
3
+ const rules = { "valid-flat-values": validFlatValues$1 };
4
+ const plugin = {
5
+ meta: { name: "@tamagui/eslint-plugin" },
6
+ rules
7
+ };
8
+ var index_default = plugin;
9
+
10
+ export { index_default as default, rules, validFlatValues };
11
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["validFlatValues2"],"sources":["esm/index.js"],"sourcesContent":["import { validFlatValues } from \"./validFlatValues\";\nimport { validFlatValues as validFlatValues2 } from \"./validFlatValues\";\nconst rules = {\n \"valid-flat-values\": validFlatValues2\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":";;;AAEA,MAAM,QAAQ,EACZ,qBAAqBA,kBACvB;AACA,MAAM,SAAS;CACb,MAAM,EACJ,MAAM,yBACR;CACA;AACF;AACA,IAAI,gBAAgB"}
@@ -0,0 +1,11 @@
1
+ import { validFlatValues, validFlatValues as validFlatValues$1 } from "./validFlatValues.native.js";
2
+
3
+ var rules = { "valid-flat-values": validFlatValues$1 };
4
+ var plugin = {
5
+ meta: { name: "@tamagui/eslint-plugin" },
6
+ rules
7
+ };
8
+ var index_default = plugin;
9
+
10
+ export { index_default as default, rules, validFlatValues };
11
+ //# sourceMappingURL=index.native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.native.js","names":["validFlatValues2"],"sources":["esm/index.native.js"],"sourcesContent":["import { validFlatValues } from \"./validFlatValues\";\nimport { validFlatValues as validFlatValues2 } from \"./validFlatValues\";\nvar rules = {\n \"valid-flat-values\": validFlatValues2\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,QAAQ,EACV,qBAAqBA,kBACvB;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 }\n};\nexport {\n validFlatValues\n};\n//# sourceMappingURL=validFlatValues.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,EACV,QAAQ,EACN,MAAM,SACR,EACF;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,WAAW,uBAAuB,MAAM,EAAE;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;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"}
@@ -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,MAAM;EACJ,MAAM;EACN,SAAS;EACT,MAAM,EACJ,aAAa,kEACf;EACA,QAAQ,CACN;GACE,MAAM;GACN,YAAY,EACV,QAAQ,EACN,MAAM,SACR,EACF;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,WAAW,uBAAuB,MAAM,EAAE;EAC9C,IAAI,aAAa,kCAAkC,MAAM;EACzD,IAAI,aAAa,mBAAmB,MAAM;EAC1C,IAAI,aAAa,QAAQ;EAC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GACvF,IAAI;IACF,KAAK,IAAI,YAAY,MAAM,OAAO,UAAU,GAAG,OAAO,EAAE,6BAA6B,QAAQ,UAAU,KAAK,GAAG,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": "0.0.0-bootstrap.0",
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.643.1",
9
4
  "license": "MIT",
5
+ "type": "module",
6
+ "sideEffects": false,
7
+ "source": "src/index.ts",
10
8
  "files": [
11
- "README.md"
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.643.1",
35
+ "@tamagui/language-service": "3.0.0-beta.643.1"
36
+ },
37
+ "peerDependencies": {
38
+ "eslint": ">=9"
39
+ },
40
+ "devDependencies": {
41
+ "@tamagui/build": "3.0.0-beta.643.1",
42
+ "@typescript-eslint/parser": "8.65.0",
43
+ "eslint": "10.8.0",
44
+ "vitest": "4.0.4"
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
  }
package/src/index.ts ADDED
@@ -0,0 +1,28 @@
1
+ export { validFlatValues } from './validFlatValues'
2
+
3
+ import type { Rule } from 'eslint'
4
+ import { validFlatValues } from './validFlatValues'
5
+
6
+ export interface TamaguiEslintRules {
7
+ 'valid-flat-values': Rule.RuleModule
8
+ }
9
+
10
+ export interface TamaguiEslintPlugin {
11
+ meta: {
12
+ name: string
13
+ }
14
+ rules: TamaguiEslintRules
15
+ }
16
+
17
+ export const rules: TamaguiEslintRules = {
18
+ 'valid-flat-values': validFlatValues,
19
+ }
20
+
21
+ const plugin: TamaguiEslintPlugin = {
22
+ meta: {
23
+ name: '@tamagui/eslint-plugin',
24
+ },
25
+ rules,
26
+ }
27
+
28
+ export default plugin
@@ -0,0 +1,95 @@
1
+ import {
2
+ extractStyleSitesFromEstree,
3
+ type EstreeStyleSite,
4
+ } from '@tamagui/language-service/extract-estree'
5
+ import {
6
+ canonicalizeStyleValue,
7
+ createCandidatePropertyVocabulary,
8
+ createModifierRegistry,
9
+ createStylePropSet,
10
+ diagnoseStyleValueProgram,
11
+ type GrammarConfigView,
12
+ } from '@tamagui/style-grammar/tooling'
13
+ import type { Rule } from 'eslint'
14
+
15
+ type RuleOption = {
16
+ config: GrammarConfigView
17
+ }
18
+
19
+ export const validFlatValues: Rule.RuleModule = {
20
+ meta: {
21
+ type: 'problem',
22
+ fixable: 'code',
23
+ docs: {
24
+ description: 'validate static Tamagui flat values with @tamagui/style-grammar',
25
+ },
26
+ schema: [
27
+ {
28
+ type: 'object',
29
+ properties: {
30
+ config: {
31
+ type: 'object',
32
+ },
33
+ },
34
+ required: ['config'],
35
+ additionalProperties: false,
36
+ },
37
+ ],
38
+ messages: {
39
+ invalidFlatValue: '{{message}}',
40
+ nonCanonicalFlatValue: 'use the canonical flat value "{{canonical}}"',
41
+ },
42
+ },
43
+
44
+ create(context) {
45
+ const option = context.options[0] as RuleOption | undefined
46
+ const config = option?.config || {}
47
+ const registry = createModifierRegistry(config).registry
48
+ const candidates = createCandidatePropertyVocabulary(config)
49
+ const styleProps = createStylePropSet(config)
50
+ const sourceCode = context.sourceCode
51
+
52
+ const report = (site: EstreeStyleSite): void => {
53
+ const node = site.node as Rule.Node
54
+ const diagnostics = diagnoseStyleValueProgram(site.property, site.value, {
55
+ config,
56
+ registry,
57
+ candidates,
58
+ })
59
+ for (const diagnostic of diagnostics) {
60
+ context.report({
61
+ node,
62
+ // the engine reports value-relative spans; surface them exactly
63
+ loc: {
64
+ start: sourceCode.getLocFromIndex(site.start + diagnostic.start),
65
+ end: sourceCode.getLocFromIndex(site.start + diagnostic.end),
66
+ },
67
+ messageId: 'invalidFlatValue',
68
+ data: { message: diagnostic.message },
69
+ })
70
+ }
71
+ if (diagnostics.length > 0) return
72
+
73
+ const formatted = canonicalizeStyleValue(site.value, registry)
74
+ if (!formatted.ok || formatted.value === site.value) return
75
+ const canonical = formatted.value
76
+ context.report({
77
+ node,
78
+ messageId: 'nonCanonicalFlatValue',
79
+ data: { canonical },
80
+ fix(fixer) {
81
+ return fixer.replaceText(node, JSON.stringify(canonical))
82
+ },
83
+ })
84
+ }
85
+
86
+ return {
87
+ 'Program:exit'(program) {
88
+ const sites = extractStyleSitesFromEstree(program, {
89
+ isStyleProp: (name) => styleProps.has(name),
90
+ })
91
+ for (const site of sites) report(site)
92
+ },
93
+ }
94
+ },
95
+ }
@@ -0,0 +1,16 @@
1
+ export { validFlatValues } from "./validFlatValues";
2
+ import type { Rule } from "eslint";
3
+ export interface TamaguiEslintRules {
4
+ "valid-flat-values": Rule.RuleModule;
5
+ }
6
+ export interface TamaguiEslintPlugin {
7
+ meta: {
8
+ name: string;
9
+ };
10
+ rules: TamaguiEslintRules;
11
+ }
12
+ export declare const rules: TamaguiEslintRules;
13
+ declare const plugin: TamaguiEslintPlugin;
14
+ export default plugin;
15
+
16
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,11 @@
1
+ {
2
+ "mappings": "AAAA,SAAS,uBAAuB;AAEhC,cAAc,YAAY;AAG1B,iBAAiB,mBAAmB;CAClC,qBAAqB,KAAK;;AAG5B,iBAAiB,oBAAoB;CACnC,MAAM;EACJ;;CAEF,OAAO;;AAGT,OAAO,cAAM,OAAO;AAIpB,cAAM,QAAQ;AAOd,eAAe",
3
+ "names": [],
4
+ "sources": [
5
+ "src/index.ts"
6
+ ],
7
+ "version": 3,
8
+ "sourcesContent": [
9
+ "export { validFlatValues } from './validFlatValues'\n\nimport type { Rule } from 'eslint'\nimport { validFlatValues } from './validFlatValues'\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
+ ]
11
+ }
@@ -0,0 +1,4 @@
1
+ import type { Rule } from "eslint";
2
+ export declare const validFlatValues: Rule.RuleModule;
3
+
4
+ //# sourceMappingURL=validFlatValues.d.ts.map
@@ -0,0 +1,11 @@
1
+ {
2
+ "mappings": "AAYA,cAAc,YAAY;AAM1B,OAAO,cAAM,iBAAiB,KAAK",
3
+ "names": [],
4
+ "sources": [
5
+ "src/validFlatValues.ts"
6
+ ],
7
+ "version": 3,
8
+ "sourcesContent": [
9
+ "import {\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'\nimport type { Rule } from 'eslint'\n\ntype RuleOption = {\n config: GrammarConfigView\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 },\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 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 })\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"
10
+ ]
11
+ }