@atlaskit/eslint-plugin-ui-styling-standard 0.8.1 → 0.8.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,11 @@
1
1
  # @atlaskit/eslint-plugin-ui-styling-standard
2
2
 
3
+ ## 0.8.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [#88753](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/88753) [`df5cbd4957ea`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/df5cbd4957ea) - Fixed no nested selectors rule to skip @ queries, cssMap and keyFrames calls
8
+
3
9
  ## 0.8.1
4
10
 
5
11
  ### Patch Changes
@@ -54,7 +54,7 @@ var rule = exports.rule = (0, _createRule.createLintRule)({
54
54
  references = _context$getScope.references;
55
55
  var ancestors = context.getAncestors();
56
56
  if (ancestors.every(function (ancestor) {
57
- return ancestor.type !== 'CallExpression' || !(ancestor !== null && ancestor !== void 0 && ancestor.callee) || !((0, _isSupportedImport.isCss)(ancestor.callee, references, importSources) || (0, _isSupportedImport.isStyled)(ancestor.callee, references, importSources) || (0, _isSupportedImport.isKeyframes)(ancestor.callee, references, importSources) || (0, _isSupportedImport.isCssMap)(ancestor.callee, references, importSources) || (0, _isSupportedImport.isXcss)(ancestor.callee, references, importSources));
57
+ return ancestor.type !== 'CallExpression' || !(ancestor !== null && ancestor !== void 0 && ancestor.callee) || !((0, _isSupportedImport.isCss)(ancestor.callee, references, importSources) || (0, _isSupportedImport.isStyled)(ancestor.callee, references, importSources) || (0, _isSupportedImport.isXcss)(ancestor.callee, references, importSources));
58
58
  })) {
59
59
  return;
60
60
  }
@@ -67,7 +67,7 @@ var rule = exports.rule = (0, _createRule.createLintRule)({
67
67
  return;
68
68
  }
69
69
  var tokens = cssSelector.split(/[, ]+/);
70
- if (!tokens.every(function (token) {
70
+ if (!cssSelector.includes('@') && !tokens.every(function (token) {
71
71
  return token.length === 0 || token.startsWith('&') || token.startsWith(':') || token.includes('+') || token.includes('~') || token.endsWith('&');
72
72
  })) {
73
73
  context.report({
@@ -1,4 +1,4 @@
1
- import { isStyled, isCss, isKeyframes, isCssMap, isXcss, getImportSources } from '@atlaskit/eslint-utils/is-supported-import';
1
+ import { isStyled, isCss, isXcss, getImportSources } from '@atlaskit/eslint-utils/is-supported-import';
2
2
  import { createLintRule } from '../utils/create-rule';
3
3
  const schema = [{
4
4
  type: 'object',
@@ -46,7 +46,7 @@ export const rule = createLintRule({
46
46
  references
47
47
  } = context.getScope();
48
48
  const ancestors = context.getAncestors();
49
- if (ancestors.every(ancestor => ancestor.type !== 'CallExpression' || !(ancestor !== null && ancestor !== void 0 && ancestor.callee) || !(isCss(ancestor.callee, references, importSources) || isStyled(ancestor.callee, references, importSources) || isKeyframes(ancestor.callee, references, importSources) || isCssMap(ancestor.callee, references, importSources) || isXcss(ancestor.callee, references, importSources)))) {
49
+ if (ancestors.every(ancestor => ancestor.type !== 'CallExpression' || !(ancestor !== null && ancestor !== void 0 && ancestor.callee) || !(isCss(ancestor.callee, references, importSources) || isStyled(ancestor.callee, references, importSources) || isXcss(ancestor.callee, references, importSources)))) {
50
50
  return;
51
51
  }
52
52
  if (node.value.type !== 'ObjectExpression') {
@@ -58,7 +58,7 @@ export const rule = createLintRule({
58
58
  return;
59
59
  }
60
60
  const tokens = cssSelector.split(/[, ]+/);
61
- if (!tokens.every(token => token.length === 0 || token.startsWith('&') || token.startsWith(':') || token.includes('+') || token.includes('~') || token.endsWith('&'))) {
61
+ if (!cssSelector.includes('@') && !tokens.every(token => token.length === 0 || token.startsWith('&') || token.startsWith(':') || token.includes('+') || token.includes('~') || token.endsWith('&'))) {
62
62
  context.report({
63
63
  messageId: 'no-nested-selectors',
64
64
  node: node.key
@@ -1,4 +1,4 @@
1
- import { isStyled, isCss, isKeyframes, isCssMap, isXcss, getImportSources } from '@atlaskit/eslint-utils/is-supported-import';
1
+ import { isStyled, isCss, isXcss, getImportSources } from '@atlaskit/eslint-utils/is-supported-import';
2
2
  import { createLintRule } from '../utils/create-rule';
3
3
  var schema = [{
4
4
  type: 'object',
@@ -48,7 +48,7 @@ export var rule = createLintRule({
48
48
  references = _context$getScope.references;
49
49
  var ancestors = context.getAncestors();
50
50
  if (ancestors.every(function (ancestor) {
51
- return ancestor.type !== 'CallExpression' || !(ancestor !== null && ancestor !== void 0 && ancestor.callee) || !(isCss(ancestor.callee, references, importSources) || isStyled(ancestor.callee, references, importSources) || isKeyframes(ancestor.callee, references, importSources) || isCssMap(ancestor.callee, references, importSources) || isXcss(ancestor.callee, references, importSources));
51
+ return ancestor.type !== 'CallExpression' || !(ancestor !== null && ancestor !== void 0 && ancestor.callee) || !(isCss(ancestor.callee, references, importSources) || isStyled(ancestor.callee, references, importSources) || isXcss(ancestor.callee, references, importSources));
52
52
  })) {
53
53
  return;
54
54
  }
@@ -61,7 +61,7 @@ export var rule = createLintRule({
61
61
  return;
62
62
  }
63
63
  var tokens = cssSelector.split(/[, ]+/);
64
- if (!tokens.every(function (token) {
64
+ if (!cssSelector.includes('@') && !tokens.every(function (token) {
65
65
  return token.length === 0 || token.startsWith('&') || token.startsWith(':') || token.includes('+') || token.includes('~') || token.endsWith('&');
66
66
  })) {
67
67
  context.report({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/eslint-plugin-ui-styling-standard",
3
- "version": "0.8.1",
3
+ "version": "0.8.2",
4
4
  "author": "Atlassian Pty Ltd",
5
5
  "description": "The eslint plugin to enforce and educate on Atlassian's UI Styling Standard",
6
6
  "license": "Apache-2.0",
@@ -94,6 +94,55 @@ typescriptEslintTester.run(
94
94
  });
95
95
  `,
96
96
  },
97
+ {
98
+ name: 'Skips @ queries',
99
+ code: `
100
+ import { css } from '@compiled/react';
101
+ const styles = css({
102
+ '@container (width > 400px)': {
103
+ fontSize: '1.5rem',
104
+ },
105
+ '@media (max-width: 1200px)': {
106
+ gridTemplateColumns: 'repeat(1, 1fr)',
107
+ justifyItems: 'center',
108
+ },
109
+ });
110
+ `,
111
+ },
112
+ {
113
+ name: 'Skip cssMap call',
114
+ code: `
115
+ import { cssMap } from '@atlaskit/css';
116
+
117
+ const styles = cssMap({
118
+ success: {
119
+ color: 'var(--ds-text-inverse)',
120
+ backgroundColor: 'var(--ds-background-success-bold)',
121
+ '&:hover': {
122
+ backgroundColor: 'var(--ds-background-success-bold-hovered)',
123
+ },
124
+ '&:active': {
125
+ backgroundColor: 'var(--ds-background-success-bold-pressed)',
126
+ },
127
+ },
128
+ });
129
+ `,
130
+ },
131
+ {
132
+ name: 'Skip keyframes call',
133
+ code: `
134
+ import { keyframes } from '@emotion/react';
135
+
136
+ const keyFrameStyles = keyframes({
137
+ 'from, to': {
138
+ opacity: 0,
139
+ },
140
+ '50%': {
141
+ opacity: 1,
142
+ },
143
+ });
144
+ `,
145
+ },
97
146
  ],
98
147
  invalid: [
99
148
  {
@@ -3,8 +3,6 @@ import type { Property } from 'estree';
3
3
  import {
4
4
  isStyled,
5
5
  isCss,
6
- isKeyframes,
7
- isCssMap,
8
6
  isXcss,
9
7
  getImportSources,
10
8
  } from '@atlaskit/eslint-utils/is-supported-import';
@@ -70,8 +68,6 @@ export const rule = createLintRule({
70
68
  !(
71
69
  isCss(ancestor.callee, references, importSources) ||
72
70
  isStyled(ancestor.callee, references, importSources) ||
73
- isKeyframes(ancestor.callee, references, importSources) ||
74
- isCssMap(ancestor.callee, references, importSources) ||
75
71
  isXcss(ancestor.callee, references, importSources)
76
72
  ),
77
73
  )
@@ -92,6 +88,7 @@ export const rule = createLintRule({
92
88
  const tokens = cssSelector.split(/[, ]+/);
93
89
 
94
90
  if (
91
+ !cssSelector.includes('@') &&
95
92
  !tokens.every(
96
93
  (token) =>
97
94
  token.length === 0 ||