@atlaskit/eslint-plugin-ui-styling-standard 0.17.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 (152) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/cjs/presets/all.codegen.js +3 -2
  3. package/dist/cjs/presets/recommended.codegen.js +3 -2
  4. package/dist/cjs/rules/external-rules.js +3 -1
  5. package/dist/es2019/presets/all.codegen.js +3 -2
  6. package/dist/es2019/presets/recommended.codegen.js +3 -2
  7. package/dist/es2019/rules/external-rules.js +3 -1
  8. package/dist/esm/presets/all.codegen.js +3 -2
  9. package/dist/esm/presets/recommended.codegen.js +3 -2
  10. package/dist/esm/rules/external-rules.js +3 -1
  11. package/dist/types/index.codegen.d.ts +2 -0
  12. package/dist/types/presets/all.codegen.d.ts +2 -1
  13. package/dist/types/presets/recommended.codegen.d.ts +2 -1
  14. package/dist/types-ts4.5/index.codegen.d.ts +2 -0
  15. package/dist/types-ts4.5/presets/all.codegen.d.ts +2 -1
  16. package/dist/types-ts4.5/presets/recommended.codegen.d.ts +2 -1
  17. package/package.json +2 -2
  18. package/afm-cc/tsconfig.json +0 -28
  19. package/afm-jira/tsconfig.json +0 -28
  20. package/build/tsconfig.json +0 -18
  21. package/constellation/atlaskit-theme/usage.mdx +0 -132
  22. package/constellation/consistent-css-prop-usage/usage.mdx +0 -7
  23. package/constellation/convert-props-syntax/usage.mdx +0 -130
  24. package/constellation/enforce-style-prop/usage.mdx +0 -47
  25. package/constellation/index/migration-guide.mdx +0 -309
  26. package/constellation/index/overview.mdx +0 -250
  27. package/constellation/index/props.mdx +0 -30
  28. package/constellation/local-cx-xcss/usage.mdx +0 -53
  29. package/constellation/no-array-arguments/usage.mdx +0 -49
  30. package/constellation/no-classname-prop/usage.mdx +0 -49
  31. package/constellation/no-container-queries/usage.mdx +0 -101
  32. package/constellation/no-css-tagged-template-expression/usage.mdx +0 -8
  33. package/constellation/no-dynamic-styles/usage.mdx +0 -130
  34. package/constellation/no-empty-styled-expression/usage.mdx +0 -8
  35. package/constellation/no-exported-css/usage.mdx +0 -8
  36. package/constellation/no-exported-keyframes/usage.mdx +0 -8
  37. package/constellation/no-exported-styles/usage.mdx +0 -87
  38. package/constellation/no-global-styles/usage.mdx +0 -60
  39. package/constellation/no-important-styles/usage.mdx +0 -33
  40. package/constellation/no-imported-style-values/usage.mdx +0 -157
  41. package/constellation/no-invalid-css-map/usage.mdx +0 -8
  42. package/constellation/no-js-xcss/usage.mdx +0 -7
  43. package/constellation/no-keyframes-tagged-template-expression/usage.mdx +0 -8
  44. package/constellation/no-nested-selectors/usage.mdx +0 -95
  45. package/constellation/no-styled/usage.mdx +0 -92
  46. package/constellation/no-styled-tagged-template-expression/usage.mdx +0 -8
  47. package/constellation/no-suppress-xcss/usage.mdx +0 -28
  48. package/constellation/no-unsafe-selectors/usage.mdx +0 -370
  49. package/constellation/no-unsafe-values/usage.mdx +0 -318
  50. package/constellation/use-compiled/usage.mdx +0 -54
  51. package/index.js +0 -24
  52. package/scripts/codegen.tsx +0 -373
  53. package/src/index.codegen.tsx +0 -14
  54. package/src/index.tsx +0 -1
  55. package/src/presets/all.codegen.tsx +0 -79
  56. package/src/presets/recommended.codegen.tsx +0 -79
  57. package/src/rules/TEMPLATE.md +0 -29
  58. package/src/rules/__tests__/utils/_tester.tsx +0 -40
  59. package/src/rules/atlaskit-theme/README.md +0 -130
  60. package/src/rules/atlaskit-theme/__tests__/test.ts +0 -133
  61. package/src/rules/atlaskit-theme/index.ts +0 -134
  62. package/src/rules/convert-props-syntax/README.md +0 -128
  63. package/src/rules/convert-props-syntax/__tests__/invalid.test.tsx +0 -76
  64. package/src/rules/convert-props-syntax/__tests__/rule.test.tsx +0 -584
  65. package/src/rules/convert-props-syntax/__tests__/type-annotations.test.tsx +0 -140
  66. package/src/rules/convert-props-syntax/__tests__/unusual-properties.test.tsx +0 -69
  67. package/src/rules/convert-props-syntax/index.tsx +0 -414
  68. package/src/rules/enforce-style-prop/README.md +0 -45
  69. package/src/rules/enforce-style-prop/__tests__/rule.test.tsx +0 -243
  70. package/src/rules/enforce-style-prop/index.tsx +0 -172
  71. package/src/rules/external-rules.tsx +0 -175
  72. package/src/rules/index.codegen.tsx +0 -42
  73. package/src/rules/local-cx-xcss/README.md +0 -51
  74. package/src/rules/local-cx-xcss/__tests__/rule.test.tsx +0 -102
  75. package/src/rules/local-cx-xcss/index.tsx +0 -62
  76. package/src/rules/no-array-arguments/README.md +0 -47
  77. package/src/rules/no-array-arguments/__tests__/rule.test.tsx +0 -107
  78. package/src/rules/no-array-arguments/index.tsx +0 -86
  79. package/src/rules/no-classname-prop/README.md +0 -47
  80. package/src/rules/no-classname-prop/__tests__/rule.test.tsx +0 -39
  81. package/src/rules/no-classname-prop/index.tsx +0 -34
  82. package/src/rules/no-container-queries/README.md +0 -99
  83. package/src/rules/no-container-queries/__tests__/rule.test.tsx +0 -139
  84. package/src/rules/no-container-queries/index.tsx +0 -94
  85. package/src/rules/no-dynamic-styles/README.md +0 -128
  86. package/src/rules/no-dynamic-styles/__tests__/rule.test.tsx +0 -135
  87. package/src/rules/no-dynamic-styles/index.tsx +0 -60
  88. package/src/rules/no-exported-styles/README.md +0 -85
  89. package/src/rules/no-exported-styles/__tests__/rule.test.tsx +0 -216
  90. package/src/rules/no-exported-styles/index.tsx +0 -52
  91. package/src/rules/no-global-styles/README.md +0 -58
  92. package/src/rules/no-global-styles/__tests__/no-css-modules.test.tsx +0 -33
  93. package/src/rules/no-global-styles/__tests__/no-global-styles.test.tsx +0 -46
  94. package/src/rules/no-global-styles/index.tsx +0 -82
  95. package/src/rules/no-important-styles/README.md +0 -31
  96. package/src/rules/no-important-styles/__tests__/rule.test.tsx +0 -165
  97. package/src/rules/no-important-styles/index.tsx +0 -70
  98. package/src/rules/no-imported-style-values/README.md +0 -155
  99. package/src/rules/no-imported-style-values/__tests__/rule.test.tsx +0 -491
  100. package/src/rules/no-imported-style-values/index.tsx +0 -188
  101. package/src/rules/no-nested-selectors/README.md +0 -93
  102. package/src/rules/no-nested-selectors/__tests__/rule.test.tsx +0 -335
  103. package/src/rules/no-nested-selectors/index.tsx +0 -99
  104. package/src/rules/no-styled/README.md +0 -90
  105. package/src/rules/no-styled/__tests__/rule.test.tsx +0 -73
  106. package/src/rules/no-styled/index.tsx +0 -45
  107. package/src/rules/no-unsafe-selectors/README.md +0 -368
  108. package/src/rules/no-unsafe-selectors/__tests__/no-ambiguous-pseudos.test.tsx +0 -368
  109. package/src/rules/no-unsafe-selectors/__tests__/no-grouped-at-rules.test.tsx +0 -57
  110. package/src/rules/no-unsafe-selectors/__tests__/no-increased-specificity.test.tsx +0 -73
  111. package/src/rules/no-unsafe-selectors/__tests__/no-keyframes-at-rules.test.tsx +0 -40
  112. package/src/rules/no-unsafe-selectors/__tests__/no-legacy-pseudo-element-syntax.test.tsx +0 -101
  113. package/src/rules/no-unsafe-selectors/__tests__/no-restricted-at-rules.test.tsx +0 -131
  114. package/src/rules/no-unsafe-selectors/__tests__/no-restricted-pseudos.test.tsx +0 -132
  115. package/src/rules/no-unsafe-selectors/__tests__/no-selectors-object.test.tsx +0 -25
  116. package/src/rules/no-unsafe-selectors/__tests__/no-unparsable-selectors.test.tsx +0 -35
  117. package/src/rules/no-unsafe-selectors/__tests__/rule.test.tsx +0 -257
  118. package/src/rules/no-unsafe-selectors/constants.tsx +0 -91
  119. package/src/rules/no-unsafe-selectors/index.tsx +0 -198
  120. package/src/rules/no-unsafe-selectors/lint-selector.tsx +0 -155
  121. package/src/rules/no-unsafe-selectors/source-position-utils.tsx +0 -55
  122. package/src/rules/no-unsafe-selectors/walk-css-map.tsx +0 -226
  123. package/src/rules/no-unsafe-values/README.md +0 -316
  124. package/src/rules/no-unsafe-values/__tests__/no-array-values.test.tsx +0 -27
  125. package/src/rules/no-unsafe-values/__tests__/no-conditional-values.test.tsx +0 -37
  126. package/src/rules/no-unsafe-values/__tests__/no-dynamic-keys.test.tsx +0 -229
  127. package/src/rules/no-unsafe-values/__tests__/no-function-calls.test.tsx +0 -267
  128. package/src/rules/no-unsafe-values/__tests__/no-identifier-arguments.test.tsx +0 -52
  129. package/src/rules/no-unsafe-values/__tests__/no-object-access.test.tsx +0 -106
  130. package/src/rules/no-unsafe-values/__tests__/no-object-references.test.tsx +0 -44
  131. package/src/rules/no-unsafe-values/__tests__/no-spread-elements.test.tsx +0 -48
  132. package/src/rules/no-unsafe-values/__tests__/no-unsafe-values.test.tsx +0 -75
  133. package/src/rules/no-unsafe-values/__tests__/no-variables.test.tsx +0 -121
  134. package/src/rules/no-unsafe-values/index.tsx +0 -94
  135. package/src/rules/no-unsafe-values/messages.tsx +0 -86
  136. package/src/rules/no-unsafe-values/utils.tsx +0 -387
  137. package/src/rules/use-compiled/README.md +0 -52
  138. package/src/rules/use-compiled/__tests__/can-auto-fix.test.tsx +0 -73
  139. package/src/rules/use-compiled/__tests__/css.test.tsx +0 -126
  140. package/src/rules/use-compiled/__tests__/imports.test.tsx +0 -158
  141. package/src/rules/use-compiled/__tests__/keyframes.test.tsx +0 -140
  142. package/src/rules/use-compiled/__tests__/pragma.test.tsx +0 -108
  143. package/src/rules/use-compiled/__tests__/styled.test.tsx +0 -114
  144. package/src/rules/use-compiled/__tests__/use-compiled.test.tsx +0 -15
  145. package/src/rules/use-compiled/index.tsx +0 -252
  146. package/src/rules/use-compiled/is-safe.tsx +0 -159
  147. package/src/rules/use-compiled/utils.tsx +0 -33
  148. package/src/rules/utils/create-rule-with-typed-config.tsx +0 -86
  149. package/src/rules/utils/create-rule.tsx +0 -13
  150. package/tsconfig.app.json +0 -47
  151. package/tsconfig.dev.json +0 -45
  152. package/tsconfig.json +0 -25
package/index.js DELETED
@@ -1,24 +0,0 @@
1
- /* eslint-disable import/no-extraneous-dependencies */
2
- /* eslint-disable global-require */
3
- // Used only for internal repo usage.
4
- const path = require('path');
5
-
6
- const paths = require('tsconfig-paths');
7
-
8
- if (!require.extensions['.ts']) {
9
- // ts-node can only handle being registered once, see https://github.com/TypeStrong/ts-node/issues/409
10
- require('ts-node').register({
11
- project: path.join(__dirname, 'tsconfig.json'),
12
- });
13
- }
14
-
15
- try {
16
- // We programatically register tsconfig paths here so it picks up the tsconfig here
17
- // instead of in root CWD.
18
- paths.register(paths.loadConfig(__dirname));
19
- } catch (e) {
20
- // eslint-disable-next-line no-console
21
- console.log(e);
22
- }
23
-
24
- module.exports = require('./src/index');
@@ -1,373 +0,0 @@
1
- import { existsSync } from 'fs';
2
- import fs from 'fs/promises';
3
- import { extname, join, relative } from 'path';
4
-
5
- import camelCase from 'lodash/camelCase';
6
- import outdent from 'outdent';
7
- import format from '@af/formatting/sync';
8
-
9
- import { createSignedArtifact } from '@atlassian/codegen';
10
-
11
- import { type LintRule, getPathSafeName } from '@atlaskit/eslint-utils/create-rule';
12
- import { externalRules, type ExternalRuleMeta } from '../src/rules/external-rules';
13
-
14
- const packagePluginName = '@atlaskit/eslint-plugin-ui-styling-standard';
15
- const pluginName = '@atlaskit/ui-styling-standard';
16
- const pluginPath = 'eslint-plugin-ui-styling-standard';
17
- const codegenCommand = `yarn workspace ${packagePluginName} codegen`;
18
-
19
- interface FoundRule {
20
- module: LintRule | { meta: ExternalRuleMeta };
21
- /**
22
- * This is used for the directory name, import path, and urls
23
- */
24
- pathSafeName: string;
25
- /**
26
- * Friendly name that can include special characters
27
- */
28
- ruleName: string;
29
- }
30
-
31
- /**
32
- * A rule that is externally referenced and distributed via dependencies rather than local.
33
- * These come from `rules/external-rules.tsx`
34
- */
35
- interface ExternalRule extends FoundRule {
36
- module: { meta: ExternalRuleMeta };
37
- }
38
- interface InternalRule extends FoundRule {
39
- module: LintRule;
40
- }
41
-
42
- interface GeneratedConfig {
43
- name: string;
44
- path: string;
45
- }
46
-
47
- const ignoreList = ['index.codegen.tsx', 'TEMPLATE.md', '__tests__', 'utils', 'external-rules.tsx'];
48
- const srcDir = join(__dirname, '../src');
49
- const rulesDir = join(srcDir, 'rules');
50
- const presetsDir = join(srcDir, 'presets');
51
- const generatedConfigs: GeneratedConfig[] = [];
52
-
53
- function ruleIsExternal(rule: FoundRule | ExternalRule): rule is ExternalRule {
54
- return 'isExternal' in rule.module.meta && !!rule.module.meta.isExternal;
55
- }
56
- function ruleIsInternal(rule: FoundRule | ExternalRule): rule is InternalRule {
57
- return !ruleIsExternal(rule);
58
- }
59
-
60
- /**
61
- * Get the path to, and file contents for, a rule's README.md file.
62
- */
63
- async function ruleDocsPath(name: string) {
64
- const absolutePath = join(rulesDir, name, 'README.md');
65
- const relativePath = '.' + absolutePath.replace(process.cwd(), '');
66
-
67
- try {
68
- const file = await fs.readFile(absolutePath, 'utf-8');
69
- return { path: relativePath, file };
70
- } catch (_) {
71
- throw new Error(`invariant: rule ${name} should have docs at ${absolutePath}`);
72
- }
73
- }
74
-
75
- /**
76
- * Generates the preset config, eg. `src/presets/all.codegen.tsx` and `src/presets/recommended.codegen.tsx`
77
- */
78
- async function generatePresetConfig(name: 'all' | 'recommended', rules: FoundRule[]) {
79
- const externalScopes = externalRules
80
- .filter((rule) => rule.name?.includes('/'))
81
- .map((rule) => {
82
- // Take the first part of the name, eg. `@atlaskit/design-system` and wrap it in quotes to be
83
- const groups = rule.name.split('/');
84
- return `'${groups.slice(0, groups.length - 1).join('/')}'`;
85
- });
86
-
87
- // NOTE: Given we have external plugins, we must include them as plugins as well./
88
- const pluginList = [`'${pluginName}'`, ...Array.from(new Set(externalScopes))];
89
-
90
- const code = outdent`
91
- export default {
92
- plugins: [
93
- ${pluginList.join(',\n')}],
94
- rules: {
95
- ${rules
96
- .map((rule) => {
97
- const { severity, recommended, pluginConfig } = rule.module.meta?.docs || {};
98
-
99
- // `recommended` is a snowflake at this stage ... it can be a string at runtime
100
- // because of legacy `import { createRule } from 'utils/create-rule'` so we take
101
- // into account this possibility (as a fallback) until everything is moved over
102
- // to the new syntax
103
- const calculatedSeverity =
104
- severity ?? (typeof recommended === 'string' ? String(recommended) : 'error');
105
-
106
- let ruleName = rule.ruleName;
107
- if (ruleIsInternal(rule)) {
108
- ruleName = `${pluginName}/${rule.ruleName}`;
109
- }
110
-
111
- if (typeof pluginConfig === 'object' && pluginConfig) {
112
- return `'${ruleName}': ['${calculatedSeverity}', ${JSON.stringify(pluginConfig)}]`;
113
- }
114
-
115
- return `'${ruleName}': '${calculatedSeverity}'`;
116
- })
117
- .join(',')}
118
- },
119
- }
120
- `;
121
-
122
- const filepath = join(presetsDir, `${name}.codegen.tsx`);
123
- await writeFile(filepath, code);
124
-
125
- generatedConfigs.push({
126
- name: camelCase(name),
127
- path: './' + relative(srcDir, join(presetsDir, `${name}.codegen`)),
128
- });
129
- }
130
-
131
- /**
132
- * Write contents to a given file, creating a signed artifact if it's not a markdown file.
133
- */
134
- async function writeFile(filepath: string, code: string) {
135
- await fs.writeFile(
136
- filepath,
137
- extname(filepath).includes('.md')
138
- ? format(code, 'markdown')
139
- : createSignedArtifact(format(code, 'typescript'), codegenCommand),
140
- );
141
- }
142
-
143
- /**
144
- * Generates the `src/rules/index.codegen.tsx` entrypoint, exporting all rules.
145
- */
146
- async function generateRuleIndex(rules: FoundRule[]) {
147
- const internalRules = rules.filter(ruleIsInternal);
148
-
149
- const code = outdent`
150
- ${internalRules
151
- .map((rule) => `import ${camelCase(rule.pathSafeName)} from './${rule.pathSafeName}'`)
152
- .join('\n')}
153
-
154
- export default {
155
- ${internalRules.map((rule) => `'${rule.ruleName}': ${camelCase(rule.pathSafeName)}`).join(',')}
156
- }
157
- `;
158
-
159
- const filepath = join(rulesDir, 'index.codegen.tsx');
160
- await writeFile(filepath, code);
161
- }
162
-
163
- /**
164
- * Generates the `src/index.codegen.tsx` entrypoint, exporting all the preset configs.
165
- */
166
- async function generatePluginIndex() {
167
- const code = outdent`
168
- ${generatedConfigs.map((config) => `import ${config.name} from '${config.path}'`).join('\n')}
169
-
170
- export { default as rules } from './rules/index.codegen'
171
-
172
- export const configs = {
173
- ${generatedConfigs.map((config) => `${config.name}`).join(',')}
174
- }
175
- `;
176
-
177
- const filepath = join(srcDir, 'index.codegen.tsx');
178
- await writeFile(filepath, code);
179
- }
180
-
181
- const conditional = (cond: string, content?: boolean | string) => (content ? cond : '');
182
- const optionallyLinkTo = (content: string, url?: string) =>
183
- url ? `<a href="${url}">${content}</a>` : content;
184
-
185
- /**
186
- * Generate each individual rules' documentation pages, eg. `constellation/icon-label/usage.mdx`
187
- */
188
- async function generateRulePages(rules: FoundRule[]): Promise<void> {
189
- const docsDir = join(srcDir, '../constellation');
190
-
191
- for await (const rule of rules) {
192
- const ruleDir = join(docsDir, rule.pathSafeName);
193
- const destination = join(ruleDir, 'usage.mdx');
194
- await fs.mkdir(ruleDir, { recursive: true });
195
-
196
- if (ruleIsExternal(rule)) {
197
- await generateExternalRulePage(rule, destination);
198
- } else if (ruleIsInternal(rule)) {
199
- await generateInternalRulePage(rule, destination);
200
- } else {
201
- throw new Error(`invariant: found an unexpected rule type ${rule.ruleName}`);
202
- }
203
- }
204
- }
205
-
206
- async function generateExternalRulePage(rule: ExternalRule, destination: string) {
207
- if (existsSync(destination)) {
208
- return true;
209
- }
210
-
211
- const ruleContent = outdent`
212
- # ${rule.ruleName}
213
- ${rule.module.meta?.docs?.description || ''}
214
-
215
- ${
216
- rule.module.meta?.docs?.externalUrl
217
- ? `This rule is maintained by another package and configured here; refer to ${rule.module.meta.docs.externalUrl} for more details.`
218
- : ''
219
- }
220
- `;
221
-
222
- await writeFile(destination, ruleContent);
223
- }
224
-
225
- async function generateInternalRulePage(rule: InternalRule, destination: string) {
226
- const { file } = await ruleDocsPath(rule.pathSafeName);
227
- if (file.match(/^# /)) {
228
- throw new Error(
229
- `invariant: ${rule.pathSafeName} README doc should not include a h1 heading as it is injected automatically.`,
230
- );
231
- }
232
-
233
- const ruleContent = outdent`
234
- # ${rule.ruleName}
235
- ${file}
236
- `;
237
-
238
- await writeFile(destination, ruleContent);
239
- }
240
-
241
- /**
242
- * Generates the `RULE_TABLE_CODEGEN` in `constellation/index/usage.mdx` and `README.md`.
243
- * This is the list of all rules and their metadata.
244
- */
245
- async function generateRuleTable(filepath: string, linkTo: 'docs' | 'repo', rules: FoundRule[]) {
246
- const file = await fs.readFile(filepath, 'utf-8');
247
- const rows: string[] = [];
248
-
249
- for (const rule of rules) {
250
- let docsPath: string | undefined;
251
-
252
- if (linkTo === 'docs') {
253
- docsPath = `/components/${pluginPath}/${rule.pathSafeName}/usage`;
254
- } else if (ruleIsInternal(rule)) {
255
- const result = await ruleDocsPath(rule.pathSafeName);
256
- docsPath = result.path;
257
- } else {
258
- docsPath = rule.module.meta?.docs?.url;
259
- }
260
-
261
- const link = optionallyLinkTo(rule.ruleName, docsPath);
262
- const description = rule.module.meta?.docs?.description || '';
263
- const recommended = conditional('Yes', rule.module.meta?.docs?.recommended);
264
- const fixable = conditional('Yes', rule.module.meta?.fixable);
265
- const suggestions = conditional('Yes', rule.module.meta?.hasSuggestions);
266
-
267
- rows.push(outdent`
268
- | ${link} | ${description} | ${recommended} | ${fixable} | ${suggestions} |
269
- `);
270
- }
271
-
272
- const code = outdent`
273
- | Rule | Description | Recommended | Fixable | Suggestions |
274
- | ---- | -- | -- | -- | -- |
275
- ${rows.join('\n')}
276
- `;
277
-
278
- const found = /<!-- START_RULE_TABLE_CODEGEN -->(.|\n)*<!-- END_RULE_TABLE_CODEGEN -->/.exec(
279
- file,
280
- );
281
-
282
- if (!found) {
283
- throw new Error(`invariant: could not find the partial codegen section in ${filepath}`);
284
- }
285
-
286
- const updatedFile = file.replace(
287
- found[0],
288
- outdent`
289
- <!-- START_RULE_TABLE_CODEGEN -->
290
- <!-- @codegenCommand ${codegenCommand} -->
291
- ${code}
292
- <!-- END_RULE_TABLE_CODEGEN -->
293
- `,
294
- );
295
-
296
- await writeFile(filepath, updatedFile);
297
- }
298
-
299
- const validateInternalRule = (rule: InternalRule) => {
300
- if (typeof rule.ruleName !== 'string' || !rule.ruleName) {
301
- throw new Error(
302
- `invariant: The ${rule.pathSafeName} rule must use the createLintRule() function`,
303
- );
304
- }
305
-
306
- if (ruleIsInternal(rule) && rule.pathSafeName !== rule.ruleName) {
307
- throw new Error(
308
- `invariant: module name ${rule.pathSafeName} does not match lint rule name ${rule.ruleName}`,
309
- );
310
- }
311
-
312
- if (rule.pathSafeName.includes('@') || rule.pathSafeName.includes('/')) {
313
- throw new Error(`invariant: name ${rule.pathSafeName} is not valid, specify a path-safe name`);
314
- }
315
- };
316
-
317
- /**
318
- * Fetch all rules in `rules/*` and generate all associated contents.
319
- */
320
- async function generate() {
321
- const rulePaths = await fs.readdir(rulesDir);
322
- const recommended: FoundRule[] = [];
323
- const rules: FoundRule[] = [];
324
-
325
- for (const filename of rulePaths) {
326
- if (ignoreList.includes(filename)) {
327
- continue;
328
- }
329
-
330
- const dirname = filename.replace(extname(filename), '');
331
- const filenameWithExt = filename.endsWith('.tsx') ? filename + '.tsx' : filename;
332
-
333
- const rule: LintRule = (await import(join(rulesDir, filenameWithExt))).default;
334
-
335
- const foundRule: InternalRule = {
336
- module: rule,
337
- pathSafeName: dirname,
338
- ruleName: rule.name || rule.meta.name,
339
- };
340
-
341
- validateInternalRule(foundRule);
342
-
343
- rules.push(foundRule);
344
- }
345
-
346
- for (const rule of externalRules) {
347
- const foundRule: ExternalRule = {
348
- module: { meta: rule },
349
- pathSafeName: rule.displayName || getPathSafeName(rule.name),
350
- ruleName: rule.name,
351
- };
352
-
353
- // We don't validate these; types should do their job instead.
354
- rules.push(foundRule);
355
- }
356
-
357
- rules.forEach((rule) => {
358
- if (rule.module.meta?.docs?.recommended) {
359
- recommended.push(rule);
360
- }
361
- });
362
-
363
- // NOTE: Some of these could be awaited in parallel, but it's not worth the complexity for <1s diff.
364
- await generateRuleIndex(rules);
365
- await generatePresetConfig('all', rules);
366
- await generatePresetConfig('recommended', recommended);
367
- await generatePluginIndex();
368
- await generateRulePages(rules);
369
- await generateRuleTable(join(srcDir, '../README.md'), 'repo', rules);
370
- await generateRuleTable(join(srcDir, '../constellation/index/overview.mdx'), 'docs', rules);
371
- }
372
-
373
- generate();
@@ -1,14 +0,0 @@
1
- /**
2
- * THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
3
- * @codegen <<SignedSource::aff3fad2b8534fad07ba5f0f1b981a55>>
4
- * @codegenCommand yarn workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
5
- */
6
- import all from './presets/all.codegen';
7
- import recommended from './presets/recommended.codegen';
8
-
9
- export { default as rules } from './rules/index.codegen';
10
-
11
- export const configs = {
12
- all,
13
- recommended,
14
- };
package/src/index.tsx DELETED
@@ -1 +0,0 @@
1
- export { configs, rules } from './index.codegen';
@@ -1,79 +0,0 @@
1
- /**
2
- * THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
3
- * @codegen <<SignedSource::aa1d9d67dc9b6b0488df0b31ff142f30>>
4
- * @codegenCommand yarn workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
5
- */
6
- export default {
7
- plugins: ['@atlaskit/ui-styling-standard', '@atlaskit/design-system', '@compiled'],
8
- rules: {
9
- '@atlaskit/ui-styling-standard/atlaskit-theme': 'error',
10
- '@atlaskit/ui-styling-standard/convert-props-syntax': 'error',
11
- '@atlaskit/ui-styling-standard/enforce-style-prop': 'error',
12
- '@atlaskit/ui-styling-standard/local-cx-xcss': 'error',
13
- '@atlaskit/ui-styling-standard/no-array-arguments': 'error',
14
- '@atlaskit/ui-styling-standard/no-classname-prop': 'error',
15
- '@atlaskit/ui-styling-standard/no-container-queries': 'error',
16
- '@atlaskit/ui-styling-standard/no-dynamic-styles': 'error',
17
- '@atlaskit/ui-styling-standard/no-exported-styles': 'error',
18
- '@atlaskit/ui-styling-standard/no-global-styles': 'error',
19
- '@atlaskit/ui-styling-standard/no-important-styles': 'error',
20
- '@atlaskit/ui-styling-standard/no-imported-style-values': 'error',
21
- '@atlaskit/ui-styling-standard/no-nested-selectors': 'error',
22
- '@atlaskit/ui-styling-standard/no-styled': 'error',
23
- '@atlaskit/ui-styling-standard/no-unsafe-selectors': 'error',
24
- '@atlaskit/ui-styling-standard/no-unsafe-values': 'error',
25
- '@atlaskit/ui-styling-standard/use-compiled': 'error',
26
- '@atlaskit/design-system/consistent-css-prop-usage': [
27
- 'error',
28
- { excludeReactComponents: true },
29
- ],
30
- '@atlaskit/design-system/no-css-tagged-template-expression': 'error',
31
- '@atlaskit/design-system/no-keyframes-tagged-template-expression': 'error',
32
- '@atlaskit/design-system/no-styled-tagged-template-expression': 'error',
33
- '@compiled/no-suppress-xcss': 'error',
34
- '@compiled/no-js-xcss': 'error',
35
- '@atlaskit/design-system/no-empty-styled-expression': [
36
- 'error',
37
- {
38
- importSources: [
39
- '@compiled/react',
40
- '@atlaskit/css',
41
- '@emotion/core',
42
- '@emotion/react',
43
- '@emotion/styled',
44
- 'styled-components',
45
- ],
46
- },
47
- ],
48
- '@atlaskit/design-system/no-exported-css': [
49
- 'error',
50
- {
51
- importSources: [
52
- '@compiled/react',
53
- '@atlaskit/css',
54
- '@emotion/core',
55
- '@emotion/react',
56
- '@emotion/styled',
57
- 'styled-components',
58
- ],
59
- },
60
- ],
61
- '@atlaskit/design-system/no-exported-keyframes': [
62
- 'error',
63
- {
64
- importSources: [
65
- '@compiled/react',
66
- '@atlaskit/css',
67
- '@emotion/core',
68
- '@emotion/react',
69
- '@emotion/styled',
70
- 'styled-components',
71
- ],
72
- },
73
- ],
74
- '@atlaskit/design-system/no-invalid-css-map': [
75
- 'error',
76
- { allowedFunctionCalls: [['@atlaskit/tokens', 'token']] },
77
- ],
78
- },
79
- };
@@ -1,79 +0,0 @@
1
- /**
2
- * THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
3
- * @codegen <<SignedSource::aa1d9d67dc9b6b0488df0b31ff142f30>>
4
- * @codegenCommand yarn workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
5
- */
6
- export default {
7
- plugins: ['@atlaskit/ui-styling-standard', '@atlaskit/design-system', '@compiled'],
8
- rules: {
9
- '@atlaskit/ui-styling-standard/atlaskit-theme': 'error',
10
- '@atlaskit/ui-styling-standard/convert-props-syntax': 'error',
11
- '@atlaskit/ui-styling-standard/enforce-style-prop': 'error',
12
- '@atlaskit/ui-styling-standard/local-cx-xcss': 'error',
13
- '@atlaskit/ui-styling-standard/no-array-arguments': 'error',
14
- '@atlaskit/ui-styling-standard/no-classname-prop': 'error',
15
- '@atlaskit/ui-styling-standard/no-container-queries': 'error',
16
- '@atlaskit/ui-styling-standard/no-dynamic-styles': 'error',
17
- '@atlaskit/ui-styling-standard/no-exported-styles': 'error',
18
- '@atlaskit/ui-styling-standard/no-global-styles': 'error',
19
- '@atlaskit/ui-styling-standard/no-important-styles': 'error',
20
- '@atlaskit/ui-styling-standard/no-imported-style-values': 'error',
21
- '@atlaskit/ui-styling-standard/no-nested-selectors': 'error',
22
- '@atlaskit/ui-styling-standard/no-styled': 'error',
23
- '@atlaskit/ui-styling-standard/no-unsafe-selectors': 'error',
24
- '@atlaskit/ui-styling-standard/no-unsafe-values': 'error',
25
- '@atlaskit/ui-styling-standard/use-compiled': 'error',
26
- '@atlaskit/design-system/consistent-css-prop-usage': [
27
- 'error',
28
- { excludeReactComponents: true },
29
- ],
30
- '@atlaskit/design-system/no-css-tagged-template-expression': 'error',
31
- '@atlaskit/design-system/no-keyframes-tagged-template-expression': 'error',
32
- '@atlaskit/design-system/no-styled-tagged-template-expression': 'error',
33
- '@compiled/no-suppress-xcss': 'error',
34
- '@compiled/no-js-xcss': 'error',
35
- '@atlaskit/design-system/no-empty-styled-expression': [
36
- 'error',
37
- {
38
- importSources: [
39
- '@compiled/react',
40
- '@atlaskit/css',
41
- '@emotion/core',
42
- '@emotion/react',
43
- '@emotion/styled',
44
- 'styled-components',
45
- ],
46
- },
47
- ],
48
- '@atlaskit/design-system/no-exported-css': [
49
- 'error',
50
- {
51
- importSources: [
52
- '@compiled/react',
53
- '@atlaskit/css',
54
- '@emotion/core',
55
- '@emotion/react',
56
- '@emotion/styled',
57
- 'styled-components',
58
- ],
59
- },
60
- ],
61
- '@atlaskit/design-system/no-exported-keyframes': [
62
- 'error',
63
- {
64
- importSources: [
65
- '@compiled/react',
66
- '@atlaskit/css',
67
- '@emotion/core',
68
- '@emotion/react',
69
- '@emotion/styled',
70
- 'styled-components',
71
- ],
72
- },
73
- ],
74
- '@atlaskit/design-system/no-invalid-css-map': [
75
- 'error',
76
- { allowedFunctionCalls: [['@atlaskit/tokens', 'token']] },
77
- ],
78
- },
79
- };
@@ -1,29 +0,0 @@
1
- <!-- To fill out -- tell us why this rule exists and any relevant context. -->
2
-
3
- ## Examples
4
-
5
- <!-- To fill out -- tell us when this rule will mark violations. -->
6
-
7
- ### Incorrect
8
-
9
- ```tsx
10
- // To fill out: incorrect code
11
- // Have one code block for all incorrect examples
12
- ```
13
-
14
- ### Correct
15
-
16
- ```tsx
17
- // To fill out: correct code
18
- // Have one code block for all correct examples
19
- ```
20
-
21
- ## Options
22
-
23
- <!-- To fill out -- delete section if rule doesn't take any options. -->
24
-
25
- This rule accepts...
26
-
27
- ## When not to use it
28
-
29
- <!-- To fill out -- delete section if this should should always be used. -->
@@ -1,40 +0,0 @@
1
- /* eslint-disable @repo/internal/fs/filename-pattern-match */
2
- /* eslint-disable no-undef */
3
- import { ESLintUtils } from '@typescript-eslint/utils';
4
- import { RuleTester } from 'eslint';
5
-
6
- import __noop from '@atlaskit/ds-lib/noop';
7
-
8
- (RuleTester as any).describe = (text: string, method: Function) => {
9
- const origHasAssertions = expect.hasAssertions;
10
- describe(text, () => {
11
- beforeAll(() => {
12
- // Stub out expect.hasAssertions beforeEach from jest-presetup.js
13
- expect.hasAssertions = __noop;
14
- });
15
- afterAll(() => {
16
- expect.hasAssertions = origHasAssertions;
17
- });
18
-
19
- method();
20
- });
21
- };
22
-
23
- export const typescriptEslintTester = new ESLintUtils.RuleTester({
24
- parser: '@typescript-eslint/parser',
25
- parserOptions: {
26
- ecmaVersion: 2020,
27
- sourceType: 'module',
28
- ecmaFeatures: {
29
- jsx: true,
30
- },
31
- },
32
- });
33
-
34
- export const tester = new RuleTester({
35
- parser: require.resolve('@babel/eslint-parser'),
36
- parserOptions: {
37
- ecmaVersion: 6,
38
- sourceType: 'module',
39
- },
40
- });