@atlaskit/eslint-plugin-ui-styling-standard 0.15.1 → 0.16.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/constellation/index/migration-guide.mdx +309 -0
- package/constellation/index/overview.mdx +4 -0
- package/constellation/index/props.mdx +9 -5
- package/dist/cjs/rules/no-nested-selectors/index.js +68 -49
- package/dist/es2019/rules/no-nested-selectors/index.js +63 -45
- package/dist/esm/rules/no-nested-selectors/index.js +64 -49
- package/dist/types/rules/no-unsafe-selectors/constants.d.ts +1 -4
- package/index.js +9 -9
- package/package.json +3 -3
- package/scripts/codegen.tsx +223 -284
- package/src/rules/__tests__/utils/_tester.tsx +24 -24
- package/src/rules/atlaskit-theme/README.md +21 -19
- package/src/rules/atlaskit-theme/__tests__/test.ts +53 -53
- package/src/rules/atlaskit-theme/index.ts +107 -115
- package/src/rules/convert-props-syntax/README.md +32 -22
- package/src/rules/convert-props-syntax/__tests__/invalid.test.tsx +46 -46
- package/src/rules/convert-props-syntax/__tests__/rule.test.tsx +175 -175
- package/src/rules/convert-props-syntax/__tests__/type-annotations.test.tsx +52 -52
- package/src/rules/convert-props-syntax/__tests__/unusual-properties.test.tsx +33 -33
- package/src/rules/convert-props-syntax/index.tsx +356 -386
- package/src/rules/enforce-style-prop/README.md +21 -18
- package/src/rules/enforce-style-prop/__tests__/rule.test.tsx +90 -96
- package/src/rules/enforce-style-prop/index.tsx +144 -160
- package/src/rules/external-rules.tsx +163 -164
- package/src/rules/local-cx-xcss/README.md +10 -6
- package/src/rules/local-cx-xcss/__tests__/rule.test.tsx +26 -26
- package/src/rules/local-cx-xcss/index.tsx +46 -56
- package/src/rules/no-array-arguments/README.md +2 -1
- package/src/rules/no-array-arguments/__tests__/rule.test.tsx +37 -46
- package/src/rules/no-array-arguments/index.tsx +68 -69
- package/src/rules/no-classname-prop/README.md +7 -4
- package/src/rules/no-classname-prop/__tests__/rule.test.tsx +22 -22
- package/src/rules/no-classname-prop/index.tsx +25 -25
- package/src/rules/no-container-queries/README.md +11 -9
- package/src/rules/no-container-queries/__tests__/rule.test.tsx +47 -50
- package/src/rules/no-container-queries/index.tsx +75 -81
- package/src/rules/no-dynamic-styles/README.md +16 -19
- package/src/rules/no-dynamic-styles/__tests__/rule.test.tsx +58 -67
- package/src/rules/no-dynamic-styles/index.tsx +45 -48
- package/src/rules/no-exported-styles/README.md +17 -12
- package/src/rules/no-exported-styles/__tests__/rule.test.tsx +102 -111
- package/src/rules/no-exported-styles/index.tsx +36 -36
- package/src/rules/no-global-styles/README.md +15 -14
- package/src/rules/no-global-styles/__tests__/no-css-modules.test.tsx +28 -28
- package/src/rules/no-global-styles/__tests__/no-global-styles.test.tsx +37 -37
- package/src/rules/no-global-styles/index.tsx +59 -62
- package/src/rules/no-important-styles/README.md +5 -3
- package/src/rules/no-important-styles/__tests__/rule.test.tsx +66 -66
- package/src/rules/no-important-styles/index.tsx +49 -49
- package/src/rules/no-imported-style-values/README.md +23 -15
- package/src/rules/no-imported-style-values/__tests__/rule.test.tsx +123 -123
- package/src/rules/no-imported-style-values/index.tsx +116 -120
- package/src/rules/no-nested-selectors/README.md +15 -13
- package/src/rules/no-nested-selectors/__tests__/rule.test.tsx +186 -149
- package/src/rules/no-nested-selectors/index.tsx +92 -105
- package/src/rules/no-styled/README.md +14 -9
- package/src/rules/no-styled/__tests__/rule.test.tsx +31 -31
- package/src/rules/no-styled/index.tsx +34 -41
- package/src/rules/no-unsafe-selectors/README.md +103 -93
- package/src/rules/no-unsafe-selectors/__tests__/no-grouped-at-rules.test.tsx +21 -24
- package/src/rules/no-unsafe-selectors/__tests__/no-increased-specificity.test.tsx +44 -44
- package/src/rules/no-unsafe-selectors/__tests__/no-keyframes-at-rules.test.tsx +21 -21
- package/src/rules/no-unsafe-selectors/__tests__/no-legacy-pseudo-element-syntax.test.tsx +57 -57
- package/src/rules/no-unsafe-selectors/__tests__/no-restricted-at-rules.test.tsx +58 -58
- package/src/rules/no-unsafe-selectors/__tests__/no-restricted-pseudos.test.tsx +85 -85
- package/src/rules/no-unsafe-selectors/__tests__/no-selectors-object.test.tsx +12 -12
- package/src/rules/no-unsafe-selectors/__tests__/no-unparsable-selectors.test.tsx +23 -23
- package/src/rules/no-unsafe-selectors/__tests__/rule.test.tsx +114 -114
- package/src/rules/no-unsafe-selectors/constants.tsx +69 -77
- package/src/rules/no-unsafe-selectors/source-position-utils.tsx +38 -38
- package/src/rules/no-unsafe-selectors/walk-css-map.tsx +178 -184
- package/src/rules/no-unsafe-values/README.md +34 -40
- package/src/rules/no-unsafe-values/__tests__/no-array-values.test.tsx +13 -13
- package/src/rules/no-unsafe-values/__tests__/no-conditional-values.test.tsx +18 -18
- package/src/rules/no-unsafe-values/__tests__/no-dynamic-keys.test.tsx +104 -104
- package/src/rules/no-unsafe-values/__tests__/no-function-calls.test.tsx +128 -128
- package/src/rules/no-unsafe-values/__tests__/no-identifier-arguments.test.tsx +23 -23
- package/src/rules/no-unsafe-values/__tests__/no-object-access.test.tsx +38 -38
- package/src/rules/no-unsafe-values/__tests__/no-object-references.test.tsx +18 -18
- package/src/rules/no-unsafe-values/__tests__/no-spread-elements.test.tsx +18 -18
- package/src/rules/no-unsafe-values/__tests__/no-unsafe-values.test.tsx +28 -28
- package/src/rules/no-unsafe-values/__tests__/no-variables.test.tsx +47 -47
- package/src/rules/no-unsafe-values/index.tsx +76 -78
- package/src/rules/no-unsafe-values/messages.tsx +12 -12
- package/src/rules/no-unsafe-values/utils.tsx +370 -382
- package/src/rules/use-compiled/README.md +11 -8
- package/src/rules/use-compiled/__tests__/can-auto-fix.test.tsx +32 -32
- package/src/rules/use-compiled/__tests__/css.test.tsx +53 -53
- package/src/rules/use-compiled/__tests__/imports.test.tsx +90 -95
- package/src/rules/use-compiled/__tests__/keyframes.test.tsx +47 -47
- package/src/rules/use-compiled/__tests__/pragma.test.tsx +64 -64
- package/src/rules/use-compiled/__tests__/styled.test.tsx +53 -53
- package/src/rules/use-compiled/__tests__/use-compiled.test.tsx +10 -10
- package/src/rules/use-compiled/index.tsx +203 -226
- package/src/rules/use-compiled/is-safe.tsx +113 -117
- package/src/rules/use-compiled/utils.tsx +14 -18
- package/src/rules/utils/create-rule-with-typed-config.tsx +62 -63
- package/src/rules/utils/create-rule.tsx +3 -6
|
@@ -5,159 +5,155 @@ import type * as ESTree from 'eslint-codemod-utils';
|
|
|
5
5
|
import { findVariable } from '@atlaskit/eslint-utils/find-variable';
|
|
6
6
|
|
|
7
7
|
export function isSafeUsage({
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
context,
|
|
9
|
+
specifier,
|
|
10
|
+
supportedImports,
|
|
11
11
|
}: {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
context: Rule.RuleContext;
|
|
13
|
+
specifier: ESTree.ImportSpecifier;
|
|
14
|
+
supportedImports: Set<string>;
|
|
15
15
|
}): boolean {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
16
|
+
const importName = specifier.imported.name;
|
|
17
|
+
|
|
18
|
+
if (!supportedImports.has(importName)) {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
if (importName === 'css') {
|
|
23
|
+
const css = findVariable({
|
|
24
|
+
identifier: specifier.local,
|
|
25
|
+
sourceCode: context.getSourceCode(),
|
|
26
|
+
});
|
|
27
|
+
return css !== null && isSafeCss(css);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if (importName === 'keyframes') {
|
|
31
|
+
const keyframes = findVariable({
|
|
32
|
+
identifier: specifier.local,
|
|
33
|
+
sourceCode: context.getSourceCode(),
|
|
34
|
+
});
|
|
35
|
+
return keyframes !== null && isSafeKeyframes(keyframes);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return true;
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
export function isSafeKeyframes(keyframes: Scope.Variable): boolean {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
42
|
+
return keyframes.references.every((ref) => {
|
|
43
|
+
const callExpression = closestOfType(ref.identifier, 'CallExpression');
|
|
44
|
+
if (!callExpression) {
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if (callExpression.callee !== ref.identifier) {
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (callExpression.arguments.length !== 1) {
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const argument = callExpression.arguments[0];
|
|
57
|
+
if (argument.type !== 'ObjectExpression') {
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return argument.properties.every((property) =>
|
|
62
|
+
isSafeProperty(property, isSafeKeyframePropertyValue),
|
|
63
|
+
);
|
|
64
|
+
});
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
function isSafeKeyframePropertyValue(value: ESTree.Property['value']): boolean {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
68
|
+
if (value.type !== 'ObjectExpression') {
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
return isSafeStyleObject(value);
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
export function isSafeCss(css: Scope.Variable): boolean {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
75
|
+
return css.references.every((ref) => {
|
|
76
|
+
const callExpression = closestOfType(ref.identifier, 'CallExpression');
|
|
77
|
+
if (!callExpression) {
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (callExpression.callee !== ref.identifier) {
|
|
82
|
+
return false;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return callExpression.arguments.every(isSafeStyleArgument);
|
|
86
|
+
});
|
|
87
87
|
}
|
|
88
88
|
|
|
89
89
|
export function isSafeStyled(styled: Scope.Variable): boolean {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
90
|
+
return styled.references.every((ref) => {
|
|
91
|
+
const callExpression = closestOfType(ref.identifier, 'CallExpression');
|
|
92
|
+
if (!callExpression) {
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* If it's not in the form `styled.tagName()`
|
|
98
|
+
* then we consider it unsafe to auto-fix.
|
|
99
|
+
*/
|
|
100
|
+
if (
|
|
101
|
+
callExpression.callee.type !== 'MemberExpression' ||
|
|
102
|
+
callExpression.callee.object !== ref.identifier
|
|
103
|
+
) {
|
|
104
|
+
return false;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
return callExpression.arguments.every(isSafeStyleArgument);
|
|
108
|
+
});
|
|
109
109
|
}
|
|
110
110
|
|
|
111
111
|
/**
|
|
112
112
|
* Determines if a style argument is safe for auto-fix conversion.
|
|
113
113
|
*/
|
|
114
|
-
function isSafeStyleArgument(
|
|
115
|
-
|
|
116
|
-
)
|
|
117
|
-
|
|
118
|
-
return isSafeStyleObject(arg);
|
|
119
|
-
}
|
|
114
|
+
function isSafeStyleArgument(arg: ESTree.Expression | ESTree.SpreadElement): boolean {
|
|
115
|
+
if (arg.type === 'ObjectExpression') {
|
|
116
|
+
return isSafeStyleObject(arg);
|
|
117
|
+
}
|
|
120
118
|
|
|
121
|
-
|
|
119
|
+
return false;
|
|
122
120
|
}
|
|
123
121
|
|
|
124
122
|
function isSafeStyleObject(object: ESTree.ObjectExpression): boolean {
|
|
125
|
-
|
|
126
|
-
isSafeProperty(property, isSafeStyleValue),
|
|
127
|
-
);
|
|
123
|
+
return object.properties.every((property) => isSafeProperty(property, isSafeStyleValue));
|
|
128
124
|
}
|
|
129
125
|
|
|
130
126
|
function isSafeStyleValue(value: ESTree.Expression | ESTree.Pattern): boolean {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
127
|
+
if (value.type === 'Literal') {
|
|
128
|
+
return true;
|
|
129
|
+
}
|
|
134
130
|
|
|
135
|
-
|
|
131
|
+
return false;
|
|
136
132
|
}
|
|
137
133
|
|
|
138
134
|
function isSafeProperty(
|
|
139
|
-
|
|
140
|
-
|
|
135
|
+
property: ESTree.Property | ESTree.SpreadElement,
|
|
136
|
+
isSafePropertyValue: (value: ESTree.Property['value']) => boolean,
|
|
141
137
|
): boolean {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
138
|
+
if (property.type === 'SpreadElement') {
|
|
139
|
+
return false;
|
|
140
|
+
}
|
|
145
141
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
142
|
+
if (property.method || property.shorthand || property.kind !== 'init') {
|
|
143
|
+
return false;
|
|
144
|
+
}
|
|
149
145
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
146
|
+
if (!hasSafeKey(property)) {
|
|
147
|
+
return false;
|
|
148
|
+
}
|
|
153
149
|
|
|
154
|
-
|
|
150
|
+
return isSafePropertyValue(property.value);
|
|
155
151
|
}
|
|
156
152
|
|
|
157
153
|
function hasSafeKey(property: ESTree.Property): boolean {
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
154
|
+
if (property.computed) {
|
|
155
|
+
return property.key.type === 'Literal';
|
|
156
|
+
}
|
|
161
157
|
|
|
162
|
-
|
|
158
|
+
return true;
|
|
163
159
|
}
|
|
@@ -3,35 +3,31 @@ import type { Rule } from 'eslint';
|
|
|
3
3
|
import type * as ESTree from 'eslint-codemod-utils';
|
|
4
4
|
|
|
5
5
|
export function getFirstImportFromSource(
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
context: Rule.RuleContext,
|
|
7
|
+
source: string,
|
|
8
8
|
): ESTree.ImportDeclaration | undefined {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
return context
|
|
10
|
+
.getSourceCode()
|
|
11
|
+
.ast.body.filter(isImportDeclaration)
|
|
12
|
+
.find((node) => node.source.value === source);
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
function isImportDeclaration(
|
|
16
|
-
|
|
17
|
-
): node is ESTree.ImportDeclaration {
|
|
18
|
-
return node.type === 'ImportDeclaration';
|
|
15
|
+
function isImportDeclaration(node: ESTree.Node): node is ESTree.ImportDeclaration {
|
|
16
|
+
return node.type === 'ImportDeclaration';
|
|
19
17
|
}
|
|
20
18
|
|
|
21
|
-
export function isImportSpecifier(
|
|
22
|
-
|
|
23
|
-
): specifier is ESTree.ImportSpecifier {
|
|
24
|
-
return specifier.type === 'ImportSpecifier';
|
|
19
|
+
export function isImportSpecifier(specifier: ESTree.Node): specifier is ESTree.ImportSpecifier {
|
|
20
|
+
return specifier.type === 'ImportSpecifier';
|
|
25
21
|
}
|
|
26
22
|
|
|
27
23
|
export function isImportDefaultSpecifier(
|
|
28
|
-
|
|
24
|
+
specifier: ESTree.Node,
|
|
29
25
|
): specifier is ESTree.ImportDefaultSpecifier {
|
|
30
|
-
|
|
26
|
+
return specifier.type === 'ImportDefaultSpecifier';
|
|
31
27
|
}
|
|
32
28
|
|
|
33
29
|
export function isImportNamespaceSpecifier(
|
|
34
|
-
|
|
30
|
+
specifier: ESTree.Node,
|
|
35
31
|
): specifier is ESTree.ImportNamespaceSpecifier {
|
|
36
|
-
|
|
32
|
+
return specifier.type === 'ImportNamespaceSpecifier';
|
|
37
33
|
}
|
|
@@ -3,85 +3,84 @@ import type { Rule } from 'eslint';
|
|
|
3
3
|
import type { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
|
4
4
|
|
|
5
5
|
import type {
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
LintRule as BaseLintRule,
|
|
7
|
+
LintRuleMeta as BaseLintRuleMeta,
|
|
8
8
|
} from '@atlaskit/eslint-utils/create-rule';
|
|
9
9
|
|
|
10
10
|
import { getRuleUrl } from './create-rule';
|
|
11
11
|
|
|
12
12
|
export interface LintRule<Schema extends JSONSchema, Config>
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
extends Omit<BaseLintRule, 'meta' | 'create'> {
|
|
14
|
+
meta: LintRuleMeta<Schema>;
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
create(context: Rule.RuleContext, config: Config): Rule.RuleListener;
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
18
|
+
/**
|
|
19
|
+
* Unsure why the eslint typings include this when the docs
|
|
20
|
+
* say the schema should be in meta.
|
|
21
|
+
*/
|
|
22
|
+
schema?: never;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
export interface LintRuleMeta<Schema extends JSONSchema>
|
|
26
|
-
|
|
27
|
-
schema: Schema;
|
|
25
|
+
export interface LintRuleMeta<Schema extends JSONSchema> extends Omit<BaseLintRuleMeta, 'schema'> {
|
|
26
|
+
schema: Schema;
|
|
28
27
|
}
|
|
29
28
|
|
|
30
29
|
export const createLintRuleWithTypedConfig = <
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
Schema extends JSONSchema & { type: 'object' },
|
|
31
|
+
Config = FromSchema<Schema>,
|
|
33
32
|
>(
|
|
34
|
-
|
|
33
|
+
rule: LintRule<Schema, Config>,
|
|
35
34
|
) => {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
35
|
+
/**
|
|
36
|
+
* Gets the default config by running the same validator
|
|
37
|
+
* ESLint does against an empty config object with
|
|
38
|
+
* `useDefaults` option enabled.
|
|
39
|
+
*
|
|
40
|
+
* Any properties with a `default` property set in the schema
|
|
41
|
+
* will be populated with the specified default value.
|
|
42
|
+
*/
|
|
43
|
+
function getDefaultConfig(): Config {
|
|
44
|
+
const ajv = new Ajv({ useDefaults: true });
|
|
45
|
+
const validate = ajv.compile(rule.meta.schema);
|
|
47
46
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
47
|
+
const config = {};
|
|
48
|
+
/**
|
|
49
|
+
* The `validate()` function mutates the config object.
|
|
50
|
+
*/
|
|
51
|
+
validate(config);
|
|
53
52
|
|
|
54
|
-
|
|
55
|
-
|
|
53
|
+
return config as Config;
|
|
54
|
+
}
|
|
56
55
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
56
|
+
return {
|
|
57
|
+
...rule,
|
|
58
|
+
meta: {
|
|
59
|
+
...rule.meta,
|
|
60
|
+
docs: {
|
|
61
|
+
...rule.meta.docs,
|
|
62
|
+
url: getRuleUrl(rule.meta.name),
|
|
63
|
+
},
|
|
64
|
+
schema: [rule.meta.schema],
|
|
65
|
+
},
|
|
66
|
+
create(context) {
|
|
67
|
+
/**
|
|
68
|
+
* The config the user has passed.
|
|
69
|
+
*
|
|
70
|
+
* If they passed a config object, even if it is missing properties,
|
|
71
|
+
* ESLint will have added any default values defined using the
|
|
72
|
+
* `default` property in the schema.
|
|
73
|
+
*
|
|
74
|
+
* https://github.com/eslint/eslint/pull/11288
|
|
75
|
+
*/
|
|
76
|
+
const userConfig = context.options[0] as Config | undefined;
|
|
77
|
+
/**
|
|
78
|
+
* If the user passed no config object at all we need to obtain
|
|
79
|
+
* the default ourselves.
|
|
80
|
+
*/
|
|
81
|
+
const config = userConfig ?? getDefaultConfig();
|
|
83
82
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
83
|
+
return rule.create(context, config);
|
|
84
|
+
},
|
|
85
|
+
} as Rule.RuleModule;
|
|
87
86
|
};
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
getCreateLintRule,
|
|
3
|
-
getPathSafeName,
|
|
4
|
-
} from '@atlaskit/eslint-utils/create-rule';
|
|
1
|
+
import { getCreateLintRule, getPathSafeName } from '@atlaskit/eslint-utils/create-rule';
|
|
5
2
|
|
|
6
3
|
/**
|
|
7
4
|
* Tiny wrapped over the ESLint rule module type that ensures
|
|
@@ -11,6 +8,6 @@ import {
|
|
|
11
8
|
export const createLintRule = getCreateLintRule(getRuleUrl);
|
|
12
9
|
|
|
13
10
|
export function getRuleUrl(ruleName: string) {
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
const name = getPathSafeName(ruleName);
|
|
12
|
+
return `https://atlassian.design/components/eslint-plugin-ui-styling-standard/${name}/usage`;
|
|
16
13
|
}
|