@plumeria/eslint-plugin 18.2.12 → 18.2.14

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.
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.expandBorderShorthands = void 0;
4
4
  const borderShorthand_1 = require("../util/borderShorthand");
5
5
  const logicalPhysical_1 = require("../util/logicalPhysical");
6
+ const styleObject_1 = require("../util/styleObject");
6
7
  const BUNDLES = new Set(borderShorthand_1.BORDER_BUNDLES);
7
8
  exports.expandBorderShorthands = {
8
9
  meta: {
@@ -65,10 +66,11 @@ exports.expandBorderShorthands = {
65
66
  node.arguments.forEach((arg) => {
66
67
  if (arg.type === 'ObjectExpression') {
67
68
  arg.properties.forEach((prop) => {
68
- if (prop.type === 'Property' &&
69
- prop.value.type === 'ObjectExpression') {
70
- checkStyleObject(prop.value);
71
- }
69
+ if (prop.type !== 'Property')
70
+ return;
71
+ const style = (0, styleObject_1.styleObjectFromValue)(prop.value);
72
+ if (style)
73
+ checkStyleObject(style);
72
74
  });
73
75
  }
74
76
  });
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.formatProperties = void 0;
4
+ const styleObject_1 = require("../util/styleObject");
4
5
  exports.formatProperties = {
5
6
  meta: {
6
7
  type: 'layout',
@@ -164,10 +165,11 @@ exports.formatProperties = {
164
165
  node.arguments.forEach((arg) => {
165
166
  if (arg.type === 'ObjectExpression') {
166
167
  arg.properties.forEach((prop) => {
167
- if (prop.type === 'Property' &&
168
- prop.value.type === 'ObjectExpression') {
169
- checkStyleObject(prop.value);
170
- }
168
+ if (prop.type !== 'Property')
169
+ return;
170
+ const style = (0, styleObject_1.styleObjectFromValue)(prop.value);
171
+ if (style)
172
+ checkStyleObject(style);
171
173
  });
172
174
  }
173
175
  });
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.noCombinator = void 0;
4
+ const styleObject_1 = require("../util/styleObject");
4
5
  exports.noCombinator = {
5
6
  meta: {
6
7
  type: 'problem',
@@ -177,9 +178,9 @@ exports.noCombinator = {
177
178
  if (keyName) {
178
179
  checkAndReport(keyName, prop.key);
179
180
  }
180
- if (prop.value.type === 'ObjectExpression') {
181
- checkForCombinatorsRecursively(prop.value);
182
- }
181
+ const style = (0, styleObject_1.styleObjectFromValue)(prop.value);
182
+ if (style)
183
+ checkForCombinatorsRecursively(style);
183
184
  }
184
185
  }
185
186
  }
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.noInvalidSelector = void 0;
4
4
  const utils_1 = require("@typescript-eslint/utils");
5
+ const styleObject_1 = require("../util/styleObject");
5
6
  exports.noInvalidSelector = {
6
7
  meta: {
7
8
  type: 'problem',
@@ -216,10 +217,11 @@ exports.noInvalidSelector = {
216
217
  });
217
218
  }
218
219
  }
219
- if (prop.type === utils_1.TSESTree.AST_NODE_TYPES.Property &&
220
- prop.value.type === utils_1.TSESTree.AST_NODE_TYPES.ObjectExpression) {
221
- checkNesting(prop.value, 'CLASS');
222
- }
220
+ if (prop.type !== utils_1.TSESTree.AST_NODE_TYPES.Property)
221
+ return;
222
+ const style = (0, styleObject_1.styleObjectFromValue)(prop.value);
223
+ if (style)
224
+ checkNesting(style, 'CLASS');
223
225
  });
224
226
  }
225
227
  if (isCssKeyframes &&
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.noOrderDependentOverlap = void 0;
4
4
  const zss_engine_1 = require("zss-engine");
5
5
  const logicalPhysical_1 = require("../util/logicalPhysical");
6
+ const styleObject_1 = require("../util/styleObject");
6
7
  const DIRECT_SHORTHANDS = {};
7
8
  for (const [shorthand, longhands] of Object.entries(zss_engine_1.DIRECT_LONGHANDS)) {
8
9
  for (const longhand of longhands) {
@@ -112,10 +113,11 @@ exports.noOrderDependentOverlap = {
112
113
  node.arguments.forEach((arg) => {
113
114
  if (arg.type === 'ObjectExpression') {
114
115
  arg.properties.forEach((prop) => {
115
- if (prop.type === 'Property' &&
116
- prop.value.type === 'ObjectExpression') {
117
- checkStyleObject(prop.value);
118
- }
116
+ if (prop.type !== 'Property')
117
+ return;
118
+ const style = (0, styleObject_1.styleObjectFromValue)(prop.value);
119
+ if (style)
120
+ checkStyleObject(style);
119
121
  });
120
122
  }
121
123
  });
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.noUnknownCssProperties = void 0;
4
4
  const known_css_properties_1 = require("known-css-properties");
5
+ const styleObject_1 = require("../util/styleObject");
5
6
  const knownProperties = new Set(known_css_properties_1.all);
6
7
  const kebabCache = new Map();
7
8
  function toKebabCase(str) {
@@ -70,10 +71,11 @@ exports.noUnknownCssProperties = {
70
71
  node.arguments.forEach((arg) => {
71
72
  if (arg.type === 'ObjectExpression') {
72
73
  arg.properties.forEach((prop) => {
73
- if (prop.type === 'Property' &&
74
- prop.value.type === 'ObjectExpression') {
75
- checkStyleObject(prop.value);
76
- }
74
+ if (prop.type !== 'Property')
75
+ return;
76
+ const style = (0, styleObject_1.styleObjectFromValue)(prop.value);
77
+ if (style)
78
+ checkStyleObject(style);
77
79
  });
78
80
  }
79
81
  });
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.noUnusedKeys = void 0;
4
+ const styleObject_1 = require("../util/styleObject");
4
5
  function getRootObject(node) {
5
6
  if (node.type === 'Identifier') {
6
7
  return node;
@@ -46,7 +47,7 @@ exports.noUnusedKeys = {
46
47
  arg.properties.forEach((prop) => {
47
48
  if (prop.type === 'Property' &&
48
49
  prop.key.type === 'Identifier' &&
49
- prop.value.type === 'ObjectExpression') {
50
+ (0, styleObject_1.styleObjectFromValue)(prop.value)) {
50
51
  keyMap.set(prop.key.name, prop.key);
51
52
  }
52
53
  });
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.sortProperties = void 0;
4
+ const styleObject_1 = require("../util/styleObject");
4
5
  const propertyGroups_1 = require("../util/propertyGroups");
5
6
  function getPropertyName(property) {
6
7
  if (property.key.type === 'Identifier') {
@@ -212,10 +213,11 @@ exports.sortProperties = {
212
213
  node.arguments.forEach((arg) => {
213
214
  if (arg.type === 'ObjectExpression') {
214
215
  arg.properties.forEach((prop) => {
215
- if (prop.type === 'Property' &&
216
- prop.value.type === 'ObjectExpression') {
217
- checkStyleObject(prop.value);
218
- }
216
+ if (prop.type !== 'Property')
217
+ return;
218
+ const style = (0, styleObject_1.styleObjectFromValue)(prop.value);
219
+ if (style)
220
+ checkStyleObject(style);
219
221
  });
220
222
  }
221
223
  });
@@ -4,6 +4,7 @@ exports.validatePseudos = void 0;
4
4
  exports.splitChainedPseudos = splitChainedPseudos;
5
5
  exports.isValidPseudo = isValidPseudo;
6
6
  const utils_1 = require("@typescript-eslint/utils");
7
+ const styleObject_1 = require("../util/styleObject");
7
8
  const VALID_STATIC_PSEUDOS = new Set([
8
9
  ':hover',
9
10
  ':active',
@@ -235,10 +236,11 @@ exports.validatePseudos = {
235
236
  node.arguments[0]?.type === utils_1.TSESTree.AST_NODE_TYPES.ObjectExpression) {
236
237
  const styleObj = node.arguments[0];
237
238
  styleObj.properties.forEach((prop) => {
238
- if (prop.type === utils_1.TSESTree.AST_NODE_TYPES.Property &&
239
- prop.value.type === utils_1.TSESTree.AST_NODE_TYPES.ObjectExpression) {
240
- checkProperties(prop.value);
241
- }
239
+ if (prop.type !== utils_1.TSESTree.AST_NODE_TYPES.Property)
240
+ return;
241
+ const style = (0, styleObject_1.styleObjectFromValue)(prop.value);
242
+ if (style)
243
+ checkProperties(style);
242
244
  });
243
245
  }
244
246
  },
@@ -5,6 +5,7 @@ const validData_1 = require("../util/validData");
5
5
  const unitData_1 = require("../util/unitData");
6
6
  const colorData_1 = require("../util/colorData");
7
7
  const place_1 = require("../util/place");
8
+ const styleObject_1 = require("../util/styleObject");
8
9
  const globalValues = ['inherit', 'initial', 'revert', 'revert-layer', 'unset'];
9
10
  const lengthValueProperties = [
10
11
  'width',
@@ -1674,10 +1675,11 @@ exports.validateValues = {
1674
1675
  node.arguments.forEach((arg) => {
1675
1676
  if (arg.type === 'ObjectExpression') {
1676
1677
  arg.properties.forEach((prop) => {
1677
- if (prop.type === 'Property' &&
1678
- prop.value.type === 'ObjectExpression') {
1679
- checkStyleObject(prop.value);
1680
- }
1678
+ if (prop.type !== 'Property')
1679
+ return;
1680
+ const style = (0, styleObject_1.styleObjectFromValue)(prop.value);
1681
+ if (style)
1682
+ checkStyleObject(style);
1681
1683
  });
1682
1684
  }
1683
1685
  });
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createSpellingRule = void 0;
4
4
  const logicalPhysical_1 = require("./logicalPhysical");
5
+ const styleObject_1 = require("./styleObject");
5
6
  const DESCRIPTIONS = {
6
7
  physical: 'Disallow the physical name of a property that also has a logical name',
7
8
  logical: 'Disallow the logical name of a property that also has a physical name',
@@ -77,10 +78,11 @@ const createSpellingRule = (reject) => ({
77
78
  node.arguments.forEach((arg) => {
78
79
  if (arg.type === 'ObjectExpression') {
79
80
  arg.properties.forEach((prop) => {
80
- if (prop.type === 'Property' &&
81
- prop.value.type === 'ObjectExpression') {
82
- checkStyleObject(prop.value);
83
- }
81
+ if (prop.type !== 'Property')
82
+ return;
83
+ const style = (0, styleObject_1.styleObjectFromValue)(prop.value);
84
+ if (style)
85
+ checkStyleObject(style);
84
86
  });
85
87
  }
86
88
  });
@@ -0,0 +1,4 @@
1
+ import type { ObjectExpression } from 'estree';
2
+ export declare function styleObjectFromValue(value: {
3
+ type: string;
4
+ }): ObjectExpression | undefined;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.styleObjectFromValue = styleObjectFromValue;
4
+ function styleObjectFromValue(value) {
5
+ if (value.type === 'ObjectExpression')
6
+ return value;
7
+ if (value.type !== 'ArrowFunctionExpression' &&
8
+ value.type !== 'FunctionExpression')
9
+ return undefined;
10
+ const body = value.body;
11
+ if (body?.type === 'ObjectExpression')
12
+ return body;
13
+ if (body?.type !== 'BlockStatement')
14
+ return undefined;
15
+ const first = body.body?.[0];
16
+ return first?.type === 'ReturnStatement' &&
17
+ first.argument?.type === 'ObjectExpression'
18
+ ? first.argument
19
+ : undefined;
20
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plumeria/eslint-plugin",
3
- "version": "18.2.12",
3
+ "version": "18.2.14",
4
4
  "description": "Plumeria ESLint plugin",
5
5
  "author": "Refirst 11",
6
6
  "license": "MIT",