@atlaskit/eslint-plugin-ui-styling-standard 0.16.0 → 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,22 @@
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
+
11
+ ## 0.16.1
12
+
13
+ ### Patch Changes
14
+
15
+ - [#110975](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/110975)
16
+ [`47a912f14bb6f`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/47a912f14bb6f) -
17
+ Fixed a bug in `walkStyleProperties` that could result in `styled(BaseComponent)({})` styles to
18
+ not be linted.
19
+
3
20
  ## 0.16.0
4
21
 
5
22
  ### Minor Changes
@@ -2,4 +2,6 @@
2
2
 
3
3
  Ensures consistency with all `css` and `xcss` prop usages.
4
4
 
5
- This rule is maintained by another package and configured here; refer to https://atlassian.design/components/eslint-plugin-design-system/consistent-css-prop-usage/usage for more details.
5
+ This rule is maintained by another package and configured here; refer to
6
+ https://atlassian.design/components/eslint-plugin-design-system/consistent-css-prop-usage/usage for
7
+ more details.
@@ -1,5 +1,8 @@
1
1
  # @atlaskit/design-system/no-css-tagged-template-expression
2
2
 
3
- Disallows any `css` tagged template expressions that originate from a CSS-in-JS library, including `@atlaskit/css`, `@compiled/react`, Emotion, and `styled-components`.
3
+ Disallows any `css` tagged template expressions that originate from a CSS-in-JS library, including
4
+ `@atlaskit/css`, `@compiled/react`, Emotion, and `styled-components`.
4
5
 
5
- This rule is maintained by another package and configured here; refer to https://atlassian.design/components/eslint-plugin-design-system/no-css-tagged-template-expression/usage for more details.
6
+ This rule is maintained by another package and configured here; refer to
7
+ https://atlassian.design/components/eslint-plugin-design-system/no-css-tagged-template-expression/usage
8
+ for more details.
@@ -1,5 +1,8 @@
1
1
  # @atlaskit/design-system/no-empty-styled-expression
2
2
 
3
- Forbids any styled expression to be used when passing empty arguments to styled.div() (or other JSX elements).
3
+ Forbids any styled expression to be used when passing empty arguments to styled.div() (or other JSX
4
+ elements).
4
5
 
5
- This rule is maintained by another package and configured here; refer to https://atlassian.design/components/eslint-plugin-design-system/no-empty-styled-expression/usage for more details.
6
+ This rule is maintained by another package and configured here; refer to
7
+ https://atlassian.design/components/eslint-plugin-design-system/no-empty-styled-expression/usage for
8
+ more details.
@@ -1,5 +1,8 @@
1
1
  # @atlaskit/design-system/no-exported-css
2
2
 
3
- Forbid exporting `css` function calls. Exporting `css` function calls can result in unexpected behaviour at runtime, and is not statically analysable.
3
+ Forbid exporting `css` function calls. Exporting `css` function calls can result in unexpected
4
+ behaviour at runtime, and is not statically analysable.
4
5
 
5
- This rule is maintained by another package and configured here; refer to https://atlassian.design/components/eslint-plugin-design-system/no-exported-css/usage for more details.
6
+ This rule is maintained by another package and configured here; refer to
7
+ https://atlassian.design/components/eslint-plugin-design-system/no-exported-css/usage for more
8
+ details.
@@ -1,5 +1,8 @@
1
1
  # @atlaskit/design-system/no-exported-keyframes
2
2
 
3
- Forbid exporting `keyframes` function calls. Exporting `css` function calls can result in unexpected behaviour at runtime, and is not statically analysable.
3
+ Forbid exporting `keyframes` function calls. Exporting `css` function calls can result in unexpected
4
+ behaviour at runtime, and is not statically analysable.
4
5
 
5
- This rule is maintained by another package and configured here; refer to https://atlassian.design/components/eslint-plugin-design-system/no-exported-keyframes/usage for more details.
6
+ This rule is maintained by another package and configured here; refer to
7
+ https://atlassian.design/components/eslint-plugin-design-system/no-exported-keyframes/usage for more
8
+ details.
@@ -1,5 +1,8 @@
1
1
  # @atlaskit/design-system/no-invalid-css-map
2
2
 
3
- Ensure that all usages of the cssMap API are valid, and enforces the format of the object that is passed to cssMap. This is intended to be used alongside TypeScript's type-checking.
3
+ Ensure that all usages of the cssMap API are valid, and enforces the format of the object that is
4
+ passed to cssMap. This is intended to be used alongside TypeScript's type-checking.
4
5
 
5
- This rule is maintained by another package and configured here; refer to https://atlassian.design/components/eslint-plugin-design-system/no-invalid-css-map/usage for more details.
6
+ This rule is maintained by another package and configured here; refer to
7
+ https://atlassian.design/components/eslint-plugin-design-system/no-invalid-css-map/usage for more
8
+ details.
@@ -2,4 +2,6 @@
2
2
 
3
3
  Disallows using xcss prop inside JavaScript files.
4
4
 
5
- This rule is maintained by another package and configured here; refer to https://github.com/atlassian-labs/compiled/tree/master/packages/eslint-plugin/src/rules/no-js-xcss for more details.
5
+ This rule is maintained by another package and configured here; refer to
6
+ https://github.com/atlassian-labs/compiled/tree/master/packages/eslint-plugin/src/rules/no-js-xcss
7
+ for more details.
@@ -1,5 +1,8 @@
1
1
  # @atlaskit/design-system/no-keyframes-tagged-template-expression
2
2
 
3
- Disallows any `keyframes` tagged template expressions that originate from a CSS-in-JS library, including `@atlaskit/css`, `@compiled/react`, Emotion, and `styled-components`.
3
+ Disallows any `keyframes` tagged template expressions that originate from a CSS-in-JS library,
4
+ including `@atlaskit/css`, `@compiled/react`, Emotion, and `styled-components`.
4
5
 
5
- This rule is maintained by another package and configured here; refer to https://atlassian.design/components/eslint-plugin-design-system/no-keyframes-tagged-template-expression/usage for more details.
6
+ This rule is maintained by another package and configured here; refer to
7
+ https://atlassian.design/components/eslint-plugin-design-system/no-keyframes-tagged-template-expression/usage
8
+ for more details.
@@ -1,5 +1,8 @@
1
1
  # @atlaskit/design-system/no-styled-tagged-template-expression
2
2
 
3
- Disallows any `styled` tagged template expressions that originate from from a CSS-in-JS library, including `@atlaskit/css`, `@compiled/react`, Emotion, and `styled-components`.
3
+ Disallows any `styled` tagged template expressions that originate from from a CSS-in-JS library,
4
+ including `@atlaskit/css`, `@compiled/react`, Emotion, and `styled-components`.
4
5
 
5
- This rule is maintained by another package and configured here; refer to https://atlassian.design/components/eslint-plugin-design-system/no-styled-tagged-template-expression/usage for more details.
6
+ This rule is maintained by another package and configured here; refer to
7
+ https://atlassian.design/components/eslint-plugin-design-system/no-styled-tagged-template-expression/usage
8
+ for more details.
@@ -1,12 +1,15 @@
1
1
  # @compiled/no-suppress-xcss
2
2
 
3
- Disallows supressing type violations when using the xcss prop. Supressing type violations will cause incidents and unexpected behaviour when code changes in the future.
3
+ Disallows supressing type violations when using the xcss prop. Supressing type violations will cause
4
+ incidents and unexpected behaviour when code changes in the future.
4
5
 
5
- Components that use xcss prop have explicitly declared what styles they should and should not accept, consumers must adhere to this API.
6
+ Components that use xcss prop have explicitly declared what styles they should and should not
7
+ accept, consumers must adhere to this API.
6
8
 
7
9
  ## Incorrect
8
10
 
9
- Do not suppress type violations; if the value doesn't match the type, fix the value or expect breaking changes in the future.
11
+ Do not suppress type violations; if the value doesn't match the type, fix the value or expect
12
+ breaking changes in the future.
10
13
 
11
14
  ```js
12
15
  // @ts-expect-error
@@ -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.0",
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.6.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
  };
@@ -317,6 +317,19 @@ typescriptEslintTester.run(
317
317
  `,
318
318
  errors: [{ messageId: 'no-nested-selectors' }],
319
319
  },
320
+ {
321
+ name: 'Nested selector inside styled(BaseComponent)()',
322
+ code: `
323
+ import { styled } from '@compiled/react';
324
+ import { BaseComponent } from './base-component';
325
+ styled(BaseComponent)({
326
+ '> span': {
327
+ color: 'orange'
328
+ }
329
+ });
330
+ `,
331
+ errors: [{ messageId: 'no-nested-selectors' }],
332
+ },
320
333
  ],
321
334
  },
322
335
  );
@@ -127,6 +127,25 @@ tester.run('no-unsafe-selectors', rule, {
127
127
  },
128
128
  ],
129
129
  },
130
+ {
131
+ name: 'styled API extending base component',
132
+ code: `
133
+ import { styled } from '@compiled/react';
134
+ import { BaseComponent } from './base-component';
135
+
136
+ styled(BaseComponent)({
137
+ '@keyframes fadeIn': {},
138
+ });
139
+ `,
140
+ errors: [
141
+ {
142
+ messageId: 'no-keyframes-at-rules',
143
+ line: 6,
144
+ column: 11,
145
+ endColumn: 30,
146
+ },
147
+ ],
148
+ },
130
149
  {
131
150
  name: 'keyframes API invalid usage',
132
151
  code: outdent`