@atlaskit/eslint-plugin-design-system 13.23.1 → 13.23.3

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/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # @atlaskit/eslint-plugin-design-system
2
2
 
3
+ ## 13.23.3
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+
9
+ ## 13.23.2
10
+
11
+ ### Patch Changes
12
+
13
+ - [`789b0a7d82394`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/789b0a7d82394) -
14
+ Update `ensure-proper-xcss-usage` to account for style declarations after usage.
15
+
3
16
  ## 13.23.1
4
17
 
5
18
  ### Patch Changes
@@ -31,6 +31,9 @@ var rule = (0, _createRule.createLintRule)({
31
31
  cssMapVariables: new Map(),
32
32
  xcssVariables: new Set()
33
33
  };
34
+
35
+ // Store potential violations to check after all declarations are collected
36
+ var potentialViolations = [];
34
37
  return (0, _errorBoundary.errorBoundary)({
35
38
  // Track all imports in a single handler
36
39
  ImportDeclaration: function ImportDeclaration(node) {
@@ -44,7 +47,9 @@ var rule = (0, _createRule.createLintRule)({
44
47
  switch (source) {
45
48
  case '@atlaskit/primitives/compiled':
46
49
  if (specifier.imported.type === 'Identifier') {
47
- tracker.compiledComponents.add(specifier.imported.name);
50
+ // Track the local name (alias), not the imported name
51
+ // e.g., import { Box as CompiledBox } -> track "CompiledBox"
52
+ tracker.compiledComponents.add(specifier.local.name);
48
53
  }
49
54
  break;
50
55
  case '@atlaskit/primitives':
@@ -82,11 +87,54 @@ var rule = (0, _createRule.createLintRule)({
82
87
  });
83
88
  }
84
89
  tracker.cssMapVariables.set(variableName, keys);
90
+
91
+ // Check if this variable was used before it was declared
92
+ var violationsToRemove = [];
93
+ potentialViolations.forEach(function (violation, index) {
94
+ if (violation.identifierName === variableName) {
95
+ if (violation.type === 'identifier') {
96
+ // Identifier usage of cssMap variable is invalid (e.g., styles instead of styles.root)
97
+ context.report({
98
+ node: violation.node,
99
+ messageId: 'missingCssMapKey',
100
+ data: {
101
+ identifier: variableName
102
+ }
103
+ });
104
+ violationsToRemove.push(index);
105
+ }
106
+ // Member expressions with cssMap are valid (e.g., styles.root) - just remove from list
107
+ // No need to report or keep in list
108
+ if (violation.type === 'memberExpression') {
109
+ violationsToRemove.push(index);
110
+ }
111
+ }
112
+ });
113
+ // Remove violations in reverse order to maintain indices
114
+ violationsToRemove.reverse().forEach(function (index) {
115
+ potentialViolations.splice(index, 1);
116
+ });
85
117
  }
86
118
 
87
119
  // Track xcss variables
88
120
  if (tracker.xcssFunction.has(calleeName)) {
89
121
  tracker.xcssVariables.add(variableName);
122
+
123
+ // Check if this variable was used before it was declared
124
+ var _violationsToRemove = [];
125
+ potentialViolations.forEach(function (violation, index) {
126
+ if (violation.identifierName === variableName) {
127
+ context.report({
128
+ node: violation.node,
129
+ messageId: 'noXcssWithCompiled'
130
+ });
131
+ _violationsToRemove.push(index);
132
+ }
133
+ });
134
+ // Remove violations in reverse order to maintain indices
135
+ _violationsToRemove.reverse().forEach(function (index) {
136
+ potentialViolations.splice(index, 1);
137
+ });
90
138
  }
91
139
  },
92
140
  // Check JSX elements for xcss prop usage
@@ -138,6 +186,13 @@ var rule = (0, _createRule.createLintRule)({
138
186
  identifier: identifierName
139
187
  }
140
188
  });
189
+ } else {
190
+ // Variable not yet declared - store for later check
191
+ potentialViolations.push({
192
+ node: expression,
193
+ identifierName: identifierName,
194
+ type: 'identifier'
195
+ });
141
196
  }
142
197
  return;
143
198
  }
@@ -150,8 +205,39 @@ var rule = (0, _createRule.createLintRule)({
150
205
  node: expression,
151
206
  messageId: 'noXcssWithCompiled'
152
207
  });
208
+ } else if (!tracker.cssMapVariables.has(objectName)) {
209
+ // Variable not yet declared - store for later check
210
+ // Note: If it's already a cssMap variable, member expressions are valid (e.g., styles.root)
211
+ potentialViolations.push({
212
+ node: expression,
213
+ identifierName: objectName,
214
+ type: 'memberExpression'
215
+ });
153
216
  }
217
+ // If it's a cssMap variable, member expressions are valid - no action needed
154
218
  }
219
+ },
220
+ // Final check after all declarations are processed
221
+ 'Program:exit': function ProgramExit() {
222
+ // Check remaining potential violations against all collected declarations
223
+ potentialViolations.forEach(function (violation) {
224
+ if (tracker.xcssVariables.has(violation.identifierName)) {
225
+ context.report({
226
+ node: violation.node,
227
+ messageId: 'noXcssWithCompiled'
228
+ });
229
+ } else if (tracker.cssMapVariables.has(violation.identifierName) && violation.type === 'identifier') {
230
+ // Only report cssMap violations for identifier usage (not member expressions)
231
+ // Member expressions like stylesMap.root are valid
232
+ context.report({
233
+ node: violation.node,
234
+ messageId: 'missingCssMapKey',
235
+ data: {
236
+ identifier: violation.identifierName
237
+ }
238
+ });
239
+ }
240
+ });
155
241
  }
156
242
  });
157
243
  }
@@ -25,6 +25,9 @@ const rule = createLintRule({
25
25
  cssMapVariables: new Map(),
26
26
  xcssVariables: new Set()
27
27
  };
28
+
29
+ // Store potential violations to check after all declarations are collected
30
+ const potentialViolations = [];
28
31
  return errorBoundary({
29
32
  // Track all imports in a single handler
30
33
  ImportDeclaration(node) {
@@ -38,7 +41,9 @@ const rule = createLintRule({
38
41
  switch (source) {
39
42
  case '@atlaskit/primitives/compiled':
40
43
  if (specifier.imported.type === 'Identifier') {
41
- tracker.compiledComponents.add(specifier.imported.name);
44
+ // Track the local name (alias), not the imported name
45
+ // e.g., import { Box as CompiledBox } -> track "CompiledBox"
46
+ tracker.compiledComponents.add(specifier.local.name);
42
47
  }
43
48
  break;
44
49
  case '@atlaskit/primitives':
@@ -76,11 +81,54 @@ const rule = createLintRule({
76
81
  });
77
82
  }
78
83
  tracker.cssMapVariables.set(variableName, keys);
84
+
85
+ // Check if this variable was used before it was declared
86
+ const violationsToRemove = [];
87
+ potentialViolations.forEach((violation, index) => {
88
+ if (violation.identifierName === variableName) {
89
+ if (violation.type === 'identifier') {
90
+ // Identifier usage of cssMap variable is invalid (e.g., styles instead of styles.root)
91
+ context.report({
92
+ node: violation.node,
93
+ messageId: 'missingCssMapKey',
94
+ data: {
95
+ identifier: variableName
96
+ }
97
+ });
98
+ violationsToRemove.push(index);
99
+ }
100
+ // Member expressions with cssMap are valid (e.g., styles.root) - just remove from list
101
+ // No need to report or keep in list
102
+ if (violation.type === 'memberExpression') {
103
+ violationsToRemove.push(index);
104
+ }
105
+ }
106
+ });
107
+ // Remove violations in reverse order to maintain indices
108
+ violationsToRemove.reverse().forEach(index => {
109
+ potentialViolations.splice(index, 1);
110
+ });
79
111
  }
80
112
 
81
113
  // Track xcss variables
82
114
  if (tracker.xcssFunction.has(calleeName)) {
83
115
  tracker.xcssVariables.add(variableName);
116
+
117
+ // Check if this variable was used before it was declared
118
+ const violationsToRemove = [];
119
+ potentialViolations.forEach((violation, index) => {
120
+ if (violation.identifierName === variableName) {
121
+ context.report({
122
+ node: violation.node,
123
+ messageId: 'noXcssWithCompiled'
124
+ });
125
+ violationsToRemove.push(index);
126
+ }
127
+ });
128
+ // Remove violations in reverse order to maintain indices
129
+ violationsToRemove.reverse().forEach(index => {
130
+ potentialViolations.splice(index, 1);
131
+ });
84
132
  }
85
133
  },
86
134
  // Check JSX elements for xcss prop usage
@@ -130,6 +178,13 @@ const rule = createLintRule({
130
178
  identifier: identifierName
131
179
  }
132
180
  });
181
+ } else {
182
+ // Variable not yet declared - store for later check
183
+ potentialViolations.push({
184
+ node: expression,
185
+ identifierName,
186
+ type: 'identifier'
187
+ });
133
188
  }
134
189
  return;
135
190
  }
@@ -142,8 +197,39 @@ const rule = createLintRule({
142
197
  node: expression,
143
198
  messageId: 'noXcssWithCompiled'
144
199
  });
200
+ } else if (!tracker.cssMapVariables.has(objectName)) {
201
+ // Variable not yet declared - store for later check
202
+ // Note: If it's already a cssMap variable, member expressions are valid (e.g., styles.root)
203
+ potentialViolations.push({
204
+ node: expression,
205
+ identifierName: objectName,
206
+ type: 'memberExpression'
207
+ });
145
208
  }
209
+ // If it's a cssMap variable, member expressions are valid - no action needed
146
210
  }
211
+ },
212
+ // Final check after all declarations are processed
213
+ 'Program:exit'() {
214
+ // Check remaining potential violations against all collected declarations
215
+ potentialViolations.forEach(violation => {
216
+ if (tracker.xcssVariables.has(violation.identifierName)) {
217
+ context.report({
218
+ node: violation.node,
219
+ messageId: 'noXcssWithCompiled'
220
+ });
221
+ } else if (tracker.cssMapVariables.has(violation.identifierName) && violation.type === 'identifier') {
222
+ // Only report cssMap violations for identifier usage (not member expressions)
223
+ // Member expressions like stylesMap.root are valid
224
+ context.report({
225
+ node: violation.node,
226
+ messageId: 'missingCssMapKey',
227
+ data: {
228
+ identifier: violation.identifierName
229
+ }
230
+ });
231
+ }
232
+ });
147
233
  }
148
234
  });
149
235
  }
@@ -25,6 +25,9 @@ var rule = createLintRule({
25
25
  cssMapVariables: new Map(),
26
26
  xcssVariables: new Set()
27
27
  };
28
+
29
+ // Store potential violations to check after all declarations are collected
30
+ var potentialViolations = [];
28
31
  return errorBoundary({
29
32
  // Track all imports in a single handler
30
33
  ImportDeclaration: function ImportDeclaration(node) {
@@ -38,7 +41,9 @@ var rule = createLintRule({
38
41
  switch (source) {
39
42
  case '@atlaskit/primitives/compiled':
40
43
  if (specifier.imported.type === 'Identifier') {
41
- tracker.compiledComponents.add(specifier.imported.name);
44
+ // Track the local name (alias), not the imported name
45
+ // e.g., import { Box as CompiledBox } -> track "CompiledBox"
46
+ tracker.compiledComponents.add(specifier.local.name);
42
47
  }
43
48
  break;
44
49
  case '@atlaskit/primitives':
@@ -76,11 +81,54 @@ var rule = createLintRule({
76
81
  });
77
82
  }
78
83
  tracker.cssMapVariables.set(variableName, keys);
84
+
85
+ // Check if this variable was used before it was declared
86
+ var violationsToRemove = [];
87
+ potentialViolations.forEach(function (violation, index) {
88
+ if (violation.identifierName === variableName) {
89
+ if (violation.type === 'identifier') {
90
+ // Identifier usage of cssMap variable is invalid (e.g., styles instead of styles.root)
91
+ context.report({
92
+ node: violation.node,
93
+ messageId: 'missingCssMapKey',
94
+ data: {
95
+ identifier: variableName
96
+ }
97
+ });
98
+ violationsToRemove.push(index);
99
+ }
100
+ // Member expressions with cssMap are valid (e.g., styles.root) - just remove from list
101
+ // No need to report or keep in list
102
+ if (violation.type === 'memberExpression') {
103
+ violationsToRemove.push(index);
104
+ }
105
+ }
106
+ });
107
+ // Remove violations in reverse order to maintain indices
108
+ violationsToRemove.reverse().forEach(function (index) {
109
+ potentialViolations.splice(index, 1);
110
+ });
79
111
  }
80
112
 
81
113
  // Track xcss variables
82
114
  if (tracker.xcssFunction.has(calleeName)) {
83
115
  tracker.xcssVariables.add(variableName);
116
+
117
+ // Check if this variable was used before it was declared
118
+ var _violationsToRemove = [];
119
+ potentialViolations.forEach(function (violation, index) {
120
+ if (violation.identifierName === variableName) {
121
+ context.report({
122
+ node: violation.node,
123
+ messageId: 'noXcssWithCompiled'
124
+ });
125
+ _violationsToRemove.push(index);
126
+ }
127
+ });
128
+ // Remove violations in reverse order to maintain indices
129
+ _violationsToRemove.reverse().forEach(function (index) {
130
+ potentialViolations.splice(index, 1);
131
+ });
84
132
  }
85
133
  },
86
134
  // Check JSX elements for xcss prop usage
@@ -132,6 +180,13 @@ var rule = createLintRule({
132
180
  identifier: identifierName
133
181
  }
134
182
  });
183
+ } else {
184
+ // Variable not yet declared - store for later check
185
+ potentialViolations.push({
186
+ node: expression,
187
+ identifierName: identifierName,
188
+ type: 'identifier'
189
+ });
135
190
  }
136
191
  return;
137
192
  }
@@ -144,8 +199,39 @@ var rule = createLintRule({
144
199
  node: expression,
145
200
  messageId: 'noXcssWithCompiled'
146
201
  });
202
+ } else if (!tracker.cssMapVariables.has(objectName)) {
203
+ // Variable not yet declared - store for later check
204
+ // Note: If it's already a cssMap variable, member expressions are valid (e.g., styles.root)
205
+ potentialViolations.push({
206
+ node: expression,
207
+ identifierName: objectName,
208
+ type: 'memberExpression'
209
+ });
147
210
  }
211
+ // If it's a cssMap variable, member expressions are valid - no action needed
148
212
  }
213
+ },
214
+ // Final check after all declarations are processed
215
+ 'Program:exit': function ProgramExit() {
216
+ // Check remaining potential violations against all collected declarations
217
+ potentialViolations.forEach(function (violation) {
218
+ if (tracker.xcssVariables.has(violation.identifierName)) {
219
+ context.report({
220
+ node: violation.node,
221
+ messageId: 'noXcssWithCompiled'
222
+ });
223
+ } else if (tracker.cssMapVariables.has(violation.identifierName) && violation.type === 'identifier') {
224
+ // Only report cssMap violations for identifier usage (not member expressions)
225
+ // Member expressions like stylesMap.root are valid
226
+ context.report({
227
+ node: violation.node,
228
+ messageId: 'missingCssMapKey',
229
+ data: {
230
+ identifier: violation.identifierName
231
+ }
232
+ });
233
+ }
234
+ });
149
235
  }
150
236
  });
151
237
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@atlaskit/eslint-plugin-design-system",
3
3
  "description": "The essential plugin for use with the Atlassian Design System.",
4
- "version": "13.23.1",
4
+ "version": "13.23.3",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
7
7
  "publishConfig": {
@@ -41,7 +41,7 @@
41
41
  "@atlaskit/eslint-utils": "^2.0.0",
42
42
  "@atlaskit/icon": "^28.5.0",
43
43
  "@atlaskit/icon-lab": "^5.11.0",
44
- "@atlaskit/tokens": "^7.1.0",
44
+ "@atlaskit/tokens": "^8.0.0",
45
45
  "@babel/runtime": "^7.0.0",
46
46
  "@typescript-eslint/utils": "^7.1.0",
47
47
  "ajv": "^6.12.6",
@@ -54,7 +54,7 @@
54
54
  },
55
55
  "devDependencies": {
56
56
  "@af/formatting": "workspace:^",
57
- "@atlaskit/ds-lib": "^5.1.0",
57
+ "@atlaskit/ds-lib": "^5.2.0",
58
58
  "@atlaskit/theme": "^21.0.0",
59
59
  "@atlassian/codegen": "^0.1.0",
60
60
  "@atlassian/eslint-utils": "^0.5.0",