@atlaskit/eslint-plugin-ui-styling-standard 0.7.2 → 0.8.1

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.
Files changed (51) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/README.md +2 -1
  3. package/constellation/index/overview.mdx +2 -1
  4. package/constellation/no-nested-selectors/usage.mdx +60 -0
  5. package/dist/cjs/presets/all.codegen.js +3 -4
  6. package/dist/cjs/presets/recommended.codegen.js +3 -4
  7. package/dist/cjs/rules/convert-props-syntax/index.js +5 -0
  8. package/dist/cjs/rules/external-rules.js +1 -27
  9. package/dist/cjs/rules/index.codegen.js +4 -2
  10. package/dist/cjs/rules/no-nested-selectors/index.js +82 -0
  11. package/dist/cjs/rules/utils/create-rule.js +4 -29
  12. package/dist/es2019/presets/all.codegen.js +3 -4
  13. package/dist/es2019/presets/recommended.codegen.js +3 -4
  14. package/dist/es2019/rules/convert-props-syntax/index.js +5 -0
  15. package/dist/es2019/rules/external-rules.js +1 -27
  16. package/dist/es2019/rules/index.codegen.js +4 -2
  17. package/dist/es2019/rules/no-nested-selectors/index.js +71 -0
  18. package/dist/es2019/rules/utils/create-rule.js +2 -23
  19. package/dist/esm/presets/all.codegen.js +3 -4
  20. package/dist/esm/presets/recommended.codegen.js +3 -4
  21. package/dist/esm/rules/convert-props-syntax/index.js +5 -0
  22. package/dist/esm/rules/external-rules.js +1 -27
  23. package/dist/esm/rules/index.codegen.js +4 -2
  24. package/dist/esm/rules/no-nested-selectors/index.js +76 -0
  25. package/dist/esm/rules/utils/create-rule.js +2 -25
  26. package/dist/types/index.codegen.d.ts +4 -6
  27. package/dist/types/presets/all.codegen.d.ts +3 -4
  28. package/dist/types/presets/recommended.codegen.d.ts +3 -4
  29. package/dist/types/rules/external-rules.d.ts +1 -1
  30. package/dist/types/rules/index.codegen.d.ts +1 -0
  31. package/dist/types/rules/no-nested-selectors/index.d.ts +2 -0
  32. package/dist/types/rules/utils/create-rule.d.ts +1 -58
  33. package/dist/types-ts4.5/index.codegen.d.ts +4 -6
  34. package/dist/types-ts4.5/presets/all.codegen.d.ts +3 -4
  35. package/dist/types-ts4.5/presets/recommended.codegen.d.ts +3 -4
  36. package/dist/types-ts4.5/rules/external-rules.d.ts +1 -1
  37. package/dist/types-ts4.5/rules/index.codegen.d.ts +1 -0
  38. package/dist/types-ts4.5/rules/no-nested-selectors/index.d.ts +2 -0
  39. package/dist/types-ts4.5/rules/utils/create-rule.d.ts +1 -58
  40. package/package.json +3 -3
  41. package/scripts/codegen.tsx +4 -1
  42. package/src/presets/all.codegen.tsx +3 -13
  43. package/src/presets/recommended.codegen.tsx +3 -13
  44. package/src/rules/convert-props-syntax/__tests__/rule.test.tsx +52 -0
  45. package/src/rules/convert-props-syntax/index.tsx +10 -0
  46. package/src/rules/external-rules.tsx +2 -31
  47. package/src/rules/index.codegen.tsx +3 -1
  48. package/src/rules/no-nested-selectors/README.md +58 -0
  49. package/src/rules/no-nested-selectors/__tests__/rule.test.tsx +236 -0
  50. package/src/rules/no-nested-selectors/index.tsx +115 -0
  51. package/src/rules/utils/create-rule.tsx +5 -69
@@ -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::2e134e292f949b29bfd0b29d128e684a>>
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': ['warn', {
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', {
@@ -376,6 +376,11 @@ export var rule = createLintRule({
376
376
  return {
377
377
  'CallExpression[callee.type="MemberExpression"]': function CallExpressionCalleeTypeMemberExpression(node) {
378
378
  var references = context.getScope().references;
379
+
380
+ // Rule should ignore .attrs() calls
381
+ if (node.callee.type === 'MemberExpression' && node.callee.property.type === 'Identifier' && node.callee.property.name === 'attrs') {
382
+ return;
383
+ }
379
384
  var callee = node.callee.type === 'MemberExpression' ? node.callee.object : node.callee;
380
385
  if (!isStyledComponents(callee, references) && !isEmotion(callee, references)) {
381
386
  return;
@@ -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::3504ce124f49b7eca8abafb5a0bd6884>>
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
  };
@@ -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;
@@ -1,35 +1,12 @@
1
- import { ESLintUtils } from '@typescript-eslint/utils';
2
- // eslint-disable-next-line import/no-extraneous-dependencies
1
+ import { getCreateLintRule, getPathSafeName } from '@atlaskit/eslint-utils/create-rule';
3
2
 
4
- /**
5
- * We are moving to our own small abstraction to create a lint rule that we have the power
6
- * to change and mold to our own needs.
7
- *
8
- * @see createLintRule
9
- *
10
- * @private
11
- * @deprecated
12
- */
13
- export var createRule = ESLintUtils.RuleCreator(function (name) {
14
- return getRuleUrl(name);
15
- });
16
3
  /**
17
4
  * Tiny wrapped over the ESLint rule module type that ensures
18
5
  * there is a docs link to our ESLint plugin documentation page,
19
6
  * as well as improving type support.
20
7
  */
21
- export var createLintRule = function createLintRule(rule) {
22
- rule.meta.docs.url = getRuleUrl(rule.meta.name);
23
- return rule;
24
- };
8
+ export var createLintRule = getCreateLintRule(getRuleUrl);
25
9
  export function getRuleUrl(ruleName) {
26
10
  var name = getPathSafeName(ruleName);
27
11
  return "https://atlassian.design/components/eslint-plugin-ui-styling-standard/".concat(name, "/usage");
28
- }
29
-
30
- /**
31
- * If it's a nested rule, ensure the url is clean and safe for urls, file paths, etc.
32
- */
33
- export function getPathSafeName(ruleName) {
34
- return ruleName.replace('/', '-');
35
12
  }
@@ -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': (string | {
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': (string | {
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::2e134e292f949b29bfd0b29d128e684a>>
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': (string | {
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::2e134e292f949b29bfd0b29d128e684a>>
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': (string | {
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,4 +1,4 @@
1
- import { type LintRuleMeta } from './utils/create-rule';
1
+ import type { LintRuleMeta } from '@atlaskit/eslint-utils/create-rule';
2
2
  /** External rules must be scoped, have a display name, and external urls. */
3
3
  export type ExternalRuleMeta = LintRuleMeta & {
4
4
  isExternal: true;
@@ -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;
@@ -0,0 +1,2 @@
1
+ export declare const rule: import("eslint").Rule.RuleModule;
2
+ export default rule;
@@ -1,64 +1,7 @@
1
- import { ESLintUtils } from '@typescript-eslint/utils';
2
- import type { Rule } from 'eslint';
3
- /**
4
- * We are moving to our own small abstraction to create a lint rule that we have the power
5
- * to change and mold to our own needs.
6
- *
7
- * @see createLintRule
8
- *
9
- * @private
10
- * @deprecated
11
- */
12
- export declare const createRule: <TOptions extends readonly unknown[], TMessageIds extends string, TRuleListener extends import("@typescript-eslint/utils/dist/ts-eslint").RuleListener = import("@typescript-eslint/utils/dist/ts-eslint").RuleListener>({ name, meta, ...rule }: Readonly<ESLintUtils.RuleWithMetaAndName<TOptions, TMessageIds, TRuleListener>>) => import("@typescript-eslint/utils/dist/ts-eslint").RuleModule<TMessageIds, TOptions, TRuleListener>;
13
- export interface LintRule extends Omit<Rule.RuleModule, 'meta'> {
14
- /**
15
- * Including this for backwards compat moving from the typescript-eslint util.
16
- */
17
- name?: never;
18
- meta: LintRuleMeta;
19
- }
20
- export interface LintRuleMeta extends Omit<Rule.RuleMetaData, 'docs'> {
21
- /**
22
- * Name of the rule.
23
- * Must match the folder it is in exactly else build will throw.
24
- * Add an exception in codegen.tsx for nested rules.
25
- */
26
- name: string;
27
- docs: {
28
- /**
29
- * Short description of what this rule does.
30
- */
31
- description: string;
32
- /**
33
- * Specifies the URL at which the full documentation can be accessed.
34
- */
35
- url?: string | undefined;
36
- /**
37
- * If this rule should be in the recommended preset or not.
38
- * Set to `false` to exclude it from the recommended preset.
39
- */
40
- recommended: boolean;
41
- /**
42
- * The severity level to be applied to this rule.
43
- * When setting to `"error"` it will mean releasing a breaking change.
44
- */
45
- severity: 'error' | 'warn';
46
- /**
47
- * This is configuration passed into the plugin to configure the rule.
48
- *
49
- * Eg. `{ excludeReactComponents: true }` would be passed into the plugin config
50
- */
51
- pluginConfig?: Record<string, any>;
52
- };
53
- }
54
1
  /**
55
2
  * Tiny wrapped over the ESLint rule module type that ensures
56
3
  * there is a docs link to our ESLint plugin documentation page,
57
4
  * as well as improving type support.
58
5
  */
59
- export declare const createLintRule: (rule: LintRule) => Rule.RuleModule;
6
+ export declare const createLintRule: (rule: import("@atlaskit/eslint-utils/create-rule").LintRule) => import("eslint").Rule.RuleModule;
60
7
  export declare function getRuleUrl(ruleName: string): string;
61
- /**
62
- * If it's a nested rule, ensure the url is clean and safe for urls, file paths, etc.
63
- */
64
- export declare function getPathSafeName(ruleName: string): string;
@@ -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': (string | {
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': (string | {
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::2e134e292f949b29bfd0b29d128e684a>>
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': (string | {
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::2e134e292f949b29bfd0b29d128e684a>>
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': (string | {
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,4 +1,4 @@
1
- import { type LintRuleMeta } from './utils/create-rule';
1
+ import type { LintRuleMeta } from '@atlaskit/eslint-utils/create-rule';
2
2
  /** External rules must be scoped, have a display name, and external urls. */
3
3
  export type ExternalRuleMeta = LintRuleMeta & {
4
4
  isExternal: true;
@@ -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;
@@ -0,0 +1,2 @@
1
+ export declare const rule: import("eslint").Rule.RuleModule;
2
+ export default rule;
@@ -1,64 +1,7 @@
1
- import { ESLintUtils } from '@typescript-eslint/utils';
2
- import type { Rule } from 'eslint';
3
- /**
4
- * We are moving to our own small abstraction to create a lint rule that we have the power
5
- * to change and mold to our own needs.
6
- *
7
- * @see createLintRule
8
- *
9
- * @private
10
- * @deprecated
11
- */
12
- export declare const createRule: <TOptions extends readonly unknown[], TMessageIds extends string, TRuleListener extends import("@typescript-eslint/utils/dist/ts-eslint").RuleListener = import("@typescript-eslint/utils/dist/ts-eslint").RuleListener>({ name, meta, ...rule }: Readonly<ESLintUtils.RuleWithMetaAndName<TOptions, TMessageIds, TRuleListener>>) => import("@typescript-eslint/utils/dist/ts-eslint").RuleModule<TMessageIds, TOptions, TRuleListener>;
13
- export interface LintRule extends Omit<Rule.RuleModule, 'meta'> {
14
- /**
15
- * Including this for backwards compat moving from the typescript-eslint util.
16
- */
17
- name?: never;
18
- meta: LintRuleMeta;
19
- }
20
- export interface LintRuleMeta extends Omit<Rule.RuleMetaData, 'docs'> {
21
- /**
22
- * Name of the rule.
23
- * Must match the folder it is in exactly else build will throw.
24
- * Add an exception in codegen.tsx for nested rules.
25
- */
26
- name: string;
27
- docs: {
28
- /**
29
- * Short description of what this rule does.
30
- */
31
- description: string;
32
- /**
33
- * Specifies the URL at which the full documentation can be accessed.
34
- */
35
- url?: string | undefined;
36
- /**
37
- * If this rule should be in the recommended preset or not.
38
- * Set to `false` to exclude it from the recommended preset.
39
- */
40
- recommended: boolean;
41
- /**
42
- * The severity level to be applied to this rule.
43
- * When setting to `"error"` it will mean releasing a breaking change.
44
- */
45
- severity: 'error' | 'warn';
46
- /**
47
- * This is configuration passed into the plugin to configure the rule.
48
- *
49
- * Eg. `{ excludeReactComponents: true }` would be passed into the plugin config
50
- */
51
- pluginConfig?: Record<string, any>;
52
- };
53
- }
54
1
  /**
55
2
  * Tiny wrapped over the ESLint rule module type that ensures
56
3
  * there is a docs link to our ESLint plugin documentation page,
57
4
  * as well as improving type support.
58
5
  */
59
- export declare const createLintRule: (rule: LintRule) => Rule.RuleModule;
6
+ export declare const createLintRule: (rule: import("@atlaskit/eslint-utils/create-rule").LintRule) => import("eslint").Rule.RuleModule;
60
7
  export declare function getRuleUrl(ruleName: string): string;
61
- /**
62
- * If it's a nested rule, ensure the url is clean and safe for urls, file paths, etc.
63
- */
64
- export declare function getPathSafeName(ruleName: string): string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/eslint-plugin-ui-styling-standard",
3
- "version": "0.7.2",
3
+ "version": "0.8.1",
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,7 +36,7 @@
36
36
  ".": "./src/index.tsx"
37
37
  },
38
38
  "dependencies": {
39
- "@atlaskit/eslint-utils": "^1.0.0",
39
+ "@atlaskit/eslint-utils": "^1.1.0",
40
40
  "@babel/runtime": "^7.0.0",
41
41
  "@typescript-eslint/utils": "^5.48.1",
42
42
  "eslint-codemod-utils": "^1.8.6",
@@ -45,7 +45,7 @@
45
45
  },
46
46
  "devDependencies": {
47
47
  "@atlaskit/ds-lib": "^2.2.0",
48
- "@atlaskit/eslint-plugin-design-system": "^9.2.0",
48
+ "@atlaskit/eslint-plugin-design-system": "^9.3.0",
49
49
  "@atlassian/atlassian-frontend-prettier-config-1.0.1": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.1",
50
50
  "@atlassian/codegen": "*",
51
51
  "@compiled/eslint-plugin": "^0.13.6",
@@ -8,7 +8,10 @@ import { format, resolveConfig } from 'prettier';
8
8
 
9
9
  import { createSignedArtifact } from '@atlassian/codegen';
10
10
 
11
- import { type LintRule, getPathSafeName } from '../src/rules/utils/create-rule';
11
+ import {
12
+ type LintRule,
13
+ getPathSafeName,
14
+ } from '@atlaskit/eslint-utils/create-rule';
12
15
  import {
13
16
  externalRules,
14
17
  type ExternalRuleMeta,
@@ -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::2e134e292f949b29bfd0b29d128e684a>>
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': [