@atlaskit/eslint-plugin-ui-styling-standard 0.7.1 → 0.8.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.
- package/CHANGELOG.md +17 -0
- package/README.md +2 -1
- package/constellation/index/overview.mdx +2 -1
- package/constellation/no-nested-selectors/usage.mdx +60 -0
- package/dist/cjs/presets/all.codegen.js +3 -4
- package/dist/cjs/presets/recommended.codegen.js +3 -4
- package/dist/cjs/rules/convert-props-syntax/index.js +1 -1
- package/dist/cjs/rules/external-rules.js +1 -27
- package/dist/cjs/rules/index.codegen.js +4 -2
- package/dist/cjs/rules/local-cx-xcss/index.js +1 -1
- package/dist/cjs/rules/no-container-queries/index.js +1 -1
- package/dist/cjs/rules/no-important-styles/index.js +1 -1
- package/dist/cjs/rules/no-nested-selectors/index.js +82 -0
- package/dist/es2019/presets/all.codegen.js +3 -4
- package/dist/es2019/presets/recommended.codegen.js +3 -4
- package/dist/es2019/rules/convert-props-syntax/index.js +1 -1
- package/dist/es2019/rules/external-rules.js +1 -27
- package/dist/es2019/rules/index.codegen.js +4 -2
- package/dist/es2019/rules/local-cx-xcss/index.js +1 -1
- package/dist/es2019/rules/no-container-queries/index.js +1 -1
- package/dist/es2019/rules/no-important-styles/index.js +1 -1
- package/dist/es2019/rules/no-nested-selectors/index.js +71 -0
- package/dist/esm/presets/all.codegen.js +3 -4
- package/dist/esm/presets/recommended.codegen.js +3 -4
- package/dist/esm/rules/convert-props-syntax/index.js +1 -1
- package/dist/esm/rules/external-rules.js +1 -27
- package/dist/esm/rules/index.codegen.js +4 -2
- package/dist/esm/rules/local-cx-xcss/index.js +1 -1
- package/dist/esm/rules/no-container-queries/index.js +1 -1
- package/dist/esm/rules/no-important-styles/index.js +1 -1
- package/dist/esm/rules/no-nested-selectors/index.js +76 -0
- package/dist/types/index.codegen.d.ts +4 -6
- package/dist/types/presets/all.codegen.d.ts +3 -4
- package/dist/types/presets/recommended.codegen.d.ts +3 -4
- package/dist/types/rules/index.codegen.d.ts +1 -0
- package/dist/types/rules/no-nested-selectors/index.d.ts +2 -0
- package/dist/types-ts4.5/index.codegen.d.ts +4 -6
- package/dist/types-ts4.5/presets/all.codegen.d.ts +3 -4
- package/dist/types-ts4.5/presets/recommended.codegen.d.ts +3 -4
- package/dist/types-ts4.5/rules/index.codegen.d.ts +1 -0
- package/dist/types-ts4.5/rules/no-nested-selectors/index.d.ts +2 -0
- package/package.json +2 -1
- package/src/presets/all.codegen.tsx +3 -13
- package/src/presets/recommended.codegen.tsx +3 -13
- package/src/rules/convert-props-syntax/index.tsx +4 -1
- package/src/rules/external-rules.tsx +0 -30
- package/src/rules/index.codegen.tsx +3 -1
- package/src/rules/local-cx-xcss/index.tsx +4 -1
- package/src/rules/no-container-queries/index.tsx +1 -1
- package/src/rules/no-important-styles/index.tsx +1 -1
- package/src/rules/no-nested-selectors/README.md +58 -0
- package/src/rules/no-nested-selectors/__tests__/rule.test.tsx +236 -0
- package/src/rules/no-nested-selectors/index.tsx +115 -0
- package/tsconfig.app.json +3 -0
- package/dist/cjs/rules/utils/is-supported-import.js +0 -160
- package/dist/es2019/rules/utils/is-supported-import.js +0 -150
- package/dist/esm/rules/utils/is-supported-import.js +0 -154
- package/dist/types/rules/utils/is-supported-import.d.ts +0 -46
- package/dist/types-ts4.5/rules/utils/is-supported-import.d.ts +0 -46
- package/src/rules/utils/README.md +0 -1
- package/src/rules/utils/is-supported-import.tsx +0 -227
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
3
|
-
* @codegen <<SignedSource::
|
|
3
|
+
* @codegen <<SignedSource::7d08e77b09892b3650a472341ec77df3>>
|
|
4
4
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
|
|
5
5
|
*/
|
|
6
6
|
export default {
|
|
@@ -11,14 +11,13 @@ export default {
|
|
|
11
11
|
'@atlaskit/ui-styling-standard/no-classname-prop': 'warn',
|
|
12
12
|
'@atlaskit/ui-styling-standard/no-container-queries': 'warn',
|
|
13
13
|
'@atlaskit/ui-styling-standard/no-important-styles': 'warn',
|
|
14
|
+
'@atlaskit/ui-styling-standard/no-nested-selectors': 'warn',
|
|
14
15
|
'@atlaskit/design-system/consistent-css-prop-usage': ['warn', {
|
|
15
16
|
excludeReactComponents: true
|
|
16
17
|
}],
|
|
17
18
|
'@atlaskit/design-system/no-css-tagged-template-expression': 'warn',
|
|
18
19
|
'@atlaskit/design-system/no-keyframes-tagged-template-expression': 'warn',
|
|
19
|
-
'@atlaskit/design-system/no-styled-tagged-template-expression':
|
|
20
|
-
importSources: ['@compiled/react', '@atlaskit/css', '@emotion/core', '@emotion/react', '@emotion/styled']
|
|
21
|
-
}],
|
|
20
|
+
'@atlaskit/design-system/no-styled-tagged-template-expression': 'warn',
|
|
22
21
|
'@compiled/no-suppress-xcss': 'warn',
|
|
23
22
|
'@compiled/no-js-xcss': 'warn',
|
|
24
23
|
'@atlaskit/design-system/no-empty-styled-expression': ['warn', {
|
|
@@ -3,7 +3,7 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
|
|
|
3
3
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
4
4
|
import { analyze } from 'eslint-scope';
|
|
5
5
|
import { createLintRule } from '../utils/create-rule';
|
|
6
|
-
import { isStyledComponents, isEmotion } from '
|
|
6
|
+
import { isStyledComponents, isEmotion } from '@atlaskit/eslint-utils/is-supported-import';
|
|
7
7
|
import ESTraverse from 'estraverse';
|
|
8
8
|
|
|
9
9
|
/**
|
|
@@ -3,29 +3,6 @@ import { getRuleUrl } from './utils/create-rule';
|
|
|
3
3
|
/** External rules must be scoped, have a display name, and external urls. */
|
|
4
4
|
|
|
5
5
|
var importSources = ['@compiled/react', '@atlaskit/css', '@emotion/core', '@emotion/react', '@emotion/styled', 'styled-components'];
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Same as importSources, but excludes `styled-components` because the type-checking
|
|
9
|
-
* for `styled-components` does not support the `no-styled-tagged-template-expression`
|
|
10
|
-
* lint output for this:
|
|
11
|
-
*
|
|
12
|
-
* export const Container = styled(Section)`
|
|
13
|
-
* max-height: ${gridSize * 46}px;
|
|
14
|
-
* overflow: auto;
|
|
15
|
-
* `;
|
|
16
|
-
*
|
|
17
|
-
* export const ErrorStateContainer = styled(Container)`
|
|
18
|
-
* margin: ${
|
|
19
|
-
* (props: any) =>
|
|
20
|
-
* props.canManageAutomations // Use negative margin to reduce whitespace when the Footer component is shown
|
|
21
|
-
* ? `${gridSize * -4}px ${gridSize * 2}px`
|
|
22
|
-
* : `0 ${gridSize * 2}px`
|
|
23
|
-
* };
|
|
24
|
-
* `;
|
|
25
|
-
*/
|
|
26
|
-
var noStyledTaggedTemplateExpressionImportSources = ['@compiled/react', '@atlaskit/css',
|
|
27
|
-
// doesn't do anything because @atlaskit/css doesn't expose a styled API
|
|
28
|
-
'@emotion/core', '@emotion/react', '@emotion/styled'];
|
|
29
6
|
export var externalRules = [{
|
|
30
7
|
name: '@atlaskit/design-system/consistent-css-prop-usage',
|
|
31
8
|
displayName: 'consistent-css-prop-usage',
|
|
@@ -78,10 +55,7 @@ export var externalRules = [{
|
|
|
78
55
|
url: getRuleUrl('no-styled-tagged-template-expression'),
|
|
79
56
|
externalUrl: 'https://atlassian.design/components/eslint-plugin-design-system/no-styled-tagged-template-expression/usage',
|
|
80
57
|
recommended: true,
|
|
81
|
-
severity: 'warn'
|
|
82
|
-
pluginConfig: {
|
|
83
|
-
importSources: noStyledTaggedTemplateExpressionImportSources
|
|
84
|
-
}
|
|
58
|
+
severity: 'warn'
|
|
85
59
|
}
|
|
86
60
|
}, {
|
|
87
61
|
name: '@compiled/no-suppress-xcss',
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
3
|
-
* @codegen <<SignedSource::
|
|
3
|
+
* @codegen <<SignedSource::c50c5112f3633542ef17c291cd9d88a8>>
|
|
4
4
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
|
|
5
5
|
*/
|
|
6
6
|
import convertPropsSyntax from './convert-props-syntax';
|
|
@@ -8,10 +8,12 @@ import localCxXcss from './local-cx-xcss';
|
|
|
8
8
|
import noClassnameProp from './no-classname-prop';
|
|
9
9
|
import noContainerQueries from './no-container-queries';
|
|
10
10
|
import noImportantStyles from './no-important-styles';
|
|
11
|
+
import noNestedSelectors from './no-nested-selectors';
|
|
11
12
|
export default {
|
|
12
13
|
'convert-props-syntax': convertPropsSyntax,
|
|
13
14
|
'local-cx-xcss': localCxXcss,
|
|
14
15
|
'no-classname-prop': noClassnameProp,
|
|
15
16
|
'no-container-queries': noContainerQueries,
|
|
16
|
-
'no-important-styles': noImportantStyles
|
|
17
|
+
'no-important-styles': noImportantStyles,
|
|
18
|
+
'no-nested-selectors': noNestedSelectors
|
|
17
19
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createLintRule } from '../utils/create-rule';
|
|
2
|
-
import { CSS_IN_JS_IMPORTS, isCxFunction } from '
|
|
2
|
+
import { CSS_IN_JS_IMPORTS, isCxFunction } from '@atlaskit/eslint-utils/is-supported-import';
|
|
3
3
|
var IMPORT_SOURCES = [CSS_IN_JS_IMPORTS.compiled, CSS_IN_JS_IMPORTS.atlaskitCss];
|
|
4
4
|
function getParentJSXAttribute(node) {
|
|
5
5
|
var parent = node.parent;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import estraverse from 'estraverse';
|
|
2
2
|
import { createLintRule } from '../utils/create-rule';
|
|
3
|
-
import { isCss, getImportSources, isStyled, isKeyframes, isCssMap, isXcss } from '
|
|
3
|
+
import { isCss, getImportSources, isStyled, isKeyframes, isCssMap, isXcss } from '@atlaskit/eslint-utils/is-supported-import';
|
|
4
4
|
var schema = [{
|
|
5
5
|
type: 'object',
|
|
6
6
|
properties: {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import estraverse from 'estraverse';
|
|
2
2
|
import { createLintRule } from '../utils/create-rule';
|
|
3
|
-
import { isCss, getImportSources, isStyled, isKeyframes, isCssMap, isXcss } from '
|
|
3
|
+
import { isCss, getImportSources, isStyled, isKeyframes, isCssMap, isXcss } from '@atlaskit/eslint-utils/is-supported-import';
|
|
4
4
|
var schema = [{
|
|
5
5
|
type: 'object',
|
|
6
6
|
properties: {
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { isStyled, isCss, isKeyframes, isCssMap, isXcss, getImportSources } from '@atlaskit/eslint-utils/is-supported-import';
|
|
2
|
+
import { createLintRule } from '../utils/create-rule';
|
|
3
|
+
var schema = [{
|
|
4
|
+
type: 'object',
|
|
5
|
+
properties: {
|
|
6
|
+
importSources: {
|
|
7
|
+
type: 'array',
|
|
8
|
+
items: {
|
|
9
|
+
type: 'string'
|
|
10
|
+
},
|
|
11
|
+
uniqueItems: true
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}];
|
|
15
|
+
var getCssSelector = function getCssSelector(node) {
|
|
16
|
+
if (node.key.type === 'Literal' && typeof node.key.value === 'string') {
|
|
17
|
+
return node.key.value;
|
|
18
|
+
}
|
|
19
|
+
if (node.key.type === 'Identifier' && typeof node.key.name === 'string') {
|
|
20
|
+
return node.key.name;
|
|
21
|
+
}
|
|
22
|
+
if (node.key.type === 'TemplateLiteral') {
|
|
23
|
+
return node.key.quasis.map(function (quasi) {
|
|
24
|
+
return quasi.value.raw;
|
|
25
|
+
}).join(' ');
|
|
26
|
+
}
|
|
27
|
+
return null;
|
|
28
|
+
};
|
|
29
|
+
export var rule = createLintRule({
|
|
30
|
+
meta: {
|
|
31
|
+
name: 'no-nested-selectors',
|
|
32
|
+
docs: {
|
|
33
|
+
description: 'Prevents usage of nested selectors within css styling',
|
|
34
|
+
recommended: true,
|
|
35
|
+
severity: 'warn'
|
|
36
|
+
},
|
|
37
|
+
messages: {
|
|
38
|
+
'no-nested-selectors': 'Please avoid setting styles for child elements or elements that require context from other elements.'
|
|
39
|
+
},
|
|
40
|
+
type: 'problem',
|
|
41
|
+
schema: schema
|
|
42
|
+
},
|
|
43
|
+
create: function create(context) {
|
|
44
|
+
var importSources = getImportSources(context);
|
|
45
|
+
return {
|
|
46
|
+
'CallExpression Property': function CallExpressionProperty(node) {
|
|
47
|
+
var _context$getScope = context.getScope(),
|
|
48
|
+
references = _context$getScope.references;
|
|
49
|
+
var ancestors = context.getAncestors();
|
|
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));
|
|
52
|
+
})) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
if (node.value.type !== 'ObjectExpression') {
|
|
56
|
+
// If the value is a CSS object, safe to assume we're at a CSS selector
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
var cssSelector = getCssSelector(node);
|
|
60
|
+
if (cssSelector === null) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
var tokens = cssSelector.split(/[, ]+/);
|
|
64
|
+
if (!tokens.every(function (token) {
|
|
65
|
+
return token.length === 0 || token.startsWith('&') || token.startsWith(':') || token.includes('+') || token.includes('~') || token.endsWith('&');
|
|
66
|
+
})) {
|
|
67
|
+
context.report({
|
|
68
|
+
messageId: 'no-nested-selectors',
|
|
69
|
+
node: node.key
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
export default rule;
|
|
@@ -8,14 +8,13 @@ export declare const configs: {
|
|
|
8
8
|
'@atlaskit/ui-styling-standard/no-classname-prop': string;
|
|
9
9
|
'@atlaskit/ui-styling-standard/no-container-queries': string;
|
|
10
10
|
'@atlaskit/ui-styling-standard/no-important-styles': string;
|
|
11
|
+
'@atlaskit/ui-styling-standard/no-nested-selectors': string;
|
|
11
12
|
'@atlaskit/design-system/consistent-css-prop-usage': (string | {
|
|
12
13
|
excludeReactComponents: boolean;
|
|
13
14
|
})[];
|
|
14
15
|
'@atlaskit/design-system/no-css-tagged-template-expression': string;
|
|
15
16
|
'@atlaskit/design-system/no-keyframes-tagged-template-expression': string;
|
|
16
|
-
'@atlaskit/design-system/no-styled-tagged-template-expression':
|
|
17
|
-
importSources: string[];
|
|
18
|
-
})[];
|
|
17
|
+
'@atlaskit/design-system/no-styled-tagged-template-expression': string;
|
|
19
18
|
'@compiled/no-suppress-xcss': string;
|
|
20
19
|
'@compiled/no-js-xcss': string;
|
|
21
20
|
'@atlaskit/design-system/no-empty-styled-expression': (string | {
|
|
@@ -40,14 +39,13 @@ export declare const configs: {
|
|
|
40
39
|
'@atlaskit/ui-styling-standard/no-classname-prop': string;
|
|
41
40
|
'@atlaskit/ui-styling-standard/no-container-queries': string;
|
|
42
41
|
'@atlaskit/ui-styling-standard/no-important-styles': string;
|
|
42
|
+
'@atlaskit/ui-styling-standard/no-nested-selectors': string;
|
|
43
43
|
'@atlaskit/design-system/consistent-css-prop-usage': (string | {
|
|
44
44
|
excludeReactComponents: boolean;
|
|
45
45
|
})[];
|
|
46
46
|
'@atlaskit/design-system/no-css-tagged-template-expression': string;
|
|
47
47
|
'@atlaskit/design-system/no-keyframes-tagged-template-expression': string;
|
|
48
|
-
'@atlaskit/design-system/no-styled-tagged-template-expression':
|
|
49
|
-
importSources: string[];
|
|
50
|
-
})[];
|
|
48
|
+
'@atlaskit/design-system/no-styled-tagged-template-expression': string;
|
|
51
49
|
'@compiled/no-suppress-xcss': string;
|
|
52
50
|
'@compiled/no-js-xcss': string;
|
|
53
51
|
'@atlaskit/design-system/no-empty-styled-expression': (string | {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
3
|
-
* @codegen <<SignedSource::
|
|
3
|
+
* @codegen <<SignedSource::7d08e77b09892b3650a472341ec77df3>>
|
|
4
4
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
|
|
5
5
|
*/
|
|
6
6
|
declare const _default: {
|
|
@@ -11,14 +11,13 @@ declare const _default: {
|
|
|
11
11
|
'@atlaskit/ui-styling-standard/no-classname-prop': string;
|
|
12
12
|
'@atlaskit/ui-styling-standard/no-container-queries': string;
|
|
13
13
|
'@atlaskit/ui-styling-standard/no-important-styles': string;
|
|
14
|
+
'@atlaskit/ui-styling-standard/no-nested-selectors': string;
|
|
14
15
|
'@atlaskit/design-system/consistent-css-prop-usage': (string | {
|
|
15
16
|
excludeReactComponents: boolean;
|
|
16
17
|
})[];
|
|
17
18
|
'@atlaskit/design-system/no-css-tagged-template-expression': string;
|
|
18
19
|
'@atlaskit/design-system/no-keyframes-tagged-template-expression': string;
|
|
19
|
-
'@atlaskit/design-system/no-styled-tagged-template-expression':
|
|
20
|
-
importSources: string[];
|
|
21
|
-
})[];
|
|
20
|
+
'@atlaskit/design-system/no-styled-tagged-template-expression': string;
|
|
22
21
|
'@compiled/no-suppress-xcss': string;
|
|
23
22
|
'@compiled/no-js-xcss': string;
|
|
24
23
|
'@atlaskit/design-system/no-empty-styled-expression': (string | {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
3
|
-
* @codegen <<SignedSource::
|
|
3
|
+
* @codegen <<SignedSource::7d08e77b09892b3650a472341ec77df3>>
|
|
4
4
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
|
|
5
5
|
*/
|
|
6
6
|
declare const _default: {
|
|
@@ -11,14 +11,13 @@ declare const _default: {
|
|
|
11
11
|
'@atlaskit/ui-styling-standard/no-classname-prop': string;
|
|
12
12
|
'@atlaskit/ui-styling-standard/no-container-queries': string;
|
|
13
13
|
'@atlaskit/ui-styling-standard/no-important-styles': string;
|
|
14
|
+
'@atlaskit/ui-styling-standard/no-nested-selectors': string;
|
|
14
15
|
'@atlaskit/design-system/consistent-css-prop-usage': (string | {
|
|
15
16
|
excludeReactComponents: boolean;
|
|
16
17
|
})[];
|
|
17
18
|
'@atlaskit/design-system/no-css-tagged-template-expression': string;
|
|
18
19
|
'@atlaskit/design-system/no-keyframes-tagged-template-expression': string;
|
|
19
|
-
'@atlaskit/design-system/no-styled-tagged-template-expression':
|
|
20
|
-
importSources: string[];
|
|
21
|
-
})[];
|
|
20
|
+
'@atlaskit/design-system/no-styled-tagged-template-expression': string;
|
|
22
21
|
'@compiled/no-suppress-xcss': string;
|
|
23
22
|
'@compiled/no-js-xcss': string;
|
|
24
23
|
'@atlaskit/design-system/no-empty-styled-expression': (string | {
|
|
@@ -4,5 +4,6 @@ declare const _default: {
|
|
|
4
4
|
'no-classname-prop': import("eslint").Rule.RuleModule;
|
|
5
5
|
'no-container-queries': import("eslint").Rule.RuleModule;
|
|
6
6
|
'no-important-styles': import("eslint").Rule.RuleModule;
|
|
7
|
+
'no-nested-selectors': import("eslint").Rule.RuleModule;
|
|
7
8
|
};
|
|
8
9
|
export default _default;
|
|
@@ -8,14 +8,13 @@ export declare const configs: {
|
|
|
8
8
|
'@atlaskit/ui-styling-standard/no-classname-prop': string;
|
|
9
9
|
'@atlaskit/ui-styling-standard/no-container-queries': string;
|
|
10
10
|
'@atlaskit/ui-styling-standard/no-important-styles': string;
|
|
11
|
+
'@atlaskit/ui-styling-standard/no-nested-selectors': string;
|
|
11
12
|
'@atlaskit/design-system/consistent-css-prop-usage': (string | {
|
|
12
13
|
excludeReactComponents: boolean;
|
|
13
14
|
})[];
|
|
14
15
|
'@atlaskit/design-system/no-css-tagged-template-expression': string;
|
|
15
16
|
'@atlaskit/design-system/no-keyframes-tagged-template-expression': string;
|
|
16
|
-
'@atlaskit/design-system/no-styled-tagged-template-expression':
|
|
17
|
-
importSources: string[];
|
|
18
|
-
})[];
|
|
17
|
+
'@atlaskit/design-system/no-styled-tagged-template-expression': string;
|
|
19
18
|
'@compiled/no-suppress-xcss': string;
|
|
20
19
|
'@compiled/no-js-xcss': string;
|
|
21
20
|
'@atlaskit/design-system/no-empty-styled-expression': (string | {
|
|
@@ -40,14 +39,13 @@ export declare const configs: {
|
|
|
40
39
|
'@atlaskit/ui-styling-standard/no-classname-prop': string;
|
|
41
40
|
'@atlaskit/ui-styling-standard/no-container-queries': string;
|
|
42
41
|
'@atlaskit/ui-styling-standard/no-important-styles': string;
|
|
42
|
+
'@atlaskit/ui-styling-standard/no-nested-selectors': string;
|
|
43
43
|
'@atlaskit/design-system/consistent-css-prop-usage': (string | {
|
|
44
44
|
excludeReactComponents: boolean;
|
|
45
45
|
})[];
|
|
46
46
|
'@atlaskit/design-system/no-css-tagged-template-expression': string;
|
|
47
47
|
'@atlaskit/design-system/no-keyframes-tagged-template-expression': string;
|
|
48
|
-
'@atlaskit/design-system/no-styled-tagged-template-expression':
|
|
49
|
-
importSources: string[];
|
|
50
|
-
})[];
|
|
48
|
+
'@atlaskit/design-system/no-styled-tagged-template-expression': string;
|
|
51
49
|
'@compiled/no-suppress-xcss': string;
|
|
52
50
|
'@compiled/no-js-xcss': string;
|
|
53
51
|
'@atlaskit/design-system/no-empty-styled-expression': (string | {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
3
|
-
* @codegen <<SignedSource::
|
|
3
|
+
* @codegen <<SignedSource::7d08e77b09892b3650a472341ec77df3>>
|
|
4
4
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
|
|
5
5
|
*/
|
|
6
6
|
declare const _default: {
|
|
@@ -11,14 +11,13 @@ declare const _default: {
|
|
|
11
11
|
'@atlaskit/ui-styling-standard/no-classname-prop': string;
|
|
12
12
|
'@atlaskit/ui-styling-standard/no-container-queries': string;
|
|
13
13
|
'@atlaskit/ui-styling-standard/no-important-styles': string;
|
|
14
|
+
'@atlaskit/ui-styling-standard/no-nested-selectors': string;
|
|
14
15
|
'@atlaskit/design-system/consistent-css-prop-usage': (string | {
|
|
15
16
|
excludeReactComponents: boolean;
|
|
16
17
|
})[];
|
|
17
18
|
'@atlaskit/design-system/no-css-tagged-template-expression': string;
|
|
18
19
|
'@atlaskit/design-system/no-keyframes-tagged-template-expression': string;
|
|
19
|
-
'@atlaskit/design-system/no-styled-tagged-template-expression':
|
|
20
|
-
importSources: string[];
|
|
21
|
-
})[];
|
|
20
|
+
'@atlaskit/design-system/no-styled-tagged-template-expression': string;
|
|
22
21
|
'@compiled/no-suppress-xcss': string;
|
|
23
22
|
'@compiled/no-js-xcss': string;
|
|
24
23
|
'@atlaskit/design-system/no-empty-styled-expression': (string | {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
3
|
-
* @codegen <<SignedSource::
|
|
3
|
+
* @codegen <<SignedSource::7d08e77b09892b3650a472341ec77df3>>
|
|
4
4
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
|
|
5
5
|
*/
|
|
6
6
|
declare const _default: {
|
|
@@ -11,14 +11,13 @@ declare const _default: {
|
|
|
11
11
|
'@atlaskit/ui-styling-standard/no-classname-prop': string;
|
|
12
12
|
'@atlaskit/ui-styling-standard/no-container-queries': string;
|
|
13
13
|
'@atlaskit/ui-styling-standard/no-important-styles': string;
|
|
14
|
+
'@atlaskit/ui-styling-standard/no-nested-selectors': string;
|
|
14
15
|
'@atlaskit/design-system/consistent-css-prop-usage': (string | {
|
|
15
16
|
excludeReactComponents: boolean;
|
|
16
17
|
})[];
|
|
17
18
|
'@atlaskit/design-system/no-css-tagged-template-expression': string;
|
|
18
19
|
'@atlaskit/design-system/no-keyframes-tagged-template-expression': string;
|
|
19
|
-
'@atlaskit/design-system/no-styled-tagged-template-expression':
|
|
20
|
-
importSources: string[];
|
|
21
|
-
})[];
|
|
20
|
+
'@atlaskit/design-system/no-styled-tagged-template-expression': string;
|
|
22
21
|
'@compiled/no-suppress-xcss': string;
|
|
23
22
|
'@compiled/no-js-xcss': string;
|
|
24
23
|
'@atlaskit/design-system/no-empty-styled-expression': (string | {
|
|
@@ -4,5 +4,6 @@ declare const _default: {
|
|
|
4
4
|
'no-classname-prop': import("eslint").Rule.RuleModule;
|
|
5
5
|
'no-container-queries': import("eslint").Rule.RuleModule;
|
|
6
6
|
'no-important-styles': import("eslint").Rule.RuleModule;
|
|
7
|
+
'no-nested-selectors': import("eslint").Rule.RuleModule;
|
|
7
8
|
};
|
|
8
9
|
export default _default;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/eslint-plugin-ui-styling-standard",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
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",
|
|
@@ -36,6 +36,7 @@
|
|
|
36
36
|
".": "./src/index.tsx"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
+
"@atlaskit/eslint-utils": "^1.0.0",
|
|
39
40
|
"@babel/runtime": "^7.0.0",
|
|
40
41
|
"@typescript-eslint/utils": "^5.48.1",
|
|
41
42
|
"eslint-codemod-utils": "^1.8.6",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
3
|
-
* @codegen <<SignedSource::
|
|
3
|
+
* @codegen <<SignedSource::7d08e77b09892b3650a472341ec77df3>>
|
|
4
4
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
|
|
5
5
|
*/
|
|
6
6
|
export default {
|
|
@@ -15,24 +15,14 @@ export default {
|
|
|
15
15
|
'@atlaskit/ui-styling-standard/no-classname-prop': 'warn',
|
|
16
16
|
'@atlaskit/ui-styling-standard/no-container-queries': 'warn',
|
|
17
17
|
'@atlaskit/ui-styling-standard/no-important-styles': 'warn',
|
|
18
|
+
'@atlaskit/ui-styling-standard/no-nested-selectors': 'warn',
|
|
18
19
|
'@atlaskit/design-system/consistent-css-prop-usage': [
|
|
19
20
|
'warn',
|
|
20
21
|
{ excludeReactComponents: true },
|
|
21
22
|
],
|
|
22
23
|
'@atlaskit/design-system/no-css-tagged-template-expression': 'warn',
|
|
23
24
|
'@atlaskit/design-system/no-keyframes-tagged-template-expression': 'warn',
|
|
24
|
-
'@atlaskit/design-system/no-styled-tagged-template-expression':
|
|
25
|
-
'warn',
|
|
26
|
-
{
|
|
27
|
-
importSources: [
|
|
28
|
-
'@compiled/react',
|
|
29
|
-
'@atlaskit/css',
|
|
30
|
-
'@emotion/core',
|
|
31
|
-
'@emotion/react',
|
|
32
|
-
'@emotion/styled',
|
|
33
|
-
],
|
|
34
|
-
},
|
|
35
|
-
],
|
|
25
|
+
'@atlaskit/design-system/no-styled-tagged-template-expression': 'warn',
|
|
36
26
|
'@compiled/no-suppress-xcss': 'warn',
|
|
37
27
|
'@compiled/no-js-xcss': 'warn',
|
|
38
28
|
'@atlaskit/design-system/no-empty-styled-expression': [
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
3
|
-
* @codegen <<SignedSource::
|
|
3
|
+
* @codegen <<SignedSource::7d08e77b09892b3650a472341ec77df3>>
|
|
4
4
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
|
|
5
5
|
*/
|
|
6
6
|
export default {
|
|
@@ -15,24 +15,14 @@ export default {
|
|
|
15
15
|
'@atlaskit/ui-styling-standard/no-classname-prop': 'warn',
|
|
16
16
|
'@atlaskit/ui-styling-standard/no-container-queries': 'warn',
|
|
17
17
|
'@atlaskit/ui-styling-standard/no-important-styles': 'warn',
|
|
18
|
+
'@atlaskit/ui-styling-standard/no-nested-selectors': 'warn',
|
|
18
19
|
'@atlaskit/design-system/consistent-css-prop-usage': [
|
|
19
20
|
'warn',
|
|
20
21
|
{ excludeReactComponents: true },
|
|
21
22
|
],
|
|
22
23
|
'@atlaskit/design-system/no-css-tagged-template-expression': 'warn',
|
|
23
24
|
'@atlaskit/design-system/no-keyframes-tagged-template-expression': 'warn',
|
|
24
|
-
'@atlaskit/design-system/no-styled-tagged-template-expression':
|
|
25
|
-
'warn',
|
|
26
|
-
{
|
|
27
|
-
importSources: [
|
|
28
|
-
'@compiled/react',
|
|
29
|
-
'@atlaskit/css',
|
|
30
|
-
'@emotion/core',
|
|
31
|
-
'@emotion/react',
|
|
32
|
-
'@emotion/styled',
|
|
33
|
-
],
|
|
34
|
-
},
|
|
35
|
-
],
|
|
25
|
+
'@atlaskit/design-system/no-styled-tagged-template-expression': 'warn',
|
|
36
26
|
'@compiled/no-suppress-xcss': 'warn',
|
|
37
27
|
'@compiled/no-js-xcss': 'warn',
|
|
38
28
|
'@atlaskit/design-system/no-empty-styled-expression': [
|
|
@@ -8,7 +8,10 @@ import type {
|
|
|
8
8
|
ObjectExpression,
|
|
9
9
|
} from 'estree-jsx';
|
|
10
10
|
import { createLintRule } from '../utils/create-rule';
|
|
11
|
-
import {
|
|
11
|
+
import {
|
|
12
|
+
isStyledComponents,
|
|
13
|
+
isEmotion,
|
|
14
|
+
} from '@atlaskit/eslint-utils/is-supported-import';
|
|
12
15
|
import type { Rule, Scope, SourceCode } from 'eslint';
|
|
13
16
|
import ESTraverse from 'estraverse';
|
|
14
17
|
|
|
@@ -17,33 +17,6 @@ const importSources: readonly string[] = [
|
|
|
17
17
|
'styled-components',
|
|
18
18
|
];
|
|
19
19
|
|
|
20
|
-
/**
|
|
21
|
-
* Same as importSources, but excludes `styled-components` because the type-checking
|
|
22
|
-
* for `styled-components` does not support the `no-styled-tagged-template-expression`
|
|
23
|
-
* lint output for this:
|
|
24
|
-
*
|
|
25
|
-
* export const Container = styled(Section)`
|
|
26
|
-
* max-height: ${gridSize * 46}px;
|
|
27
|
-
* overflow: auto;
|
|
28
|
-
* `;
|
|
29
|
-
*
|
|
30
|
-
* export const ErrorStateContainer = styled(Container)`
|
|
31
|
-
* margin: ${
|
|
32
|
-
* (props: any) =>
|
|
33
|
-
* props.canManageAutomations // Use negative margin to reduce whitespace when the Footer component is shown
|
|
34
|
-
* ? `${gridSize * -4}px ${gridSize * 2}px`
|
|
35
|
-
* : `0 ${gridSize * 2}px`
|
|
36
|
-
* };
|
|
37
|
-
* `;
|
|
38
|
-
*/
|
|
39
|
-
const noStyledTaggedTemplateExpressionImportSources: readonly string[] = [
|
|
40
|
-
'@compiled/react',
|
|
41
|
-
'@atlaskit/css', // doesn't do anything because @atlaskit/css doesn't expose a styled API
|
|
42
|
-
'@emotion/core',
|
|
43
|
-
'@emotion/react',
|
|
44
|
-
'@emotion/styled',
|
|
45
|
-
];
|
|
46
|
-
|
|
47
20
|
export const externalRules: ExternalRuleMeta[] = [
|
|
48
21
|
{
|
|
49
22
|
name: '@atlaskit/design-system/consistent-css-prop-usage',
|
|
@@ -108,9 +81,6 @@ export const externalRules: ExternalRuleMeta[] = [
|
|
|
108
81
|
'https://atlassian.design/components/eslint-plugin-design-system/no-styled-tagged-template-expression/usage',
|
|
109
82
|
recommended: true,
|
|
110
83
|
severity: 'warn',
|
|
111
|
-
pluginConfig: {
|
|
112
|
-
importSources: noStyledTaggedTemplateExpressionImportSources,
|
|
113
|
-
},
|
|
114
84
|
},
|
|
115
85
|
},
|
|
116
86
|
{
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
3
|
-
* @codegen <<SignedSource::
|
|
3
|
+
* @codegen <<SignedSource::c50c5112f3633542ef17c291cd9d88a8>>
|
|
4
4
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
|
|
5
5
|
*/
|
|
6
6
|
import convertPropsSyntax from './convert-props-syntax';
|
|
@@ -8,6 +8,7 @@ import localCxXcss from './local-cx-xcss';
|
|
|
8
8
|
import noClassnameProp from './no-classname-prop';
|
|
9
9
|
import noContainerQueries from './no-container-queries';
|
|
10
10
|
import noImportantStyles from './no-important-styles';
|
|
11
|
+
import noNestedSelectors from './no-nested-selectors';
|
|
11
12
|
|
|
12
13
|
export default {
|
|
13
14
|
'convert-props-syntax': convertPropsSyntax,
|
|
@@ -15,4 +16,5 @@ export default {
|
|
|
15
16
|
'no-classname-prop': noClassnameProp,
|
|
16
17
|
'no-container-queries': noContainerQueries,
|
|
17
18
|
'no-important-styles': noImportantStyles,
|
|
19
|
+
'no-nested-selectors': noNestedSelectors,
|
|
18
20
|
};
|
|
@@ -2,7 +2,10 @@ import type { Rule } from 'eslint';
|
|
|
2
2
|
import type { JSXAttribute } from 'estree-jsx';
|
|
3
3
|
|
|
4
4
|
import { createLintRule } from '../utils/create-rule';
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
CSS_IN_JS_IMPORTS,
|
|
7
|
+
isCxFunction,
|
|
8
|
+
} from '@atlaskit/eslint-utils/is-supported-import';
|
|
6
9
|
|
|
7
10
|
const IMPORT_SOURCES = [
|
|
8
11
|
CSS_IN_JS_IMPORTS.compiled,
|