@vue-jsx-vapor/eslint 2.3.0 → 2.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +523 -597
- package/dist/index.d.cts +34 -39
- package/dist/index.d.ts +34 -39
- package/dist/index.js +496 -597
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -1,634 +1,560 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
schema: [
|
|
20
|
-
{
|
|
21
|
-
type: "object",
|
|
22
|
-
properties: {
|
|
23
|
-
tabWidth: {
|
|
24
|
-
type: "number",
|
|
25
|
-
default: 2
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
]
|
|
30
|
-
},
|
|
31
|
-
create(context) {
|
|
32
|
-
const configuration = context.options[0] || {};
|
|
33
|
-
const tabWidth = configuration.tabWidth || 2;
|
|
34
|
-
return {
|
|
35
|
-
CallExpression(node) {
|
|
36
|
-
const callee = node.callee.type === "MemberExpression" ? node.callee.object : node.callee;
|
|
37
|
-
const offset = callee.loc.start.column;
|
|
38
|
-
const parser = node.callee.type === "MemberExpression" && node.callee.property.type === "Identifier" ? node.callee.property.name : "css";
|
|
39
|
-
if (callee.type === "Identifier" && callee.name === "defineStyle") {
|
|
40
|
-
const arg = node.arguments[0];
|
|
41
|
-
if (_optionalChain([arg, 'optionalAccess', _ => _.type]) === "TemplateLiteral") {
|
|
42
|
-
const cssRaw = arg.quasis[0].value.raw;
|
|
43
|
-
let formattedCss = "";
|
|
44
|
-
try {
|
|
45
|
-
formattedCss = _sync2.default.format(cssRaw, { parser, tabWidth });
|
|
46
|
-
} catch (e) {
|
|
47
|
-
return context.report({
|
|
48
|
-
node: arg,
|
|
49
|
-
messageId: "define-style-syntax-error"
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
const placeholder = " ".repeat(offset + tabWidth);
|
|
53
|
-
const result = `
|
|
54
|
-
${placeholder}${formattedCss.slice(0, -1).replaceAll("\n", `
|
|
55
|
-
${placeholder}`)}
|
|
56
|
-
${" ".repeat(offset)}`;
|
|
57
|
-
if (result !== cssRaw) {
|
|
58
|
-
context.report({
|
|
59
|
-
node: arg,
|
|
60
|
-
messageId: "define-style",
|
|
61
|
-
fix(fixer) {
|
|
62
|
-
return fixer.replaceTextRange(
|
|
63
|
-
[arg.range[0] + 1, arg.range[1] - 1],
|
|
64
|
-
result
|
|
65
|
-
);
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
};
|
|
73
|
-
}
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
3
|
+
//#region rolldown:runtime
|
|
4
|
+
var __create = Object.create;
|
|
5
|
+
var __defProp = Object.defineProperty;
|
|
6
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
9
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
12
|
+
key = keys[i];
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
14
|
+
get: ((k) => from[k]).bind(null, key),
|
|
15
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
74
19
|
};
|
|
75
|
-
var
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
21
|
+
value: mod,
|
|
22
|
+
enumerable: true
|
|
23
|
+
}) : target, mod));
|
|
76
24
|
|
|
77
|
-
|
|
78
|
-
|
|
25
|
+
//#endregion
|
|
26
|
+
const __prettier_sync = __toESM(require("@prettier/sync"));
|
|
27
|
+
|
|
28
|
+
//#region src/rules/define-style/index.ts
|
|
29
|
+
const rule$1 = {
|
|
30
|
+
defaultOptions: [{ tabWidth: 2 }],
|
|
31
|
+
meta: {
|
|
32
|
+
type: "layout",
|
|
33
|
+
docs: { description: "Enforce consistent formatting in defineStyle CSS" },
|
|
34
|
+
fixable: "code",
|
|
35
|
+
messages: {
|
|
36
|
+
"define-style": "Style in defineStyle should be properly formatted",
|
|
37
|
+
"define-style-syntax-error": "Syntax error in defineStyle"
|
|
38
|
+
},
|
|
39
|
+
schema: [{
|
|
40
|
+
type: "object",
|
|
41
|
+
properties: { tabWidth: {
|
|
42
|
+
type: "number",
|
|
43
|
+
default: 2
|
|
44
|
+
} }
|
|
45
|
+
}]
|
|
46
|
+
},
|
|
47
|
+
create(context) {
|
|
48
|
+
const configuration = context.options[0] || {};
|
|
49
|
+
const tabWidth = configuration.tabWidth || 2;
|
|
50
|
+
return { CallExpression(node) {
|
|
51
|
+
const callee = node.callee.type === "MemberExpression" ? node.callee.object : node.callee;
|
|
52
|
+
const offset = callee.loc.start.column;
|
|
53
|
+
const parser = node.callee.type === "MemberExpression" && node.callee.property.type === "Identifier" ? node.callee.property.name : "css";
|
|
54
|
+
if (callee.type === "Identifier" && callee.name === "defineStyle") {
|
|
55
|
+
const arg = node.arguments[0];
|
|
56
|
+
if (arg?.type === "TemplateLiteral") {
|
|
57
|
+
const cssRaw = arg.quasis[0].value.raw;
|
|
58
|
+
let formattedCss = "";
|
|
59
|
+
try {
|
|
60
|
+
formattedCss = __prettier_sync.default.format(cssRaw, {
|
|
61
|
+
parser,
|
|
62
|
+
tabWidth
|
|
63
|
+
});
|
|
64
|
+
} catch {
|
|
65
|
+
return context.report({
|
|
66
|
+
node: arg,
|
|
67
|
+
messageId: "define-style-syntax-error"
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
const placeholder = " ".repeat(offset + tabWidth);
|
|
71
|
+
const result = `\n${placeholder}${formattedCss.slice(0, -1).replaceAll("\n", `\n${placeholder}`)}\n${" ".repeat(offset)}`;
|
|
72
|
+
if (result !== cssRaw) context.report({
|
|
73
|
+
node: arg,
|
|
74
|
+
messageId: "define-style",
|
|
75
|
+
fix(fixer) {
|
|
76
|
+
return fixer.replaceTextRange([arg.range[0] + 1, arg.range[1] - 1], result);
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
} };
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
var define_style_default = rule$1;
|
|
85
|
+
|
|
86
|
+
//#endregion
|
|
87
|
+
//#region src/rules/jsx-sort-props/index.ts
|
|
88
|
+
const COMPAT_TAG_REGEX = /^[a-z]/;
|
|
89
|
+
/**
|
|
90
|
+
* Checks if a node represents a DOM element according to React.
|
|
91
|
+
* @param node - JSXOpeningElement to check.
|
|
92
|
+
* @returns Whether or not the node corresponds to a DOM element.
|
|
93
|
+
*/
|
|
79
94
|
function isDOMComponent(node) {
|
|
80
|
-
|
|
81
|
-
|
|
95
|
+
const name = getElementType(node);
|
|
96
|
+
return COMPAT_TAG_REGEX.test(name);
|
|
82
97
|
}
|
|
98
|
+
/**
|
|
99
|
+
* Returns the name of the prop given the JSXAttribute object.
|
|
100
|
+
*
|
|
101
|
+
* Ported from `jsx-ast-utils/propName` to reduce bundle size
|
|
102
|
+
* @see https://github.com/jsx-eslint/jsx-ast-utils/blob/main/src/propName.js
|
|
103
|
+
*/
|
|
83
104
|
function getPropName(prop) {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
);
|
|
88
|
-
if (prop.name.type === "JSXNamespacedName")
|
|
89
|
-
return `${prop.name.namespace.name}:${prop.name.name.name}`;
|
|
90
|
-
return prop.name.name;
|
|
105
|
+
if (!prop.type || prop.type !== "JSXAttribute") throw new Error("The prop must be a JSXAttribute collected by the AST parser.");
|
|
106
|
+
if (prop.name.type === "JSXNamespacedName") return `${prop.name.namespace.name}:${prop.name.name.name}`;
|
|
107
|
+
return prop.name.name;
|
|
91
108
|
}
|
|
92
109
|
function resolveMemberExpressions(object, property) {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
return `${object.name}.${property.name}`;
|
|
110
|
+
if (object.type === "JSXMemberExpression") return `${resolveMemberExpressions(object.object, object.property)}.${property.name}`;
|
|
111
|
+
return `${object.name}.${property.name}`;
|
|
96
112
|
}
|
|
113
|
+
/**
|
|
114
|
+
* Returns the tagName associated with a JSXElement.
|
|
115
|
+
*
|
|
116
|
+
* Ported from `jsx-ast-utils/elementType` to reduce bundle size
|
|
117
|
+
* @see https://github.com/jsx-eslint/jsx-ast-utils/blob/main/src/elementType.js
|
|
118
|
+
*/
|
|
97
119
|
function getElementType(node) {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
return node.name.name;
|
|
120
|
+
if (node.type === "JSXOpeningFragment") return "<>";
|
|
121
|
+
const { name } = node;
|
|
122
|
+
if (!name) throw new Error("The argument provided is not a JSXElement node.");
|
|
123
|
+
if (name.type === "JSXMemberExpression") {
|
|
124
|
+
const { object, property } = name;
|
|
125
|
+
return resolveMemberExpressions(object, property);
|
|
126
|
+
}
|
|
127
|
+
if (name.type === "JSXNamespacedName") return `${name.namespace.name}:${name.name.name}`;
|
|
128
|
+
return node.name.name;
|
|
108
129
|
}
|
|
109
130
|
function isCallbackPropName(name) {
|
|
110
|
-
|
|
131
|
+
return /^on[A-Z]/.test(name);
|
|
111
132
|
}
|
|
112
133
|
function isMultilineProp(node) {
|
|
113
|
-
|
|
134
|
+
return node.loc.start.line !== node.loc.end.line;
|
|
114
135
|
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
136
|
+
const messages = {
|
|
137
|
+
listIsEmpty: "A customized reserved first list must not be empty",
|
|
138
|
+
listReservedPropsFirst: "Reserved props must be listed before all other props",
|
|
139
|
+
listReservedPropsLast: "Reserved props must be listed after all other props",
|
|
140
|
+
listCallbacksLast: "Callbacks must be listed after all other props",
|
|
141
|
+
listShorthandFirst: "Shorthand props must be listed before all other props",
|
|
142
|
+
listShorthandLast: "Shorthand props must be listed after all other props",
|
|
143
|
+
listMultilineFirst: "Multiline props must be listed before all other props",
|
|
144
|
+
listMultilineLast: "Multiline props must be listed after all other props",
|
|
145
|
+
sortPropsByAlpha: "Props should be sorted alphabetically"
|
|
125
146
|
};
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
147
|
+
const RESERVED_PROPS_LIST = [
|
|
148
|
+
"children",
|
|
149
|
+
"dangerouslySetInnerHTML",
|
|
150
|
+
"key",
|
|
151
|
+
"ref"
|
|
131
152
|
];
|
|
132
153
|
function getReservedPropIndex(name, list) {
|
|
133
|
-
|
|
154
|
+
return list.indexOf(name.split(":")[0]);
|
|
134
155
|
}
|
|
135
|
-
|
|
156
|
+
let attributeMap;
|
|
136
157
|
function shouldSortToEnd(node) {
|
|
137
|
-
|
|
138
|
-
|
|
158
|
+
const attr = attributeMap.get(node);
|
|
159
|
+
return !!attr && !!attr.hasComment;
|
|
139
160
|
}
|
|
140
161
|
function contextCompare(a, b, options) {
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
if (options.locale === "auto") return aProp < bProp ? -1 : 1;
|
|
192
|
-
return aProp.localeCompare(bProp, actualLocale);
|
|
162
|
+
let aProp = getPropName(a);
|
|
163
|
+
let bProp = getPropName(b);
|
|
164
|
+
const aPropWithoutNamespace = aProp.split(":")[0];
|
|
165
|
+
const bPropWithoutNamespace = bProp.split(":")[0];
|
|
166
|
+
const aSortToEnd = shouldSortToEnd(a);
|
|
167
|
+
const bSortToEnd = shouldSortToEnd(b);
|
|
168
|
+
if (aSortToEnd && !bSortToEnd) return 1;
|
|
169
|
+
if (!aSortToEnd && bSortToEnd) return -1;
|
|
170
|
+
if (options.reservedFirst) {
|
|
171
|
+
const aIndex = getReservedPropIndex(aProp, options.reservedList);
|
|
172
|
+
const bIndex = getReservedPropIndex(bProp, options.reservedList);
|
|
173
|
+
if (aIndex > -1 && bIndex === -1) return -1;
|
|
174
|
+
if (aIndex === -1 && bIndex > -1) return 1;
|
|
175
|
+
if (aIndex > -1 && bIndex > -1 && aPropWithoutNamespace !== bPropWithoutNamespace) return aIndex > bIndex ? 1 : -1;
|
|
176
|
+
}
|
|
177
|
+
if (options.reservedLast.length > 0) {
|
|
178
|
+
const aLastIndex = getReservedPropIndex(aProp, options.reservedLast);
|
|
179
|
+
const bLastIndex = getReservedPropIndex(bProp, options.reservedLast);
|
|
180
|
+
if (aLastIndex > -1 && bLastIndex === -1) return 1;
|
|
181
|
+
if (aLastIndex === -1 && bLastIndex > -1) return -1;
|
|
182
|
+
if (aLastIndex > -1 && bLastIndex > -1 && aPropWithoutNamespace !== bPropWithoutNamespace) return aLastIndex > bLastIndex ? 1 : -1;
|
|
183
|
+
}
|
|
184
|
+
if (options.callbacksLast) {
|
|
185
|
+
const aIsCallback = isCallbackPropName(aProp);
|
|
186
|
+
const bIsCallback = isCallbackPropName(bProp);
|
|
187
|
+
if (aIsCallback && !bIsCallback) return 1;
|
|
188
|
+
if (!aIsCallback && bIsCallback) return -1;
|
|
189
|
+
}
|
|
190
|
+
if (options.shorthandFirst || options.shorthandLast) {
|
|
191
|
+
const shorthandSign = options.shorthandFirst ? -1 : 1;
|
|
192
|
+
if (!a.value && b.value) return shorthandSign;
|
|
193
|
+
if (a.value && !b.value) return -shorthandSign;
|
|
194
|
+
}
|
|
195
|
+
if (options.multiline !== "ignore") {
|
|
196
|
+
const multilineSign = options.multiline === "first" ? -1 : 1;
|
|
197
|
+
const aIsMultiline = isMultilineProp(a);
|
|
198
|
+
const bIsMultiline = isMultilineProp(b);
|
|
199
|
+
if (aIsMultiline && !bIsMultiline) return multilineSign;
|
|
200
|
+
if (!aIsMultiline && bIsMultiline) return -multilineSign;
|
|
201
|
+
}
|
|
202
|
+
if (options.noSortAlphabetically) return 0;
|
|
203
|
+
const actualLocale = options.locale === "auto" ? void 0 : options.locale;
|
|
204
|
+
if (options.ignoreCase) {
|
|
205
|
+
aProp = aProp.toLowerCase();
|
|
206
|
+
bProp = bProp.toLowerCase();
|
|
207
|
+
return aProp.localeCompare(bProp, actualLocale);
|
|
208
|
+
}
|
|
209
|
+
if (aProp === bProp) return 0;
|
|
210
|
+
if (options.locale === "auto") return aProp < bProp ? -1 : 1;
|
|
211
|
+
return aProp.localeCompare(bProp, actualLocale);
|
|
193
212
|
}
|
|
213
|
+
/**
|
|
214
|
+
* Create an array of arrays where each subarray is composed of attributes
|
|
215
|
+
* that are considered sortable.
|
|
216
|
+
* @param attributes
|
|
217
|
+
* @param context The context of the rule
|
|
218
|
+
*/
|
|
194
219
|
function getGroupsOfSortableAttributes(attributes, context) {
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
}
|
|
266
|
-
addtoSortableAttributeGroups(attribute);
|
|
267
|
-
i += 1;
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
return sortableAttributeGroups;
|
|
220
|
+
const sourceCode = context.sourceCode;
|
|
221
|
+
const sortableAttributeGroups = [];
|
|
222
|
+
let groupCount = 0;
|
|
223
|
+
function addtoSortableAttributeGroups(attribute) {
|
|
224
|
+
sortableAttributeGroups[groupCount - 1].push(attribute);
|
|
225
|
+
}
|
|
226
|
+
for (let i = 0; i < attributes.length; i++) {
|
|
227
|
+
const attribute = attributes[i];
|
|
228
|
+
const nextAttribute = attributes[i + 1];
|
|
229
|
+
const attributeline = attribute.loc.start.line;
|
|
230
|
+
let comment = [];
|
|
231
|
+
try {
|
|
232
|
+
comment = sourceCode.getCommentsAfter(attribute);
|
|
233
|
+
} catch {}
|
|
234
|
+
const lastAttr = attributes[i - 1];
|
|
235
|
+
const attrIsSpread = attribute.type === "JSXSpreadAttribute";
|
|
236
|
+
if (!lastAttr || lastAttr.type === "JSXSpreadAttribute" && !attrIsSpread) {
|
|
237
|
+
groupCount += 1;
|
|
238
|
+
sortableAttributeGroups[groupCount - 1] = [];
|
|
239
|
+
}
|
|
240
|
+
if (!attrIsSpread) if (comment.length === 0) {
|
|
241
|
+
attributeMap.set(attribute, {
|
|
242
|
+
end: attribute.range[1],
|
|
243
|
+
hasComment: false
|
|
244
|
+
});
|
|
245
|
+
addtoSortableAttributeGroups(attribute);
|
|
246
|
+
} else {
|
|
247
|
+
const firstComment = comment[0];
|
|
248
|
+
const commentline = firstComment.loc.start.line;
|
|
249
|
+
if (comment.length === 1) {
|
|
250
|
+
if (attributeline + 1 === commentline && nextAttribute) {
|
|
251
|
+
attributeMap.set(attribute, {
|
|
252
|
+
end: nextAttribute.range[1],
|
|
253
|
+
hasComment: true
|
|
254
|
+
});
|
|
255
|
+
addtoSortableAttributeGroups(attribute);
|
|
256
|
+
i += 1;
|
|
257
|
+
} else if (attributeline === commentline) {
|
|
258
|
+
if (firstComment.type === "Block" && nextAttribute) {
|
|
259
|
+
attributeMap.set(attribute, {
|
|
260
|
+
end: nextAttribute.range[1],
|
|
261
|
+
hasComment: true
|
|
262
|
+
});
|
|
263
|
+
i += 1;
|
|
264
|
+
} else if (firstComment.type === "Block") attributeMap.set(attribute, {
|
|
265
|
+
end: firstComment.range[1],
|
|
266
|
+
hasComment: true
|
|
267
|
+
});
|
|
268
|
+
else attributeMap.set(attribute, {
|
|
269
|
+
end: firstComment.range[1],
|
|
270
|
+
hasComment: false
|
|
271
|
+
});
|
|
272
|
+
addtoSortableAttributeGroups(attribute);
|
|
273
|
+
}
|
|
274
|
+
} else if (comment.length > 1 && attributeline + 1 === comment[1].loc.start.line && nextAttribute) {
|
|
275
|
+
const commentNextAttribute = sourceCode.getCommentsAfter(nextAttribute);
|
|
276
|
+
attributeMap.set(attribute, {
|
|
277
|
+
end: nextAttribute.range[1],
|
|
278
|
+
hasComment: true
|
|
279
|
+
});
|
|
280
|
+
if (commentNextAttribute.length === 1 && nextAttribute.loc.start.line === commentNextAttribute[0].loc.start.line) attributeMap.set(attribute, {
|
|
281
|
+
end: commentNextAttribute[0].range[1],
|
|
282
|
+
hasComment: true
|
|
283
|
+
});
|
|
284
|
+
addtoSortableAttributeGroups(attribute);
|
|
285
|
+
i += 1;
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
return sortableAttributeGroups;
|
|
273
290
|
}
|
|
274
291
|
function generateFixerFunction(node, context, reservedList) {
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
const rangeEnd = firstFixer ? firstFixer.range[1] : -0;
|
|
325
|
-
fixers.forEach((fix) => {
|
|
326
|
-
source = `${source.slice(0, fix.range[0])}${fix.text}${source.slice(fix.range[1])}`;
|
|
327
|
-
});
|
|
328
|
-
return fixer.replaceTextRange(
|
|
329
|
-
[rangeStart, rangeEnd],
|
|
330
|
-
source.slice(rangeStart, rangeEnd)
|
|
331
|
-
);
|
|
332
|
-
};
|
|
292
|
+
const sourceCode = context.sourceCode;
|
|
293
|
+
const attributes = node.attributes.slice(0);
|
|
294
|
+
const configuration = context.options[0] || {};
|
|
295
|
+
const ignoreCase = configuration.ignoreCase || false;
|
|
296
|
+
const callbacksLast = configuration.callbacksLast || false;
|
|
297
|
+
const shorthandFirst = configuration.shorthandFirst || false;
|
|
298
|
+
const shorthandLast = configuration.shorthandLast || false;
|
|
299
|
+
const multiline = configuration.multiline || "ignore";
|
|
300
|
+
const noSortAlphabetically = configuration.noSortAlphabetically || false;
|
|
301
|
+
const reservedFirst = configuration.reservedFirst || false;
|
|
302
|
+
const reservedLast = configuration.reservedLast || [];
|
|
303
|
+
const locale = configuration.locale || "auto";
|
|
304
|
+
const options = {
|
|
305
|
+
ignoreCase,
|
|
306
|
+
callbacksLast,
|
|
307
|
+
shorthandFirst,
|
|
308
|
+
shorthandLast,
|
|
309
|
+
multiline,
|
|
310
|
+
noSortAlphabetically,
|
|
311
|
+
reservedFirst,
|
|
312
|
+
reservedList,
|
|
313
|
+
reservedLast,
|
|
314
|
+
locale
|
|
315
|
+
};
|
|
316
|
+
const sortableAttributeGroups = getGroupsOfSortableAttributes(attributes, context);
|
|
317
|
+
const sortedAttributeGroups = sortableAttributeGroups.slice(0).map((group) => [...group].sort((a, b) => contextCompare(a, b, options)));
|
|
318
|
+
return function fixFunction(fixer) {
|
|
319
|
+
const fixers = [];
|
|
320
|
+
let source = sourceCode.getText();
|
|
321
|
+
sortableAttributeGroups.forEach((sortableGroup, ii) => {
|
|
322
|
+
sortableGroup.forEach((attr, jj) => {
|
|
323
|
+
const sortedAttr = sortedAttributeGroups[ii][jj];
|
|
324
|
+
const sortedAttrText = source.slice(sortedAttr.range[0], attributeMap.get(sortedAttr).end);
|
|
325
|
+
fixers.push({
|
|
326
|
+
range: [attr.range[0], attributeMap.get(attr).end],
|
|
327
|
+
text: sortedAttrText
|
|
328
|
+
});
|
|
329
|
+
});
|
|
330
|
+
});
|
|
331
|
+
fixers.sort((a, b) => b.range[0] - a.range[0]);
|
|
332
|
+
const firstFixer = fixers[0];
|
|
333
|
+
const lastFixer = fixers.at(-1);
|
|
334
|
+
const rangeStart = lastFixer ? lastFixer.range[0] : 0;
|
|
335
|
+
const rangeEnd = firstFixer ? firstFixer.range[1] : -0;
|
|
336
|
+
fixers.forEach((fix) => {
|
|
337
|
+
source = `${source.slice(0, fix.range[0])}${fix.text}${source.slice(fix.range[1])}`;
|
|
338
|
+
});
|
|
339
|
+
return fixer.replaceTextRange([rangeStart, rangeEnd], source.slice(rangeStart, rangeEnd));
|
|
340
|
+
};
|
|
333
341
|
}
|
|
342
|
+
/**
|
|
343
|
+
* Checks if the `reservedFirst` option is valid
|
|
344
|
+
* @param context The context of the rule
|
|
345
|
+
* @param reservedFirst The `reservedFirst` option
|
|
346
|
+
* @return {Function|undefined} If an error is detected, a function to generate the error message, otherwise, `undefined`
|
|
347
|
+
*/
|
|
334
348
|
function validateReservedFirstConfig(context, reservedFirst) {
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
};
|
|
342
|
-
}
|
|
349
|
+
if (reservedFirst && Array.isArray(reservedFirst) && reservedFirst.length === 0) return function Report(decl) {
|
|
350
|
+
context.report({
|
|
351
|
+
node: decl,
|
|
352
|
+
messageId: "listIsEmpty"
|
|
353
|
+
});
|
|
354
|
+
};
|
|
343
355
|
}
|
|
344
|
-
|
|
356
|
+
const reportedNodeAttributes = new WeakMap();
|
|
357
|
+
/**
|
|
358
|
+
* Check if the current node attribute has already been reported with the same error type
|
|
359
|
+
* if that's the case then we don't report a new error
|
|
360
|
+
* otherwise we report the error
|
|
361
|
+
* @param nodeAttribute The node attribute to be reported
|
|
362
|
+
* @param errorType The error type to be reported
|
|
363
|
+
* @param node The parent node for the node attribute
|
|
364
|
+
* @param context The context of the rule
|
|
365
|
+
* @param reservedList The list of reserved props
|
|
366
|
+
*/
|
|
345
367
|
function reportNodeAttribute(nodeAttribute, errorType, node, context, reservedList) {
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
368
|
+
const errors = reportedNodeAttributes.get(nodeAttribute) || [];
|
|
369
|
+
if (errors.includes(errorType)) return;
|
|
370
|
+
errors.push(errorType);
|
|
371
|
+
reportedNodeAttributes.set(nodeAttribute, errors);
|
|
372
|
+
context.report({
|
|
373
|
+
node: nodeAttribute.name ?? "",
|
|
374
|
+
messageId: errorType,
|
|
375
|
+
fix: generateFixerFunction(node, context, reservedList)
|
|
376
|
+
});
|
|
355
377
|
}
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
context,
|
|
492
|
-
nodeReservedList
|
|
493
|
-
);
|
|
494
|
-
return memo;
|
|
495
|
-
}
|
|
496
|
-
}
|
|
497
|
-
if (callbacksLast) {
|
|
498
|
-
if (!previousIsCallback && currentIsCallback) {
|
|
499
|
-
return decl;
|
|
500
|
-
}
|
|
501
|
-
if (previousIsCallback && !currentIsCallback) {
|
|
502
|
-
reportNodeAttribute(
|
|
503
|
-
memo,
|
|
504
|
-
"listCallbacksLast",
|
|
505
|
-
node,
|
|
506
|
-
context,
|
|
507
|
-
nodeReservedList
|
|
508
|
-
);
|
|
509
|
-
return memo;
|
|
510
|
-
}
|
|
511
|
-
}
|
|
512
|
-
if (shorthandFirst) {
|
|
513
|
-
if (currentValue && !previousValue) return decl;
|
|
514
|
-
if (!currentValue && previousValue) {
|
|
515
|
-
reportNodeAttribute(
|
|
516
|
-
decl,
|
|
517
|
-
"listShorthandFirst",
|
|
518
|
-
node,
|
|
519
|
-
context,
|
|
520
|
-
nodeReservedList
|
|
521
|
-
);
|
|
522
|
-
return memo;
|
|
523
|
-
}
|
|
524
|
-
}
|
|
525
|
-
if (shorthandLast) {
|
|
526
|
-
if (!currentValue && previousValue) return decl;
|
|
527
|
-
if (currentValue && !previousValue) {
|
|
528
|
-
reportNodeAttribute(
|
|
529
|
-
memo,
|
|
530
|
-
"listShorthandLast",
|
|
531
|
-
node,
|
|
532
|
-
context,
|
|
533
|
-
nodeReservedList
|
|
534
|
-
);
|
|
535
|
-
return memo;
|
|
536
|
-
}
|
|
537
|
-
}
|
|
538
|
-
const previousIsMultiline = isMultilineProp(memo);
|
|
539
|
-
const currentIsMultiline = isMultilineProp(decl);
|
|
540
|
-
if (multiline === "first") {
|
|
541
|
-
if (previousIsMultiline && !currentIsMultiline) {
|
|
542
|
-
return decl;
|
|
543
|
-
}
|
|
544
|
-
if (!previousIsMultiline && currentIsMultiline) {
|
|
545
|
-
reportNodeAttribute(
|
|
546
|
-
decl,
|
|
547
|
-
"listMultilineFirst",
|
|
548
|
-
node,
|
|
549
|
-
context,
|
|
550
|
-
nodeReservedList
|
|
551
|
-
);
|
|
552
|
-
return memo;
|
|
553
|
-
}
|
|
554
|
-
} else if (multiline === "last") {
|
|
555
|
-
if (!previousIsMultiline && currentIsMultiline) {
|
|
556
|
-
return decl;
|
|
557
|
-
}
|
|
558
|
-
if (previousIsMultiline && !currentIsMultiline) {
|
|
559
|
-
reportNodeAttribute(
|
|
560
|
-
memo,
|
|
561
|
-
"listMultilineLast",
|
|
562
|
-
node,
|
|
563
|
-
context,
|
|
564
|
-
nodeReservedList
|
|
565
|
-
);
|
|
566
|
-
return memo;
|
|
567
|
-
}
|
|
568
|
-
}
|
|
569
|
-
if (!noSortAlphabetically && (ignoreCase || locale !== "auto" ? previousPropName.localeCompare(
|
|
570
|
-
currentPropName,
|
|
571
|
-
locale === "auto" ? void 0 : locale
|
|
572
|
-
) > 0 : previousPropName > currentPropName)) {
|
|
573
|
-
reportNodeAttribute(
|
|
574
|
-
decl,
|
|
575
|
-
"sortPropsByAlpha",
|
|
576
|
-
node,
|
|
577
|
-
context,
|
|
578
|
-
nodeReservedList
|
|
579
|
-
);
|
|
580
|
-
return memo;
|
|
581
|
-
}
|
|
582
|
-
return decl;
|
|
583
|
-
}, node.attributes[0]);
|
|
584
|
-
}
|
|
585
|
-
};
|
|
586
|
-
}
|
|
378
|
+
const rule = {
|
|
379
|
+
defaultOptions: [{
|
|
380
|
+
multiline: "ignore",
|
|
381
|
+
locale: "auto"
|
|
382
|
+
}],
|
|
383
|
+
meta: {
|
|
384
|
+
type: "layout",
|
|
385
|
+
docs: { description: "Enforce props alphabetical sorting" },
|
|
386
|
+
fixable: "code",
|
|
387
|
+
messages,
|
|
388
|
+
schema: [{
|
|
389
|
+
type: "object",
|
|
390
|
+
properties: {
|
|
391
|
+
callbacksLast: { type: "boolean" },
|
|
392
|
+
shorthandFirst: { type: "boolean" },
|
|
393
|
+
shorthandLast: { type: "boolean" },
|
|
394
|
+
multiline: {
|
|
395
|
+
type: "string",
|
|
396
|
+
enum: [
|
|
397
|
+
"ignore",
|
|
398
|
+
"first",
|
|
399
|
+
"last"
|
|
400
|
+
],
|
|
401
|
+
default: "ignore"
|
|
402
|
+
},
|
|
403
|
+
ignoreCase: { type: "boolean" },
|
|
404
|
+
noSortAlphabetically: { type: "boolean" },
|
|
405
|
+
reservedFirst: { type: ["array", "boolean"] },
|
|
406
|
+
reservedLast: { type: "array" },
|
|
407
|
+
locale: {
|
|
408
|
+
type: "string",
|
|
409
|
+
default: "auto"
|
|
410
|
+
}
|
|
411
|
+
},
|
|
412
|
+
additionalProperties: false
|
|
413
|
+
}]
|
|
414
|
+
},
|
|
415
|
+
create(context) {
|
|
416
|
+
const configuration = context.options[0] || {};
|
|
417
|
+
const ignoreCase = configuration.ignoreCase || false;
|
|
418
|
+
const callbacksLast = configuration.callbacksLast || false;
|
|
419
|
+
const shorthandFirst = configuration.shorthandFirst || false;
|
|
420
|
+
const shorthandLast = configuration.shorthandLast || false;
|
|
421
|
+
const multiline = configuration.multiline || "ignore";
|
|
422
|
+
const noSortAlphabetically = configuration.noSortAlphabetically || false;
|
|
423
|
+
const reservedFirst = configuration.reservedFirst || false;
|
|
424
|
+
const reservedFirstError = validateReservedFirstConfig(context, reservedFirst);
|
|
425
|
+
const reservedList = Array.isArray(reservedFirst) ? reservedFirst : RESERVED_PROPS_LIST;
|
|
426
|
+
const reservedLastList = configuration.reservedLast || [];
|
|
427
|
+
const locale = configuration.locale || "auto";
|
|
428
|
+
return {
|
|
429
|
+
Program() {
|
|
430
|
+
attributeMap = new WeakMap();
|
|
431
|
+
},
|
|
432
|
+
JSXOpeningElement(node) {
|
|
433
|
+
const nodeReservedList = reservedFirst && !isDOMComponent(node) ? reservedList.filter((prop) => prop !== "dangerouslySetInnerHTML") : reservedList;
|
|
434
|
+
node.attributes.reduce((memo, decl, idx, attrs) => {
|
|
435
|
+
if (decl.type === "JSXSpreadAttribute") return attrs[idx + 1];
|
|
436
|
+
let previousPropName = getPropName(memo);
|
|
437
|
+
let currentPropName = getPropName(decl);
|
|
438
|
+
const previousValue = memo.value;
|
|
439
|
+
const currentValue = decl.value;
|
|
440
|
+
const previousIsCallback = isCallbackPropName(previousPropName);
|
|
441
|
+
const currentIsCallback = isCallbackPropName(currentPropName);
|
|
442
|
+
if (ignoreCase) {
|
|
443
|
+
previousPropName = previousPropName.toLowerCase();
|
|
444
|
+
currentPropName = currentPropName.toLowerCase();
|
|
445
|
+
}
|
|
446
|
+
if (reservedFirst) {
|
|
447
|
+
if (reservedFirstError) {
|
|
448
|
+
reservedFirstError(decl);
|
|
449
|
+
return memo;
|
|
450
|
+
}
|
|
451
|
+
const previousReservedIndex = getReservedPropIndex(previousPropName, nodeReservedList);
|
|
452
|
+
const currentReservedIndex = getReservedPropIndex(currentPropName, nodeReservedList);
|
|
453
|
+
if (previousReservedIndex > -1 && currentReservedIndex === -1) return decl;
|
|
454
|
+
if (reservedFirst !== true && previousReservedIndex > currentReservedIndex || previousReservedIndex === -1 && currentReservedIndex > -1) {
|
|
455
|
+
reportNodeAttribute(decl, "listReservedPropsFirst", node, context, nodeReservedList);
|
|
456
|
+
return memo;
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
if (reservedLastList.length > 0) {
|
|
460
|
+
const previousReservedIndex = getReservedPropIndex(previousPropName, reservedLastList);
|
|
461
|
+
const currentReservedIndex = getReservedPropIndex(currentPropName, reservedLastList);
|
|
462
|
+
if (previousReservedIndex === -1 && currentReservedIndex > -1) return decl;
|
|
463
|
+
if (previousReservedIndex < currentReservedIndex || previousReservedIndex > -1 && currentReservedIndex === -1) {
|
|
464
|
+
reportNodeAttribute(decl, "listReservedPropsLast", node, context, nodeReservedList);
|
|
465
|
+
return memo;
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
if (callbacksLast) {
|
|
469
|
+
if (!previousIsCallback && currentIsCallback) return decl;
|
|
470
|
+
if (previousIsCallback && !currentIsCallback) {
|
|
471
|
+
reportNodeAttribute(memo, "listCallbacksLast", node, context, nodeReservedList);
|
|
472
|
+
return memo;
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
if (shorthandFirst) {
|
|
476
|
+
if (currentValue && !previousValue) return decl;
|
|
477
|
+
if (!currentValue && previousValue) {
|
|
478
|
+
reportNodeAttribute(decl, "listShorthandFirst", node, context, nodeReservedList);
|
|
479
|
+
return memo;
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
if (shorthandLast) {
|
|
483
|
+
if (!currentValue && previousValue) return decl;
|
|
484
|
+
if (currentValue && !previousValue) {
|
|
485
|
+
reportNodeAttribute(memo, "listShorthandLast", node, context, nodeReservedList);
|
|
486
|
+
return memo;
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
const previousIsMultiline = isMultilineProp(memo);
|
|
490
|
+
const currentIsMultiline = isMultilineProp(decl);
|
|
491
|
+
if (multiline === "first") {
|
|
492
|
+
if (previousIsMultiline && !currentIsMultiline) return decl;
|
|
493
|
+
if (!previousIsMultiline && currentIsMultiline) {
|
|
494
|
+
reportNodeAttribute(decl, "listMultilineFirst", node, context, nodeReservedList);
|
|
495
|
+
return memo;
|
|
496
|
+
}
|
|
497
|
+
} else if (multiline === "last") {
|
|
498
|
+
if (!previousIsMultiline && currentIsMultiline) return decl;
|
|
499
|
+
if (previousIsMultiline && !currentIsMultiline) {
|
|
500
|
+
reportNodeAttribute(memo, "listMultilineLast", node, context, nodeReservedList);
|
|
501
|
+
return memo;
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
if (!noSortAlphabetically && (ignoreCase || locale !== "auto" ? previousPropName.localeCompare(currentPropName, locale === "auto" ? void 0 : locale) > 0 : previousPropName > currentPropName)) {
|
|
505
|
+
reportNodeAttribute(decl, "sortPropsByAlpha", node, context, nodeReservedList);
|
|
506
|
+
return memo;
|
|
507
|
+
}
|
|
508
|
+
return decl;
|
|
509
|
+
}, node.attributes[0]);
|
|
510
|
+
}
|
|
511
|
+
};
|
|
512
|
+
}
|
|
587
513
|
};
|
|
588
|
-
var jsx_sort_props_default =
|
|
514
|
+
var jsx_sort_props_default = rule;
|
|
589
515
|
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
516
|
+
//#endregion
|
|
517
|
+
//#region src/rules/index.ts
|
|
518
|
+
const ruleOptions = {
|
|
519
|
+
"jsx-sort-props": jsx_sort_props_default,
|
|
520
|
+
"define-style": define_style_default
|
|
594
521
|
};
|
|
595
522
|
var rules_default = ruleOptions;
|
|
596
523
|
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
...options
|
|
524
|
+
//#endregion
|
|
525
|
+
//#region src/index.ts
|
|
526
|
+
const plugins = { "vue-jsx-vapor": { rules: rules_default } };
|
|
527
|
+
var src_default = ({ rules = {},...options } = {}) => ({
|
|
528
|
+
name: "vue-jsx-vapor",
|
|
529
|
+
plugins,
|
|
530
|
+
rules: {
|
|
531
|
+
"style/jsx-sort-props": "off",
|
|
532
|
+
"react/jsx-sort-props": "off",
|
|
533
|
+
"vue-jsx-vapor/jsx-sort-props": rules["vue-jsx-vapor/jsx-sort-props"] || ["warn", {
|
|
534
|
+
callbacksLast: true,
|
|
535
|
+
shorthandFirst: true,
|
|
536
|
+
reservedFirst: [
|
|
537
|
+
"v-if",
|
|
538
|
+
"v-else-if",
|
|
539
|
+
"v-else",
|
|
540
|
+
"v-for",
|
|
541
|
+
"key",
|
|
542
|
+
"ref",
|
|
543
|
+
"v-model"
|
|
544
|
+
],
|
|
545
|
+
reservedLast: [
|
|
546
|
+
"v-text",
|
|
547
|
+
"v-html",
|
|
548
|
+
"v-slots",
|
|
549
|
+
"v-slot"
|
|
550
|
+
]
|
|
551
|
+
}],
|
|
552
|
+
"vue-jsx-vapor/define-style": rules["vue-jsx-vapor/define-style"] || "warn"
|
|
553
|
+
},
|
|
554
|
+
...options
|
|
629
555
|
});
|
|
630
556
|
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
exports.
|
|
557
|
+
//#endregion
|
|
558
|
+
exports.default = src_default
|
|
559
|
+
exports.plugins = plugins
|
|
560
|
+
exports.rules = rules_default
|