@plumeria/eslint-plugin 0.1.0 → 0.2.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/lib/rules/no-inner-call.js +4 -3
- package/lib/rules/no-unused-keys.js +19 -11
- package/lib/rules/sort-properties.js +9 -4
- package/lib/rules/validate-values.js +368 -143
- package/lib/util/colorData.js +32 -32
- package/lib/util/place.js +17 -2
- package/lib/util/propertyGroups.js +2 -2
- package/lib/util/validData.js +10 -10
- package/package.json +6 -3
|
@@ -10,7 +10,8 @@ module.exports = {
|
|
|
10
10
|
meta: {
|
|
11
11
|
type: 'problem',
|
|
12
12
|
docs: {
|
|
13
|
-
description:
|
|
13
|
+
description:
|
|
14
|
+
'An error occurs if a specific call is made within a function',
|
|
14
15
|
recommended: true,
|
|
15
16
|
},
|
|
16
17
|
messages: {
|
|
@@ -41,7 +42,6 @@ module.exports = {
|
|
|
41
42
|
},
|
|
42
43
|
CallExpression(node) {
|
|
43
44
|
if (functionDepth > 0) {
|
|
44
|
-
// メンバー式(MemberExpression)の場合の処理
|
|
45
45
|
if (node.callee.type === 'MemberExpression') {
|
|
46
46
|
const objectName = node.callee.object.name;
|
|
47
47
|
const propertyName = node.callee.property.name;
|
|
@@ -52,7 +52,8 @@ module.exports = {
|
|
|
52
52
|
propertyName === 'create' ||
|
|
53
53
|
propertyName === 'global' ||
|
|
54
54
|
propertyName === 'keyframes' ||
|
|
55
|
-
propertyName === '
|
|
55
|
+
propertyName === 'defineVars' ||
|
|
56
|
+
propertyName === 'defineTheme'
|
|
56
57
|
) {
|
|
57
58
|
context.report({
|
|
58
59
|
node,
|
|
@@ -18,11 +18,13 @@ module.exports = {
|
|
|
18
18
|
meta: {
|
|
19
19
|
type: 'problem',
|
|
20
20
|
docs: {
|
|
21
|
-
description:
|
|
21
|
+
description:
|
|
22
|
+
'Detect unused object keys if they are not referenced anywhere',
|
|
22
23
|
recommended: true,
|
|
23
24
|
},
|
|
24
25
|
messages: {
|
|
25
|
-
unusedKey:
|
|
26
|
+
unusedKey:
|
|
27
|
+
"The key '{{ key }}' is defined but never referenced anywhere.",
|
|
26
28
|
},
|
|
27
29
|
},
|
|
28
30
|
|
|
@@ -37,22 +39,27 @@ module.exports = {
|
|
|
37
39
|
const referencedKeys = new Set();
|
|
38
40
|
|
|
39
41
|
return {
|
|
40
|
-
// Filter out `css.global` and find objects in functions
|
|
41
42
|
CallExpression(node) {
|
|
42
43
|
if (
|
|
43
44
|
node.callee.type === 'MemberExpression' &&
|
|
44
45
|
node.callee.object.name === 'css' &&
|
|
45
|
-
node.callee.property.name
|
|
46
|
-
node.callee.property.name !== 'defineThemeVars' &&
|
|
47
|
-
node.callee.property.name !== 'keyframes'
|
|
46
|
+
node.callee.property.name === 'create'
|
|
48
47
|
) {
|
|
49
48
|
const arg = node.arguments[0];
|
|
50
|
-
if (
|
|
49
|
+
if (
|
|
50
|
+
arg &&
|
|
51
|
+
arg.type === 'ObjectExpression' &&
|
|
52
|
+
node.parent.type === 'VariableDeclarator'
|
|
53
|
+
) {
|
|
51
54
|
const variableName = node.parent.id.name;
|
|
52
55
|
const keyMap = new Map();
|
|
53
56
|
|
|
54
57
|
arg.properties.forEach((prop) => {
|
|
55
|
-
if (
|
|
58
|
+
if (
|
|
59
|
+
prop.key &&
|
|
60
|
+
prop.key.type === 'Identifier' &&
|
|
61
|
+
prop.value.type === 'ObjectExpression'
|
|
62
|
+
) {
|
|
56
63
|
keyMap.set(prop.key.name, prop.key);
|
|
57
64
|
}
|
|
58
65
|
});
|
|
@@ -61,13 +68,14 @@ module.exports = {
|
|
|
61
68
|
}
|
|
62
69
|
}
|
|
63
70
|
},
|
|
64
|
-
// `styles.header_main` の参照を記録
|
|
65
71
|
MemberExpression(node) {
|
|
66
|
-
if (
|
|
72
|
+
if (
|
|
73
|
+
node.object.type === 'Identifier' &&
|
|
74
|
+
node.property.type === 'Identifier'
|
|
75
|
+
) {
|
|
67
76
|
const fullKey = `${node.object.name}.${node.property.name}`;
|
|
68
77
|
referencedKeys.add(fullKey);
|
|
69
78
|
|
|
70
|
-
// TypeScript の型情報を取得し、ジャンプ可能かチェック
|
|
71
79
|
if (parserServices && checker) {
|
|
72
80
|
const tsNode = parserServices.esTreeNodeToTSNodeMap.get(node);
|
|
73
81
|
const symbol = checker.getSymbolAtLocation(tsNode);
|
|
@@ -27,7 +27,10 @@ function getPropertyIndex(property, isTopLevel = false) {
|
|
|
27
27
|
|
|
28
28
|
if (
|
|
29
29
|
isTopLevel &&
|
|
30
|
-
(property.key.type !== 'Identifier' ||
|
|
30
|
+
(property.key.type !== 'Identifier' ||
|
|
31
|
+
name.startsWith('&') ||
|
|
32
|
+
name.startsWith(':') ||
|
|
33
|
+
name.startsWith('@'))
|
|
31
34
|
) {
|
|
32
35
|
return null;
|
|
33
36
|
}
|
|
@@ -60,13 +63,15 @@ module.exports = {
|
|
|
60
63
|
meta: {
|
|
61
64
|
type: 'suggestion',
|
|
62
65
|
docs: {
|
|
63
|
-
description:
|
|
66
|
+
description:
|
|
67
|
+
'Sort CSS properties keeping original order for specific keys',
|
|
64
68
|
recommended: true,
|
|
65
69
|
},
|
|
66
70
|
fixable: 'code',
|
|
67
71
|
schema: [],
|
|
68
72
|
messages: {
|
|
69
|
-
sortProperties:
|
|
73
|
+
sortProperties:
|
|
74
|
+
'Property "{{property}}" should be at position {{position}}',
|
|
70
75
|
},
|
|
71
76
|
},
|
|
72
77
|
|
|
@@ -115,7 +120,7 @@ module.exports = {
|
|
|
115
120
|
|
|
116
121
|
return fixer.replaceTextRange(
|
|
117
122
|
[node.range[0] + 1, node.range[1] - 1],
|
|
118
|
-
`${lineEnding}${newText}${lineEnding}
|
|
123
|
+
`${lineEnding}${newText}${lineEnding}`,
|
|
119
124
|
);
|
|
120
125
|
},
|
|
121
126
|
});
|