@plumeria/eslint-plugin 20.0.0 → 21.1.0
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 +2 -2
- package/dist/rules/expand-border-shorthands.js +2 -2
- package/dist/rules/format-properties.js +2 -2
- package/dist/rules/no-destructure.js +1 -1
- package/dist/rules/no-inner-call.js +1 -1
- package/dist/rules/no-invalid-selector.js +2 -2
- package/dist/rules/no-mutable-binding.js +1 -1
- package/dist/rules/no-order-dependent-overlap.js +2 -2
- package/dist/rules/no-unknown-css-properties.js +3 -3
- package/dist/rules/sort-properties.js +15 -8
- package/dist/rules/validate-values.js +2 -2
- package/dist/util/spellingRule.js +2 -2
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -125,7 +125,7 @@ Disallow calling APIs inside functions.
|
|
|
125
125
|
|
|
126
126
|
### no-invalid-selector
|
|
127
127
|
|
|
128
|
-
Disallow invalid selector inside `css.create()` and `css.keyframes()` and `css.
|
|
128
|
+
Disallow invalid selector inside `css.create()` and `css.keyframes()` and `css.viewTransitionClass()`.
|
|
129
129
|
`create()` example: (Pseudo -> Query, Query -> Query)
|
|
130
130
|
Also reports a functional pseudo-class nested inside one of the same name, such as `:where(:where(.a), .b)`, and flattens it with a fix when the nested call is a whole argument. `:not()` may nest inside `:not()`. Reports a key nested deeper than 16 levels or holding a stray quote.
|
|
131
131
|
|
|
@@ -162,7 +162,7 @@ Accepts `{ styleProp }`; see [Configuring the styling prop](#configuring-the-sty
|
|
|
162
162
|
|
|
163
163
|
### no-unknown-css-properties
|
|
164
164
|
|
|
165
|
-
Disallow unknown CSS properties in camelCase within `css.create`, `css.keyframes`, `css.
|
|
165
|
+
Disallow unknown CSS properties in camelCase within `css.create`, `css.keyframes`, `css.viewTransitionClass`, and `css.positionTry`. Inside `css.positionTry`, it also reports properties that `@position-try` does not accept.
|
|
166
166
|
|
|
167
167
|
In `css.create`, a key that holds an object is reported with a hint that nested selectors start with `:`, `[` or `@`.
|
|
168
168
|
|
|
@@ -50,7 +50,7 @@ exports.expandBorderShorthands = {
|
|
|
50
50
|
: null;
|
|
51
51
|
if (propertyName === 'create' ||
|
|
52
52
|
propertyName === 'keyframes' ||
|
|
53
|
-
propertyName === '
|
|
53
|
+
propertyName === 'viewTransitionClass' ||
|
|
54
54
|
propertyName === 'positionTry') {
|
|
55
55
|
isCssProperties = true;
|
|
56
56
|
isPositionTry = propertyName === 'positionTry';
|
|
@@ -61,7 +61,7 @@ exports.expandBorderShorthands = {
|
|
|
61
61
|
const aliasName = plumeriaAliases[node.callee.name];
|
|
62
62
|
if (aliasName === 'create' ||
|
|
63
63
|
aliasName === 'keyframes' ||
|
|
64
|
-
aliasName === '
|
|
64
|
+
aliasName === 'viewTransitionClass' ||
|
|
65
65
|
aliasName === 'positionTry') {
|
|
66
66
|
isCssProperties = true;
|
|
67
67
|
isPositionTry = aliasName === 'positionTry';
|
|
@@ -149,7 +149,7 @@ exports.formatProperties = {
|
|
|
149
149
|
: null;
|
|
150
150
|
if (propertyName === 'create' ||
|
|
151
151
|
propertyName === 'keyframes' ||
|
|
152
|
-
propertyName === '
|
|
152
|
+
propertyName === 'viewTransitionClass' ||
|
|
153
153
|
propertyName === 'positionTry') {
|
|
154
154
|
isCssProperties = true;
|
|
155
155
|
isPositionTry = propertyName === 'positionTry';
|
|
@@ -160,7 +160,7 @@ exports.formatProperties = {
|
|
|
160
160
|
const alias = plumeriaAliases[node.callee.name];
|
|
161
161
|
if (alias === 'create' ||
|
|
162
162
|
alias === 'keyframes' ||
|
|
163
|
-
alias === '
|
|
163
|
+
alias === 'viewTransitionClass' ||
|
|
164
164
|
alias === 'positionTry') {
|
|
165
165
|
isCssProperties = true;
|
|
166
166
|
isPositionTry = alias === 'positionTry';
|
|
@@ -48,7 +48,7 @@ exports.noDestructure = {
|
|
|
48
48
|
keyName === 'createStatic' ||
|
|
49
49
|
keyName === 'createTheme' ||
|
|
50
50
|
keyName === 'keyframes' ||
|
|
51
|
-
keyName === '
|
|
51
|
+
keyName === 'viewTransitionClass' ||
|
|
52
52
|
keyName === 'positionTry' ||
|
|
53
53
|
keyName === 'varType' ||
|
|
54
54
|
keyName === 'use') {
|
|
@@ -80,7 +80,7 @@ exports.noInnerCall = {
|
|
|
80
80
|
propertyName === 'createStatic' ||
|
|
81
81
|
propertyName === 'createTheme' ||
|
|
82
82
|
propertyName === 'keyframes' ||
|
|
83
|
-
propertyName === '
|
|
83
|
+
propertyName === 'viewTransitionClass' ||
|
|
84
84
|
propertyName === 'positionTry' ||
|
|
85
85
|
propertyName === 'varType') {
|
|
86
86
|
context.report({
|
|
@@ -425,7 +425,7 @@ exports.noInvalidSelector = {
|
|
|
425
425
|
isCssCreate = true;
|
|
426
426
|
if (propertyName === 'keyframes')
|
|
427
427
|
isCssKeyframes = true;
|
|
428
|
-
if (propertyName === '
|
|
428
|
+
if (propertyName === 'viewTransitionClass')
|
|
429
429
|
isCssViewTransition = true;
|
|
430
430
|
}
|
|
431
431
|
}
|
|
@@ -435,7 +435,7 @@ exports.noInvalidSelector = {
|
|
|
435
435
|
isCssCreate = true;
|
|
436
436
|
if (alias === 'keyframes')
|
|
437
437
|
isCssKeyframes = true;
|
|
438
|
-
if (alias === '
|
|
438
|
+
if (alias === 'viewTransitionClass')
|
|
439
439
|
isCssViewTransition = true;
|
|
440
440
|
}
|
|
441
441
|
if (isCssCreate && node.arguments[0]?.type === 'ObjectExpression') {
|
|
@@ -124,7 +124,7 @@ exports.noOrderDependentOverlap = {
|
|
|
124
124
|
: null;
|
|
125
125
|
if (propertyName === 'create' ||
|
|
126
126
|
propertyName === 'keyframes' ||
|
|
127
|
-
propertyName === '
|
|
127
|
+
propertyName === 'viewTransitionClass' ||
|
|
128
128
|
propertyName === 'positionTry') {
|
|
129
129
|
isCssProperties = true;
|
|
130
130
|
isPositionTry = propertyName === 'positionTry';
|
|
@@ -135,7 +135,7 @@ exports.noOrderDependentOverlap = {
|
|
|
135
135
|
const aliasName = plumeriaAliases[node.callee.name];
|
|
136
136
|
if (aliasName === 'create' ||
|
|
137
137
|
aliasName === 'keyframes' ||
|
|
138
|
-
aliasName === '
|
|
138
|
+
aliasName === 'viewTransitionClass' ||
|
|
139
139
|
aliasName === 'positionTry') {
|
|
140
140
|
isCssProperties = true;
|
|
141
141
|
isPositionTry = aliasName === 'positionTry';
|
|
@@ -50,7 +50,7 @@ exports.noUnknownCssProperties = {
|
|
|
50
50
|
meta: {
|
|
51
51
|
type: 'problem',
|
|
52
52
|
docs: {
|
|
53
|
-
description: 'Disallow unknown CSS properties in camelCase within css.create, css.keyframes, css.
|
|
53
|
+
description: 'Disallow unknown CSS properties in camelCase within css.create, css.keyframes, css.viewTransitionClass, and css.positionTry',
|
|
54
54
|
},
|
|
55
55
|
messages: {
|
|
56
56
|
unknownProperty: "Unknown CSS property '{{ name }}'.",
|
|
@@ -91,7 +91,7 @@ exports.noUnknownCssProperties = {
|
|
|
91
91
|
: null;
|
|
92
92
|
if (propertyName === 'create' ||
|
|
93
93
|
propertyName === 'keyframes' ||
|
|
94
|
-
propertyName === '
|
|
94
|
+
propertyName === 'viewTransitionClass' ||
|
|
95
95
|
propertyName === 'positionTry') {
|
|
96
96
|
isCssProperties = true;
|
|
97
97
|
isPositionTry = propertyName === 'positionTry';
|
|
@@ -103,7 +103,7 @@ exports.noUnknownCssProperties = {
|
|
|
103
103
|
const alias = plumeriaAliases[node.callee.name];
|
|
104
104
|
if (alias === 'create' ||
|
|
105
105
|
alias === 'keyframes' ||
|
|
106
|
-
alias === '
|
|
106
|
+
alias === 'viewTransitionClass' ||
|
|
107
107
|
alias === 'positionTry') {
|
|
108
108
|
isCssProperties = true;
|
|
109
109
|
isPositionTry = alias === 'positionTry';
|
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.sortProperties = void 0;
|
|
4
4
|
const styleObject_1 = require("../util/styleObject");
|
|
5
|
+
const staticValue_1 = require("../util/staticValue");
|
|
5
6
|
const propertyGroups_1 = require("../util/propertyGroups");
|
|
6
7
|
function getPropertyName(property) {
|
|
7
|
-
if (property.key.type === 'Identifier') {
|
|
8
|
+
if (property.key.type === 'Identifier' && !property.computed) {
|
|
8
9
|
return property.key.name;
|
|
9
10
|
}
|
|
10
11
|
if (property.key.type === 'Literal') {
|
|
@@ -27,8 +28,7 @@ const pseudoGroupOffset1 = (propertyGroups_1.propertyGroups.length + 1) * 1000;
|
|
|
27
28
|
const pseudoGroupOffset2 = (propertyGroups_1.propertyGroups.length + 2) * 1000;
|
|
28
29
|
const pseudoGroupOffset3 = (propertyGroups_1.propertyGroups.length + 3) * 1000;
|
|
29
30
|
const defaultOffset = globalLastGroupIndex * 1000 + globalMaxPropIndex + 1;
|
|
30
|
-
function getPropertyIndex(
|
|
31
|
-
const name = getPropertyName(property);
|
|
31
|
+
function getPropertyIndex(name) {
|
|
32
32
|
const cachedIndex = propertyIndexMap.get(name);
|
|
33
33
|
if (cachedIndex !== undefined) {
|
|
34
34
|
return cachedIndex;
|
|
@@ -85,6 +85,13 @@ exports.sortProperties = {
|
|
|
85
85
|
},
|
|
86
86
|
create(context) {
|
|
87
87
|
const plumeriaAliases = {};
|
|
88
|
+
const staticValue = (0, staticValue_1.staticValueResolver)(context);
|
|
89
|
+
function keyNameOf(property) {
|
|
90
|
+
if (!property.computed || property.key.type === 'Literal')
|
|
91
|
+
return getPropertyName(property);
|
|
92
|
+
const value = staticValue(property.key);
|
|
93
|
+
return typeof value === 'string' ? value : '';
|
|
94
|
+
}
|
|
88
95
|
function checkStyleObject(node) {
|
|
89
96
|
const sourceCode = context.sourceCode;
|
|
90
97
|
const properties = node.properties.filter((prop) => ('key' in prop && !!prop.key) || prop.type === 'SpreadElement');
|
|
@@ -109,8 +116,8 @@ exports.sortProperties = {
|
|
|
109
116
|
return chunk;
|
|
110
117
|
}
|
|
111
118
|
return [...chunk].sort((a, b) => {
|
|
112
|
-
const indexA = getPropertyIndex(a);
|
|
113
|
-
const indexB = getPropertyIndex(b);
|
|
119
|
+
const indexA = getPropertyIndex(keyNameOf(a));
|
|
120
|
+
const indexB = getPropertyIndex(keyNameOf(b));
|
|
114
121
|
return indexA - indexB;
|
|
115
122
|
});
|
|
116
123
|
})
|
|
@@ -145,7 +152,7 @@ exports.sortProperties = {
|
|
|
145
152
|
messageId: 'sortProperties',
|
|
146
153
|
data: {
|
|
147
154
|
position: propertyToIndexInSorted.get(prop) + 1,
|
|
148
|
-
property:
|
|
155
|
+
property: keyNameOf(prop),
|
|
149
156
|
},
|
|
150
157
|
fix(fixer) {
|
|
151
158
|
const newText = sorted
|
|
@@ -197,7 +204,7 @@ exports.sortProperties = {
|
|
|
197
204
|
: null;
|
|
198
205
|
if (propertyName === 'create' ||
|
|
199
206
|
propertyName === 'keyframes' ||
|
|
200
|
-
propertyName === '
|
|
207
|
+
propertyName === 'viewTransitionClass' ||
|
|
201
208
|
propertyName === 'positionTry') {
|
|
202
209
|
isCssProperties = true;
|
|
203
210
|
isPositionTry = propertyName === 'positionTry';
|
|
@@ -208,7 +215,7 @@ exports.sortProperties = {
|
|
|
208
215
|
const alias = plumeriaAliases[node.callee.name];
|
|
209
216
|
if (alias === 'create' ||
|
|
210
217
|
alias === 'keyframes' ||
|
|
211
|
-
alias === '
|
|
218
|
+
alias === 'viewTransitionClass' ||
|
|
212
219
|
alias === 'positionTry') {
|
|
213
220
|
isCssProperties = true;
|
|
214
221
|
isPositionTry = alias === 'positionTry';
|
|
@@ -2132,7 +2132,7 @@ exports.validateValues = {
|
|
|
2132
2132
|
: null;
|
|
2133
2133
|
if (propertyName === 'create' ||
|
|
2134
2134
|
propertyName === 'keyframes' ||
|
|
2135
|
-
propertyName === '
|
|
2135
|
+
propertyName === 'viewTransitionClass' ||
|
|
2136
2136
|
propertyName === 'positionTry') {
|
|
2137
2137
|
isCssProperties = true;
|
|
2138
2138
|
isPositionTry = propertyName === 'positionTry';
|
|
@@ -2143,7 +2143,7 @@ exports.validateValues = {
|
|
|
2143
2143
|
const alias = plumeriaAliases[node.callee.name];
|
|
2144
2144
|
if (alias === 'create' ||
|
|
2145
2145
|
alias === 'keyframes' ||
|
|
2146
|
-
alias === '
|
|
2146
|
+
alias === 'viewTransitionClass' ||
|
|
2147
2147
|
alias === 'positionTry') {
|
|
2148
2148
|
isCssProperties = true;
|
|
2149
2149
|
isPositionTry = alias === 'positionTry';
|
|
@@ -62,7 +62,7 @@ const createSpellingRule = (reject) => ({
|
|
|
62
62
|
: null;
|
|
63
63
|
if (propertyName === 'create' ||
|
|
64
64
|
propertyName === 'keyframes' ||
|
|
65
|
-
propertyName === '
|
|
65
|
+
propertyName === 'viewTransitionClass' ||
|
|
66
66
|
propertyName === 'positionTry') {
|
|
67
67
|
isCssProperties = true;
|
|
68
68
|
isPositionTry = propertyName === 'positionTry';
|
|
@@ -73,7 +73,7 @@ const createSpellingRule = (reject) => ({
|
|
|
73
73
|
const aliasName = plumeriaAliases[node.callee.name];
|
|
74
74
|
if (aliasName === 'create' ||
|
|
75
75
|
aliasName === 'keyframes' ||
|
|
76
|
-
aliasName === '
|
|
76
|
+
aliasName === 'viewTransitionClass' ||
|
|
77
77
|
aliasName === 'positionTry') {
|
|
78
78
|
isCssProperties = true;
|
|
79
79
|
isPositionTry = aliasName === 'positionTry';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plumeria/eslint-plugin",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "21.1.0",
|
|
4
4
|
"description": "Plumeria ESLint plugin",
|
|
5
5
|
"author": "Refirst 11",
|
|
6
6
|
"license": "MIT",
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"dependencies": {
|
|
60
60
|
"oxlint": "1.87.0",
|
|
61
61
|
"zss-engine": "3.0.1",
|
|
62
|
-
"@plumeria/compiler": "
|
|
62
|
+
"@plumeria/compiler": "21.1.0"
|
|
63
63
|
},
|
|
64
64
|
"scripts": {
|
|
65
65
|
"build": "rimraf dist && pnpm cjs",
|