@plumeria/eslint-plugin 21.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.
@@ -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(property) {
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: getPropertyName(prop),
155
+ property: keyNameOf(prop),
149
156
  },
150
157
  fix(fixer) {
151
158
  const newText = sorted
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plumeria/eslint-plugin",
3
- "version": "21.0.0",
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": "21.0.0"
62
+ "@plumeria/compiler": "21.1.0"
63
63
  },
64
64
  "scripts": {
65
65
  "build": "rimraf dist && pnpm cjs",