@atlaskit/eslint-plugin-ui-styling-standard 0.18.0 → 0.18.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 (137) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/package.json +1 -1
  3. package/afm-cc/tsconfig.json +0 -28
  4. package/afm-jira/tsconfig.json +0 -27
  5. package/build/tsconfig.json +0 -18
  6. package/constellation/atlaskit-theme/usage.mdx +0 -132
  7. package/constellation/consistent-css-prop-usage/usage.mdx +0 -7
  8. package/constellation/convert-props-syntax/usage.mdx +0 -130
  9. package/constellation/enforce-style-prop/usage.mdx +0 -47
  10. package/constellation/index/migration-guide.mdx +0 -309
  11. package/constellation/index/overview.mdx +0 -250
  12. package/constellation/index/props.mdx +0 -30
  13. package/constellation/local-cx-xcss/usage.mdx +0 -53
  14. package/constellation/no-array-arguments/usage.mdx +0 -49
  15. package/constellation/no-classname-prop/usage.mdx +0 -49
  16. package/constellation/no-container-queries/usage.mdx +0 -101
  17. package/constellation/no-css-tagged-template-expression/usage.mdx +0 -8
  18. package/constellation/no-dynamic-styles/usage.mdx +0 -130
  19. package/constellation/no-empty-styled-expression/usage.mdx +0 -8
  20. package/constellation/no-exported-css/usage.mdx +0 -8
  21. package/constellation/no-exported-keyframes/usage.mdx +0 -8
  22. package/constellation/no-exported-styles/usage.mdx +0 -87
  23. package/constellation/no-global-styles/usage.mdx +0 -60
  24. package/constellation/no-important-styles/usage.mdx +0 -33
  25. package/constellation/no-imported-style-values/usage.mdx +0 -157
  26. package/constellation/no-invalid-css-map/usage.mdx +0 -8
  27. package/constellation/no-js-xcss/usage.mdx +0 -7
  28. package/constellation/no-keyframes-tagged-template-expression/usage.mdx +0 -8
  29. package/constellation/no-nested-selectors/usage.mdx +0 -95
  30. package/constellation/no-styled/usage.mdx +0 -92
  31. package/constellation/no-styled-tagged-template-expression/usage.mdx +0 -8
  32. package/constellation/no-suppress-xcss/usage.mdx +0 -28
  33. package/constellation/no-unsafe-selectors/usage.mdx +0 -370
  34. package/constellation/no-unsafe-values/usage.mdx +0 -318
  35. package/constellation/use-compiled/usage.mdx +0 -54
  36. package/index.js +0 -24
  37. package/scripts/codegen.tsx +0 -373
  38. package/src/index.codegen.tsx +0 -14
  39. package/src/index.tsx +0 -1
  40. package/src/presets/all.codegen.tsx +0 -79
  41. package/src/presets/recommended.codegen.tsx +0 -79
  42. package/src/rules/TEMPLATE.md +0 -29
  43. package/src/rules/__tests__/utils/_tester.tsx +0 -40
  44. package/src/rules/atlaskit-theme/README.md +0 -130
  45. package/src/rules/atlaskit-theme/__tests__/test.ts +0 -133
  46. package/src/rules/atlaskit-theme/index.ts +0 -134
  47. package/src/rules/convert-props-syntax/README.md +0 -128
  48. package/src/rules/convert-props-syntax/__tests__/invalid.test.tsx +0 -76
  49. package/src/rules/convert-props-syntax/__tests__/rule.test.tsx +0 -584
  50. package/src/rules/convert-props-syntax/__tests__/type-annotations.test.tsx +0 -140
  51. package/src/rules/convert-props-syntax/__tests__/unusual-properties.test.tsx +0 -69
  52. package/src/rules/convert-props-syntax/index.tsx +0 -414
  53. package/src/rules/enforce-style-prop/README.md +0 -45
  54. package/src/rules/enforce-style-prop/__tests__/rule.test.tsx +0 -243
  55. package/src/rules/enforce-style-prop/index.tsx +0 -172
  56. package/src/rules/external-rules.tsx +0 -177
  57. package/src/rules/index.codegen.tsx +0 -42
  58. package/src/rules/local-cx-xcss/README.md +0 -51
  59. package/src/rules/local-cx-xcss/__tests__/rule.test.tsx +0 -102
  60. package/src/rules/local-cx-xcss/index.tsx +0 -62
  61. package/src/rules/no-array-arguments/README.md +0 -47
  62. package/src/rules/no-array-arguments/__tests__/rule.test.tsx +0 -107
  63. package/src/rules/no-array-arguments/index.tsx +0 -86
  64. package/src/rules/no-classname-prop/README.md +0 -47
  65. package/src/rules/no-classname-prop/__tests__/rule.test.tsx +0 -39
  66. package/src/rules/no-classname-prop/index.tsx +0 -34
  67. package/src/rules/no-container-queries/README.md +0 -99
  68. package/src/rules/no-container-queries/__tests__/rule.test.tsx +0 -139
  69. package/src/rules/no-container-queries/index.tsx +0 -94
  70. package/src/rules/no-dynamic-styles/README.md +0 -128
  71. package/src/rules/no-dynamic-styles/__tests__/rule.test.tsx +0 -135
  72. package/src/rules/no-dynamic-styles/index.tsx +0 -60
  73. package/src/rules/no-exported-styles/README.md +0 -85
  74. package/src/rules/no-exported-styles/__tests__/rule.test.tsx +0 -216
  75. package/src/rules/no-exported-styles/index.tsx +0 -52
  76. package/src/rules/no-global-styles/README.md +0 -58
  77. package/src/rules/no-global-styles/__tests__/no-css-modules.test.tsx +0 -33
  78. package/src/rules/no-global-styles/__tests__/no-global-styles.test.tsx +0 -46
  79. package/src/rules/no-global-styles/index.tsx +0 -82
  80. package/src/rules/no-important-styles/README.md +0 -31
  81. package/src/rules/no-important-styles/__tests__/rule.test.tsx +0 -165
  82. package/src/rules/no-important-styles/index.tsx +0 -70
  83. package/src/rules/no-imported-style-values/README.md +0 -155
  84. package/src/rules/no-imported-style-values/__tests__/rule.test.tsx +0 -491
  85. package/src/rules/no-imported-style-values/index.tsx +0 -188
  86. package/src/rules/no-nested-selectors/README.md +0 -93
  87. package/src/rules/no-nested-selectors/__tests__/rule.test.tsx +0 -335
  88. package/src/rules/no-nested-selectors/index.tsx +0 -99
  89. package/src/rules/no-styled/README.md +0 -90
  90. package/src/rules/no-styled/__tests__/rule.test.tsx +0 -73
  91. package/src/rules/no-styled/index.tsx +0 -45
  92. package/src/rules/no-unsafe-selectors/README.md +0 -368
  93. package/src/rules/no-unsafe-selectors/__tests__/no-ambiguous-pseudos.test.tsx +0 -368
  94. package/src/rules/no-unsafe-selectors/__tests__/no-grouped-at-rules.test.tsx +0 -57
  95. package/src/rules/no-unsafe-selectors/__tests__/no-increased-specificity.test.tsx +0 -73
  96. package/src/rules/no-unsafe-selectors/__tests__/no-keyframes-at-rules.test.tsx +0 -40
  97. package/src/rules/no-unsafe-selectors/__tests__/no-legacy-pseudo-element-syntax.test.tsx +0 -101
  98. package/src/rules/no-unsafe-selectors/__tests__/no-restricted-at-rules.test.tsx +0 -131
  99. package/src/rules/no-unsafe-selectors/__tests__/no-restricted-pseudos.test.tsx +0 -132
  100. package/src/rules/no-unsafe-selectors/__tests__/no-selectors-object.test.tsx +0 -25
  101. package/src/rules/no-unsafe-selectors/__tests__/no-unparsable-selectors.test.tsx +0 -35
  102. package/src/rules/no-unsafe-selectors/__tests__/rule.test.tsx +0 -257
  103. package/src/rules/no-unsafe-selectors/constants.tsx +0 -91
  104. package/src/rules/no-unsafe-selectors/index.tsx +0 -198
  105. package/src/rules/no-unsafe-selectors/lint-selector.tsx +0 -155
  106. package/src/rules/no-unsafe-selectors/source-position-utils.tsx +0 -55
  107. package/src/rules/no-unsafe-selectors/walk-css-map.tsx +0 -226
  108. package/src/rules/no-unsafe-values/README.md +0 -316
  109. package/src/rules/no-unsafe-values/__tests__/no-array-values.test.tsx +0 -27
  110. package/src/rules/no-unsafe-values/__tests__/no-conditional-values.test.tsx +0 -37
  111. package/src/rules/no-unsafe-values/__tests__/no-dynamic-keys.test.tsx +0 -229
  112. package/src/rules/no-unsafe-values/__tests__/no-function-calls.test.tsx +0 -267
  113. package/src/rules/no-unsafe-values/__tests__/no-identifier-arguments.test.tsx +0 -52
  114. package/src/rules/no-unsafe-values/__tests__/no-object-access.test.tsx +0 -106
  115. package/src/rules/no-unsafe-values/__tests__/no-object-references.test.tsx +0 -44
  116. package/src/rules/no-unsafe-values/__tests__/no-spread-elements.test.tsx +0 -48
  117. package/src/rules/no-unsafe-values/__tests__/no-unsafe-values.test.tsx +0 -75
  118. package/src/rules/no-unsafe-values/__tests__/no-variables.test.tsx +0 -121
  119. package/src/rules/no-unsafe-values/index.tsx +0 -94
  120. package/src/rules/no-unsafe-values/messages.tsx +0 -86
  121. package/src/rules/no-unsafe-values/utils.tsx +0 -387
  122. package/src/rules/use-compiled/README.md +0 -52
  123. package/src/rules/use-compiled/__tests__/can-auto-fix.test.tsx +0 -73
  124. package/src/rules/use-compiled/__tests__/css.test.tsx +0 -126
  125. package/src/rules/use-compiled/__tests__/imports.test.tsx +0 -158
  126. package/src/rules/use-compiled/__tests__/keyframes.test.tsx +0 -140
  127. package/src/rules/use-compiled/__tests__/pragma.test.tsx +0 -108
  128. package/src/rules/use-compiled/__tests__/styled.test.tsx +0 -114
  129. package/src/rules/use-compiled/__tests__/use-compiled.test.tsx +0 -15
  130. package/src/rules/use-compiled/index.tsx +0 -252
  131. package/src/rules/use-compiled/is-safe.tsx +0 -159
  132. package/src/rules/use-compiled/utils.tsx +0 -33
  133. package/src/rules/utils/create-rule-with-typed-config.tsx +0 -86
  134. package/src/rules/utils/create-rule.tsx +0 -13
  135. package/tsconfig.app.json +0 -47
  136. package/tsconfig.dev.json +0 -45
  137. package/tsconfig.json +0 -25
@@ -1,252 +0,0 @@
1
- import type { Rule } from 'eslint';
2
- import { identifier, importDeclaration, importSpecifier, literal } from 'eslint-codemod-utils';
3
- import type * as ESTree from 'eslint-codemod-utils';
4
- import type { FromSchema, JSONSchema } from 'json-schema-to-ts';
5
-
6
- import { findVariable } from '@atlaskit/eslint-utils/find-variable';
7
-
8
- import { createLintRule } from '../utils/create-rule';
9
- import {
10
- getFirstImportFromSource,
11
- isImportDefaultSpecifier,
12
- isImportNamespaceSpecifier,
13
- isImportSpecifier,
14
- } from './utils';
15
- import { isSafeStyled, isSafeUsage } from './is-safe';
16
-
17
- const SUPPORTED_EMOTION_IMPORTS = new Set(['css', 'keyframes', 'ClassNames', 'jsx']);
18
-
19
- const SUPPORTED_IMPORT_MAP = {
20
- '@emotion/core': SUPPORTED_EMOTION_IMPORTS,
21
- '@emotion/react': SUPPORTED_EMOTION_IMPORTS,
22
- '@emotion/styled': new Set(['default']),
23
- 'styled-components': new Set(['default', 'css', 'keyframes']),
24
- };
25
-
26
- type SupportedImportSource = keyof typeof SUPPORTED_IMPORT_MAP;
27
-
28
- function isSupportedImportSource(importSource: string): importSource is SupportedImportSource {
29
- return importSource in SUPPORTED_IMPORT_MAP;
30
- }
31
-
32
- const schema = {
33
- type: 'array',
34
- items: [
35
- {
36
- type: 'object',
37
- properties: {
38
- canAutoFix: {
39
- type: 'boolean',
40
- },
41
- },
42
- additionalProperties: false,
43
- },
44
- ],
45
- } as const satisfies JSONSchema;
46
-
47
- type Config = {
48
- canAutoFix: boolean;
49
- };
50
-
51
- const defaultConfig: Config = {
52
- canAutoFix: false,
53
- };
54
-
55
- function readConfig(context: Rule.RuleContext): Config {
56
- const [config] = context.options as FromSchema<typeof schema>;
57
- return Object.assign({}, defaultConfig, config);
58
- }
59
-
60
- export const rule: Rule.RuleModule = createLintRule({
61
- meta: {
62
- name: 'use-compiled',
63
- type: 'problem',
64
- fixable: 'code',
65
- docs: {
66
- description: 'Ensures usage of `@compiled/react` instead of other CSS-in-JS libraries',
67
- recommended: true,
68
- severity: 'error',
69
- },
70
- messages: {
71
- 'use-compiled': `Use '@compiled/react' instead of '{{importSource}}'`,
72
- },
73
- schema,
74
- },
75
- create(context) {
76
- const config = readConfig(context);
77
-
78
- return {
79
- Program() {
80
- const pragma = context
81
- .getSourceCode()
82
- .getAllComments()
83
- .find((n) => n.value.includes('@jsxImportSource @emotion/react'));
84
-
85
- if (!pragma) {
86
- return;
87
- }
88
-
89
- context.report({
90
- messageId: 'use-compiled',
91
- data: {
92
- importSource: '@emotion/react',
93
- },
94
- loc: pragma.loc!,
95
- *fix(fixer) {
96
- if (!config.canAutoFix) {
97
- return;
98
- }
99
-
100
- const importDeclarations = context
101
- .getSourceCode()
102
- .ast.body.filter(
103
- (node): node is ESTree.ImportDeclaration => node.type === 'ImportDeclaration',
104
- );
105
-
106
- const hasEmotionImport = importDeclarations.some((importDeclaration) => {
107
- const importSource = importDeclaration.source.value as string;
108
- return importSource.startsWith('@emotion/');
109
- });
110
- const hasCompiledImport = importDeclarations.some(
111
- (importDeclaration) => importDeclaration.source.value === '@compiled/react',
112
- );
113
-
114
- if (hasEmotionImport || !hasCompiledImport) {
115
- // Considering this unsafe to auto-fix
116
- return;
117
- }
118
-
119
- yield fixer.replaceText(
120
- // @ts-expect-error - types don't accept comment nodes
121
- pragma,
122
- `/** @jsxImportSource @compiled/react */`,
123
- );
124
- },
125
- });
126
- },
127
- ImportDeclaration(node: ESTree.ImportDeclaration) {
128
- const importSource = node.source.value as string;
129
- if (!isSupportedImportSource(importSource)) {
130
- return;
131
- }
132
-
133
- context.report({
134
- node: node.source,
135
- messageId: 'use-compiled',
136
- data: {
137
- importSource,
138
- },
139
- *fix(fixer) {
140
- if (!config.canAutoFix) {
141
- return;
142
- }
143
-
144
- const specifiers = getSpecifiers({ context, node, importSource });
145
-
146
- if (!specifiers) {
147
- // Cannot safely auto-fix
148
- return;
149
- }
150
-
151
- yield* fixImport({
152
- context,
153
- fixer,
154
- node,
155
- specifiers,
156
- });
157
- },
158
- });
159
- },
160
- };
161
- },
162
- });
163
-
164
- export default rule;
165
-
166
- function getSpecifiers({
167
- context,
168
- node,
169
- importSource,
170
- }: {
171
- context: Rule.RuleContext;
172
- node: ESTree.ImportDeclaration;
173
- importSource: SupportedImportSource;
174
- }) {
175
- const supportedImports = SUPPORTED_IMPORT_MAP[importSource];
176
-
177
- // We aren't supporting namespace imports
178
- if (node.specifiers.some(isImportNamespaceSpecifier)) {
179
- return;
180
- }
181
-
182
- const defaultSpecifier = node.specifiers.find(isImportDefaultSpecifier);
183
- if (defaultSpecifier) {
184
- if (!supportedImports.has('default')) {
185
- return;
186
- }
187
- const styled = findVariable({
188
- identifier: defaultSpecifier.local,
189
- sourceCode: context.getSourceCode(),
190
- });
191
- if (!styled || !isSafeStyled(styled)) {
192
- return;
193
- }
194
- }
195
-
196
- const namedSpecifiers = node.specifiers.filter(isImportSpecifier);
197
- if (
198
- !namedSpecifiers.every((specifier) =>
199
- isSafeUsage({
200
- context,
201
- specifier,
202
- supportedImports,
203
- }),
204
- )
205
- ) {
206
- return;
207
- }
208
-
209
- if (defaultSpecifier) {
210
- return [
211
- ...namedSpecifiers,
212
- // ASSUMPTION: the default import, if allowed, is for `styled`
213
- importSpecifier({
214
- imported: identifier('styled'),
215
- local: node.specifiers[0].local,
216
- }),
217
- ];
218
- }
219
-
220
- return namedSpecifiers;
221
- }
222
-
223
- function* fixImport({
224
- context,
225
- fixer,
226
- node,
227
- specifiers,
228
- }: {
229
- context: Rule.RuleContext;
230
- fixer: Rule.RuleFixer;
231
- node: ESTree.ImportDeclaration;
232
- specifiers: ESTree.ImportSpecifier[];
233
- }): Generator<Rule.Fix> {
234
- const compiledImport = getFirstImportFromSource(context, '@compiled/react');
235
-
236
- if (compiledImport) {
237
- yield fixer.remove(node);
238
- yield fixer.replaceText(
239
- compiledImport,
240
- buildImportDeclaration(compiledImport.specifiers.concat(specifiers), '@compiled/react'),
241
- );
242
- } else {
243
- yield fixer.replaceText(node, buildImportDeclaration(specifiers, '@compiled/react'));
244
- }
245
- }
246
-
247
- function buildImportDeclaration(
248
- specifiers: ESTree.ImportDeclaration['specifiers'],
249
- source: string,
250
- ) {
251
- return `${importDeclaration({ specifiers, source: literal(source) })};`;
252
- }
@@ -1,159 +0,0 @@
1
- import type { Rule, Scope } from 'eslint';
2
- import { closestOfType } from 'eslint-codemod-utils';
3
- import type * as ESTree from 'eslint-codemod-utils';
4
-
5
- import { findVariable } from '@atlaskit/eslint-utils/find-variable';
6
-
7
- export function isSafeUsage({
8
- context,
9
- specifier,
10
- supportedImports,
11
- }: {
12
- context: Rule.RuleContext;
13
- specifier: ESTree.ImportSpecifier;
14
- supportedImports: Set<string>;
15
- }): boolean {
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
- }
40
-
41
- export function isSafeKeyframes(keyframes: Scope.Variable): boolean {
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
- }
66
-
67
- function isSafeKeyframePropertyValue(value: ESTree.Property['value']): boolean {
68
- if (value.type !== 'ObjectExpression') {
69
- return false;
70
- }
71
- return isSafeStyleObject(value);
72
- }
73
-
74
- export function isSafeCss(css: Scope.Variable): boolean {
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
- }
88
-
89
- export function isSafeStyled(styled: Scope.Variable): boolean {
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
- }
110
-
111
- /**
112
- * Determines if a style argument is safe for auto-fix conversion.
113
- */
114
- function isSafeStyleArgument(arg: ESTree.Expression | ESTree.SpreadElement): boolean {
115
- if (arg.type === 'ObjectExpression') {
116
- return isSafeStyleObject(arg);
117
- }
118
-
119
- return false;
120
- }
121
-
122
- function isSafeStyleObject(object: ESTree.ObjectExpression): boolean {
123
- return object.properties.every((property) => isSafeProperty(property, isSafeStyleValue));
124
- }
125
-
126
- function isSafeStyleValue(value: ESTree.Expression | ESTree.Pattern): boolean {
127
- if (value.type === 'Literal') {
128
- return true;
129
- }
130
-
131
- return false;
132
- }
133
-
134
- function isSafeProperty(
135
- property: ESTree.Property | ESTree.SpreadElement,
136
- isSafePropertyValue: (value: ESTree.Property['value']) => boolean,
137
- ): boolean {
138
- if (property.type === 'SpreadElement') {
139
- return false;
140
- }
141
-
142
- if (property.method || property.shorthand || property.kind !== 'init') {
143
- return false;
144
- }
145
-
146
- if (!hasSafeKey(property)) {
147
- return false;
148
- }
149
-
150
- return isSafePropertyValue(property.value);
151
- }
152
-
153
- function hasSafeKey(property: ESTree.Property): boolean {
154
- if (property.computed) {
155
- return property.key.type === 'Literal';
156
- }
157
-
158
- return true;
159
- }
@@ -1,33 +0,0 @@
1
- import type { Rule } from 'eslint';
2
-
3
- import type * as ESTree from 'eslint-codemod-utils';
4
-
5
- export function getFirstImportFromSource(
6
- context: Rule.RuleContext,
7
- source: string,
8
- ): ESTree.ImportDeclaration | undefined {
9
- return context
10
- .getSourceCode()
11
- .ast.body.filter(isImportDeclaration)
12
- .find((node) => node.source.value === source);
13
- }
14
-
15
- function isImportDeclaration(node: ESTree.Node): node is ESTree.ImportDeclaration {
16
- return node.type === 'ImportDeclaration';
17
- }
18
-
19
- export function isImportSpecifier(specifier: ESTree.Node): specifier is ESTree.ImportSpecifier {
20
- return specifier.type === 'ImportSpecifier';
21
- }
22
-
23
- export function isImportDefaultSpecifier(
24
- specifier: ESTree.Node,
25
- ): specifier is ESTree.ImportDefaultSpecifier {
26
- return specifier.type === 'ImportDefaultSpecifier';
27
- }
28
-
29
- export function isImportNamespaceSpecifier(
30
- specifier: ESTree.Node,
31
- ): specifier is ESTree.ImportNamespaceSpecifier {
32
- return specifier.type === 'ImportNamespaceSpecifier';
33
- }
@@ -1,86 +0,0 @@
1
- import Ajv from 'ajv';
2
- import type { Rule } from 'eslint';
3
- import type { FromSchema, JSONSchema } from 'json-schema-to-ts';
4
-
5
- import type {
6
- LintRule as BaseLintRule,
7
- LintRuleMeta as BaseLintRuleMeta,
8
- } from '@atlaskit/eslint-utils/create-rule';
9
-
10
- import { getRuleUrl } from './create-rule';
11
-
12
- export interface LintRule<Schema extends JSONSchema, Config>
13
- extends Omit<BaseLintRule, 'meta' | 'create'> {
14
- meta: LintRuleMeta<Schema>;
15
-
16
- create(context: Rule.RuleContext, config: Config): Rule.RuleListener;
17
-
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
- }
24
-
25
- export interface LintRuleMeta<Schema extends JSONSchema> extends Omit<BaseLintRuleMeta, 'schema'> {
26
- schema: Schema;
27
- }
28
-
29
- export const createLintRuleWithTypedConfig = <
30
- Schema extends JSONSchema & { type: 'object' },
31
- Config = FromSchema<Schema>,
32
- >(
33
- rule: LintRule<Schema, Config>,
34
- ) => {
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);
46
-
47
- const config = {};
48
- /**
49
- * The `validate()` function mutates the config object.
50
- */
51
- validate(config);
52
-
53
- return config as Config;
54
- }
55
-
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();
82
-
83
- return rule.create(context, config);
84
- },
85
- } as Rule.RuleModule;
86
- };
@@ -1,13 +0,0 @@
1
- import { getCreateLintRule, getPathSafeName } from '@atlaskit/eslint-utils/create-rule';
2
-
3
- /**
4
- * Tiny wrapped over the ESLint rule module type that ensures
5
- * there is a docs link to our ESLint plugin documentation page,
6
- * as well as improving type support.
7
- */
8
- export const createLintRule = getCreateLintRule(getRuleUrl);
9
-
10
- export function getRuleUrl(ruleName: string) {
11
- const name = getPathSafeName(ruleName);
12
- return `https://atlassian.design/components/eslint-plugin-ui-styling-standard/${name}/usage`;
13
- }
package/tsconfig.app.json DELETED
@@ -1,47 +0,0 @@
1
- {
2
- "extends": "../../../tsconfig.node.json",
3
- "include": ["./src/**/*.ts", "./src/**/*.tsx"],
4
- "exclude": [
5
- "**/docs/**/*",
6
- "**/__tests__/**/*",
7
- "**/vr-tests/**/*",
8
- "**/__perf__/**/*",
9
- "**/*.test.*",
10
- "**/test.*",
11
- "**/test-*",
12
- "**/examples.ts",
13
- "**/examples.tsx",
14
- "**/examples/*.ts",
15
- "**/examples/*.tsx",
16
- "**/examples/**/*.ts",
17
- "**/examples/**/*.tsx",
18
- "**/storybook/**/*",
19
- "**/constellation/**/*",
20
- ".storybook/*",
21
- "./__fixtures__/**/*",
22
- "./__generated__/**/*",
23
- "./mocks/**/*",
24
- "./__mocks__/**/*",
25
- "**/mock.*",
26
- "**/codemods/**/*.ts",
27
- "**/codemods/**/*.tsx"
28
- ],
29
- "compilerOptions": {
30
- "baseUrl": "./",
31
- "lib": ["ES2021.String"],
32
- "composite": true,
33
- "outDir": "../../../tsDist/@atlaskit__eslint-plugin-ui-styling-standard/app"
34
- },
35
- "references": [
36
- {
37
- "path": "../../../build/formatting/tsconfig.app.json"
38
- },
39
- {
40
- "path": "../eslint-utils/tsconfig.app.json"
41
- },
42
- {
43
- "path": "../codegen/tsconfig.app.json"
44
- }
45
- ],
46
- "files": []
47
- }
package/tsconfig.dev.json DELETED
@@ -1,45 +0,0 @@
1
- {
2
- "extends": "../../../tsconfig.node.json",
3
- "include": [
4
- "**/docs/**/*",
5
- "**/__tests__/**/*",
6
- "**/vr-tests/**/*",
7
- "**/__perf__/**/*",
8
- "**/*.test.*",
9
- "**/test.*",
10
- "**/test-*",
11
- "**/examples.ts",
12
- "**/examples.tsx",
13
- "**/examples/*.ts",
14
- "**/examples/*.tsx",
15
- "**/examples/**/*.ts",
16
- "**/examples/**/*.tsx",
17
- "**/storybook/**/*",
18
- "**/constellation/**/*",
19
- ".storybook/*",
20
- "./__fixtures__/**/*",
21
- "./__generated__/**/*",
22
- "./mocks/**/*",
23
- "./__mocks__/**/*",
24
- "**/mock.*",
25
- "**/codemods/**/*.ts",
26
- "**/codemods/**/*.tsx",
27
- "./**/__fixtures__/**/*.json"
28
- ],
29
- "exclude": ["./dist/**/*", "./build/**/*", "./node_modules/**/*"],
30
- "compilerOptions": {
31
- "baseUrl": "./",
32
- "lib": ["ES2021.String"],
33
- "composite": true,
34
- "outDir": "../../../tsDist/@atlaskit__eslint-plugin-ui-styling-standard/dev"
35
- },
36
- "references": [
37
- {
38
- "path": "tsconfig.app.json"
39
- },
40
- {
41
- "path": "../ds-lib/tsconfig.app.json"
42
- }
43
- ],
44
- "files": []
45
- }
package/tsconfig.json DELETED
@@ -1,25 +0,0 @@
1
- {
2
- "extends": "../../../tsconfig.node.json",
3
- "include": [
4
- "__tests__/**/*.ts",
5
- "__tests__/**/*.tsx",
6
- "docs/**/*.ts",
7
- "docs/**/*.tsx",
8
- "examples/**/*.ts",
9
- "examples/**/*.tsx",
10
- "src/**/*.ts",
11
- "src/**/*.tsx",
12
- "scripts"
13
- ],
14
- "exclude": [],
15
- "compilerOptions": {
16
- "baseUrl": "./",
17
- "lib": ["ES2021.String"]
18
- },
19
- "ts-node": {
20
- // It is faster to skip typechecking.
21
- "transpileOnly": true,
22
- // We must load files for third party defs - https://typestrong.org/ts-node/docs/types
23
- "files": true
24
- }
25
- }