@atlaskit/eslint-plugin-ui-styling-standard 0.16.1 → 0.16.2

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,13 @@
1
1
  # @atlaskit/eslint-plugin-ui-styling-standard
2
2
 
3
+ ## 0.16.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [#109764](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/109764)
8
+ [`5ceaeae2bef25`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/5ceaeae2bef25) -
9
+ Fixes `no-imported-style-values` to ignore imported values that exist in the type level
10
+
3
11
  ## 0.16.1
4
12
 
5
13
  ### Patch Changes
@@ -127,16 +127,7 @@ var rule = exports.rule = (0, _createRule.createLintRule)({
127
127
  }
128
128
  node.arguments.forEach(checkForIdentifiers);
129
129
  },
130
- 'JSXAttribute[name.name="css"] Identifier': function JSXAttributeNameNameCssIdentifier(node) {
131
- if (node.type !== 'Identifier') {
132
- return;
133
- }
134
- checkIdentifier(node, context, functionAllowList, keysAllowList);
135
- },
136
- 'JSXAttribute[name.name="style"] Identifier': function JSXAttributeNameNameStyleIdentifier(node) {
137
- if (node.type !== 'Identifier') {
138
- return;
139
- }
130
+ 'JSXAttribute[name.name=/^style|css$/] Identifier:not(TSTypeReference Identifier)': function JSXAttributeNameNameStyleCss$IdentifierNotTSTypeReferenceIdentifier(node) {
140
131
  checkIdentifier(node, context, functionAllowList, keysAllowList);
141
132
  }
142
133
  };
@@ -107,16 +107,7 @@ export const rule = createLintRule({
107
107
  }
108
108
  node.arguments.forEach(checkForIdentifiers);
109
109
  },
110
- 'JSXAttribute[name.name="css"] Identifier': node => {
111
- if (node.type !== 'Identifier') {
112
- return;
113
- }
114
- checkIdentifier(node, context, functionAllowList, keysAllowList);
115
- },
116
- 'JSXAttribute[name.name="style"] Identifier': node => {
117
- if (node.type !== 'Identifier') {
118
- return;
119
- }
110
+ 'JSXAttribute[name.name=/^style|css$/] Identifier:not(TSTypeReference Identifier)'(node) {
120
111
  checkIdentifier(node, context, functionAllowList, keysAllowList);
121
112
  }
122
113
  };
@@ -120,16 +120,7 @@ export var rule = createLintRule({
120
120
  }
121
121
  node.arguments.forEach(checkForIdentifiers);
122
122
  },
123
- 'JSXAttribute[name.name="css"] Identifier': function JSXAttributeNameNameCssIdentifier(node) {
124
- if (node.type !== 'Identifier') {
125
- return;
126
- }
127
- checkIdentifier(node, context, functionAllowList, keysAllowList);
128
- },
129
- 'JSXAttribute[name.name="style"] Identifier': function JSXAttributeNameNameStyleIdentifier(node) {
130
- if (node.type !== 'Identifier') {
131
- return;
132
- }
123
+ 'JSXAttribute[name.name=/^style|css$/] Identifier:not(TSTypeReference Identifier)': function JSXAttributeNameNameStyleCss$IdentifierNotTSTypeReferenceIdentifier(node) {
133
124
  checkIdentifier(node, context, functionAllowList, keysAllowList);
134
125
  }
135
126
  };
package/package.json CHANGED
@@ -1,71 +1,66 @@
1
1
  {
2
- "name": "@atlaskit/eslint-plugin-ui-styling-standard",
3
- "version": "0.16.1",
4
- "author": "Atlassian Pty Ltd",
5
- "description": "The eslint plugin to enforce and educate on Atlassian's UI Styling Standard",
6
- "license": "Apache-2.0",
7
- "atlassian": {
8
- "team": "Design System Team",
9
- "inPublicMirror": true,
10
- "releaseModel": "continuous",
11
- "website": {
12
- "name": "UI Styling Standard",
13
- "category": "Tooling"
14
- },
15
- "productPushConsumption": [
16
- "jira"
17
- ]
18
- },
19
- "publishConfig": {
20
- "registry": "https://registry.npmjs.org/"
21
- },
22
- "homepage": "https://atlassian.design/components/eslint-plugin-ui-styling-standard",
23
- "repository": "https://bitbucket.org/atlassian/atlassian-frontend-mirror",
24
- "main": "dist/cjs/index.js",
25
- "module": "dist/esm/index.js",
26
- "module:es2019": "dist/es2019/index.js",
27
- "types": "dist/types/index.d.ts",
28
- "typesVersions": {
29
- ">=4.5 <4.9": {
30
- "*": [
31
- "dist/types-ts4.5/*",
32
- "dist/types-ts4.5/index.d.ts"
33
- ]
34
- }
35
- },
36
- "sideEffects": false,
37
- "atlaskit:src": "src/index.tsx",
38
- "af:exports": {
39
- ".": "./src/index.tsx"
40
- },
41
- "dependencies": {
42
- "@atlaskit/eslint-utils": "^1.6.0",
43
- "@babel/runtime": "^7.0.0",
44
- "@typescript-eslint/utils": "^5.48.1",
45
- "ajv": "^6.12.6",
46
- "eslint-codemod-utils": "^1.8.6",
47
- "eslint-scope": "^8.0.0",
48
- "esquery": "^1.5.0",
49
- "estraverse": "^5.3.0",
50
- "json-schema-to-ts": "^3.1.0",
51
- "outdent": "^0.5.0",
52
- "postcss-selector-parser": "^6.0.16"
53
- },
54
- "devDependencies": {
55
- "@af/formatting": "*",
56
- "@atlaskit/ds-lib": "^2.3.0",
57
- "@atlaskit/eslint-plugin-design-system": "^10.7.0",
58
- "@atlassian/codegen": "*",
59
- "@compiled/eslint-plugin": "^0.13.6",
60
- "@types/eslint": "^8.56.6",
61
- "@types/estraverse": "^5.1.7",
62
- "eslint": "^8.49.0",
63
- "lodash": "^4.17.21",
64
- "ts-node": "^10.9.1",
65
- "tsconfig-paths": "^4.2.0",
66
- "typescript": "~5.4.2"
67
- },
68
- "scripts": {
69
- "codegen": "ts-node -r tsconfig-paths/register ./scripts/codegen.tsx"
70
- }
71
- }
2
+ "name": "@atlaskit/eslint-plugin-ui-styling-standard",
3
+ "version": "0.16.2",
4
+ "author": "Atlassian Pty Ltd",
5
+ "description": "The eslint plugin to enforce and educate on Atlassian's UI Styling Standard",
6
+ "license": "Apache-2.0",
7
+ "atlassian": {
8
+ "team": "Design System Team",
9
+ "inPublicMirror": true,
10
+ "releaseModel": "continuous",
11
+ "website": {
12
+ "name": "UI Styling Standard",
13
+ "category": "Tooling"
14
+ },
15
+ "productPushConsumption": ["jira"]
16
+ },
17
+ "publishConfig": {
18
+ "registry": "https://registry.npmjs.org/"
19
+ },
20
+ "homepage": "https://atlassian.design/components/eslint-plugin-ui-styling-standard",
21
+ "repository": "https://bitbucket.org/atlassian/atlassian-frontend-mirror",
22
+ "main": "dist/cjs/index.js",
23
+ "module": "dist/esm/index.js",
24
+ "module:es2019": "dist/es2019/index.js",
25
+ "types": "dist/types/index.d.ts",
26
+ "typesVersions": {
27
+ ">=4.5 <4.9": {
28
+ "*": ["dist/types-ts4.5/*", "dist/types-ts4.5/index.d.ts"]
29
+ }
30
+ },
31
+ "sideEffects": false,
32
+ "atlaskit:src": "src/index.tsx",
33
+ "af:exports": {
34
+ ".": "./src/index.tsx"
35
+ },
36
+ "dependencies": {
37
+ "@atlaskit/eslint-utils": "^1.6.0",
38
+ "@babel/runtime": "^7.0.0",
39
+ "@typescript-eslint/utils": "^5.48.1",
40
+ "ajv": "^6.12.6",
41
+ "eslint-codemod-utils": "^1.8.6",
42
+ "eslint-scope": "^8.0.0",
43
+ "esquery": "^1.5.0",
44
+ "estraverse": "^5.3.0",
45
+ "json-schema-to-ts": "^3.1.0",
46
+ "outdent": "^0.5.0",
47
+ "postcss-selector-parser": "^6.0.16"
48
+ },
49
+ "devDependencies": {
50
+ "@af/formatting": "*",
51
+ "@atlaskit/ds-lib": "^2.3.0",
52
+ "@atlaskit/eslint-plugin-design-system": "^10.7.0",
53
+ "@atlassian/codegen": "*",
54
+ "@compiled/eslint-plugin": "^0.13.6",
55
+ "@types/eslint": "^8.56.6",
56
+ "@types/estraverse": "^5.1.7",
57
+ "eslint": "^8.49.0",
58
+ "lodash": "^4.17.21",
59
+ "ts-node": "^10.9.1",
60
+ "tsconfig-paths": "^4.2.0",
61
+ "typescript": "~5.4.2"
62
+ },
63
+ "scripts": {
64
+ "codegen": "ts-node -r tsconfig-paths/register ./scripts/codegen.tsx"
65
+ }
66
+ }
@@ -123,6 +123,24 @@ typescriptEslintTester.run(
123
123
  },
124
124
  ],
125
125
  },
126
+ {
127
+ name: 'Ignores type casts',
128
+ code: `
129
+ import type { CSSProperties } from 'react';
130
+ import { css } from '@compiled/react';
131
+
132
+ const Component = () => (
133
+ <div
134
+ style={
135
+ {
136
+ '--my-var': 'red',
137
+ } as CSSProperties
138
+ }
139
+ />
140
+ );
141
+ `,
142
+ options: [],
143
+ },
126
144
  ],
127
145
  invalid: [
128
146
  {
@@ -253,7 +271,7 @@ typescriptEslintTester.run(
253
271
  code: `
254
272
  import { hello } from 'package';
255
273
  import { css } from '@compiled/react';
256
-
274
+
257
275
  const styles = css({
258
276
  color: hello.world,
259
277
  });
@@ -12,7 +12,7 @@ import {
12
12
  getAllowedFunctionCalls,
13
13
  isAllowListedVariable,
14
14
  } from '@atlaskit/eslint-utils/allowed-function-calls';
15
- import type { Identifier, Node } from 'eslint-codemod-utils';
15
+ import type * as ESTree from 'eslint-codemod-utils';
16
16
  import esquery from 'esquery';
17
17
 
18
18
  const schema: JSONSchema4 = [
@@ -49,7 +49,7 @@ const schema: JSONSchema4 = [
49
49
  ];
50
50
 
51
51
  const isIdentifierImported = (
52
- identifier: Identifier,
52
+ identifier: ESTree.Identifier,
53
53
  context: Rule.RuleContext,
54
54
  functionAllowList: AllowList,
55
55
  keysAllowList: AllowList,
@@ -76,7 +76,7 @@ const isIdentifierImported = (
76
76
  };
77
77
 
78
78
  const checkIdentifier = (
79
- identifier: Identifier,
79
+ identifier: ESTree.Identifier,
80
80
  context: Rule.RuleContext,
81
81
  functionAllowList: AllowList,
82
82
  keysAllowList: AllowList,
@@ -109,7 +109,7 @@ export const rule = createLintRule({
109
109
  const functionAllowList = getAllowedFunctionCalls(context.options);
110
110
  const keysAllowList = getAllowedDynamicKeys(context.options);
111
111
 
112
- const checkForIdentifiers = (node: Node) => {
112
+ const checkForIdentifiers = (node: ESTree.Node) => {
113
113
  const matches = esquery(node, 'Identifier');
114
114
 
115
115
  for (const match of matches) {
@@ -129,18 +129,9 @@ export const rule = createLintRule({
129
129
  }
130
130
  node.arguments.forEach(checkForIdentifiers);
131
131
  },
132
- 'JSXAttribute[name.name="css"] Identifier': (node: Node) => {
133
- if (node.type !== 'Identifier') {
134
- return;
135
- }
136
-
137
- checkIdentifier(node, context, functionAllowList, keysAllowList);
138
- },
139
- 'JSXAttribute[name.name="style"] Identifier': (node: Node) => {
140
- if (node.type !== 'Identifier') {
141
- return;
142
- }
143
-
132
+ 'JSXAttribute[name.name=/^style|css$/] Identifier:not(TSTypeReference Identifier)'(
133
+ node: ESTree.Identifier,
134
+ ) {
144
135
  checkIdentifier(node, context, functionAllowList, keysAllowList);
145
136
  },
146
137
  };