@atlaskit/eslint-plugin-platform 2.6.0 → 2.7.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 (119) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/cjs/index.js +4 -3
  3. package/dist/cjs/rules/ensure-critical-dependency-resolutions/index.js +2 -2
  4. package/dist/cjs/rules/ensure-native-and-af-exports-synced/index.js +3 -0
  5. package/dist/cjs/rules/feature-gating/no-alias/index.js +1 -1
  6. package/dist/cjs/rules/no-direct-document-usage/index.js +1 -1
  7. package/dist/cjs/rules/no-set-immediate/index.js +39 -0
  8. package/dist/cjs/rules/util/context-compat.js +4 -2
  9. package/dist/es2019/index.js +4 -3
  10. package/dist/es2019/rules/ensure-critical-dependency-resolutions/index.js +2 -2
  11. package/dist/es2019/rules/ensure-native-and-af-exports-synced/index.js +3 -0
  12. package/dist/es2019/rules/feature-gating/no-alias/index.js +1 -1
  13. package/dist/es2019/rules/no-direct-document-usage/index.js +1 -1
  14. package/dist/es2019/rules/no-set-immediate/index.js +33 -0
  15. package/dist/es2019/rules/util/context-compat.js +4 -2
  16. package/dist/esm/index.js +4 -3
  17. package/dist/esm/rules/ensure-critical-dependency-resolutions/index.js +2 -2
  18. package/dist/esm/rules/ensure-native-and-af-exports-synced/index.js +3 -0
  19. package/dist/esm/rules/feature-gating/no-alias/index.js +1 -1
  20. package/dist/esm/rules/no-direct-document-usage/index.js +1 -1
  21. package/dist/esm/rules/no-set-immediate/index.js +33 -0
  22. package/dist/esm/rules/util/context-compat.js +4 -2
  23. package/dist/types/index.d.ts +14 -6
  24. package/dist/types/rules/util/handle-ast-object.d.ts +1 -1
  25. package/dist/types-ts4.5/index.d.ts +14 -6
  26. package/dist/types-ts4.5/rules/util/handle-ast-object.d.ts +1 -1
  27. package/package.json +2 -2
  28. package/afm-cc/tsconfig.json +0 -24
  29. package/afm-jira/tsconfig.json +0 -24
  30. package/build/tsconfig.json +0 -17
  31. package/dist/cjs/rules/ensure-valid-platform-yarn-protocol-usage/index.js +0 -79
  32. package/dist/es2019/rules/ensure-valid-platform-yarn-protocol-usage/index.js +0 -62
  33. package/dist/esm/rules/ensure-valid-platform-yarn-protocol-usage/index.js +0 -75
  34. package/src/__tests__/utils/_tester.tsx +0 -26
  35. package/src/index.tsx +0 -251
  36. package/src/rules/compiled/README.md +0 -3
  37. package/src/rules/compiled/expand-background-shorthand/README.md +0 -23
  38. package/src/rules/compiled/expand-background-shorthand/__tests__/rule.test.ts +0 -160
  39. package/src/rules/compiled/expand-background-shorthand/index.tsx +0 -43
  40. package/src/rules/compiled/expand-border-shorthand/README.md +0 -51
  41. package/src/rules/compiled/expand-border-shorthand/__tests__/rule.test.ts +0 -211
  42. package/src/rules/compiled/expand-border-shorthand/index.ts +0 -103
  43. package/src/rules/compiled/expand-spacing-shorthand/README.md +0 -38
  44. package/src/rules/compiled/expand-spacing-shorthand/__tests__/rule.test.ts +0 -448
  45. package/src/rules/compiled/expand-spacing-shorthand/index.ts +0 -240
  46. package/src/rules/constants.tsx +0 -20
  47. package/src/rules/ensure-atlassian-team/__tests__/unit/rule.test.ts +0 -24
  48. package/src/rules/ensure-atlassian-team/index.ts +0 -51
  49. package/src/rules/ensure-critical-dependency-resolutions/__test__/unit/rule.test.tsx +0 -200
  50. package/src/rules/ensure-critical-dependency-resolutions/index.tsx +0 -172
  51. package/src/rules/ensure-feature-flag-prefix/__tests__/unit/rule.test.tsx +0 -65
  52. package/src/rules/ensure-feature-flag-prefix/index.tsx +0 -81
  53. package/src/rules/ensure-feature-flag-registration/__tests__/unit/rule.test.tsx +0 -115
  54. package/src/rules/ensure-feature-flag-registration/index.tsx +0 -106
  55. package/src/rules/ensure-native-and-af-exports-synced/__tests__/unit/rule.test.tsx +0 -199
  56. package/src/rules/ensure-native-and-af-exports-synced/index.tsx +0 -188
  57. package/src/rules/ensure-no-private-dependencies/__tests__/unit/rule.test.ts +0 -212
  58. package/src/rules/ensure-no-private-dependencies/index.ts +0 -64
  59. package/src/rules/ensure-publish-valid/__tests__/unit/rule.test.ts +0 -39
  60. package/src/rules/ensure-publish-valid/index.ts +0 -81
  61. package/src/rules/ensure-test-runner-arguments/__tests__/unit/rule.test.tsx +0 -298
  62. package/src/rules/ensure-test-runner-arguments/index.tsx +0 -121
  63. package/src/rules/ensure-test-runner-nested-count/__tests__/unit/rule.test.tsx +0 -308
  64. package/src/rules/ensure-test-runner-nested-count/index.tsx +0 -82
  65. package/src/rules/ensure-valid-bin-values/__tests__/unit/rule.test.ts +0 -159
  66. package/src/rules/ensure-valid-bin-values/index.ts +0 -70
  67. package/src/rules/ensure-valid-platform-yarn-protocol-usage/__tests__/unit/rule.test.ts +0 -147
  68. package/src/rules/ensure-valid-platform-yarn-protocol-usage/index.ts +0 -67
  69. package/src/rules/feature-gating/README.md +0 -8
  70. package/src/rules/feature-gating/inline-usage/README.md +0 -53
  71. package/src/rules/feature-gating/inline-usage/__tests__/rule.test.tsx +0 -106
  72. package/src/rules/feature-gating/inline-usage/index.tsx +0 -135
  73. package/src/rules/feature-gating/no-alias/README.md +0 -29
  74. package/src/rules/feature-gating/no-alias/__tests__/rule.test.tsx +0 -76
  75. package/src/rules/feature-gating/no-alias/index.tsx +0 -80
  76. package/src/rules/feature-gating/no-module-level-eval/README.md +0 -53
  77. package/src/rules/feature-gating/no-module-level-eval/__tests__/test.tsx +0 -133
  78. package/src/rules/feature-gating/no-module-level-eval/index.tsx +0 -54
  79. package/src/rules/feature-gating/no-module-level-eval-nav4/README.md +0 -8
  80. package/src/rules/feature-gating/no-module-level-eval-nav4/__tests__/test.tsx +0 -130
  81. package/src/rules/feature-gating/no-module-level-eval-nav4/index.tsx +0 -73
  82. package/src/rules/feature-gating/no-preconditioning/README.md +0 -69
  83. package/src/rules/feature-gating/no-preconditioning/__tests__/rule.test.tsx +0 -164
  84. package/src/rules/feature-gating/no-preconditioning/index.tsx +0 -138
  85. package/src/rules/feature-gating/prefer-fg/README.md +0 -3
  86. package/src/rules/feature-gating/prefer-fg/__tests__/rule.test.tsx +0 -83
  87. package/src/rules/feature-gating/prefer-fg/index.tsx +0 -110
  88. package/src/rules/feature-gating/static-feature-flags/README.md +0 -3
  89. package/src/rules/feature-gating/static-feature-flags/__tests__/test.tsx +0 -135
  90. package/src/rules/feature-gating/static-feature-flags/index.tsx +0 -103
  91. package/src/rules/feature-gating/use-recommended-utils/README.md +0 -67
  92. package/src/rules/feature-gating/use-recommended-utils/__tests__/rule.test.tsx +0 -78
  93. package/src/rules/feature-gating/use-recommended-utils/index.tsx +0 -57
  94. package/src/rules/feature-gating/utils.tsx +0 -48
  95. package/src/rules/no-direct-document-usage/index.tsx +0 -109
  96. package/src/rules/no-duplicate-dependencies/__tests__/unit/rule.test.ts +0 -116
  97. package/src/rules/no-duplicate-dependencies/index.ts +0 -79
  98. package/src/rules/no-invalid-feature-flag-usage/__tests__/unit/rule.test.tsx +0 -69
  99. package/src/rules/no-invalid-feature-flag-usage/index.tsx +0 -128
  100. package/src/rules/no-invalid-storybook-decorator-usage/__tests__/unit/rule.test.tsx +0 -18
  101. package/src/rules/no-invalid-storybook-decorator-usage/index.tsx +0 -39
  102. package/src/rules/no-pre-post-installs/__tests__/unit/rule.test.ts +0 -41
  103. package/src/rules/no-pre-post-installs/index.ts +0 -35
  104. package/src/rules/no-sparse-checkout/__tests__/unit/rule.test.tsx +0 -48
  105. package/src/rules/no-sparse-checkout/index.tsx +0 -54
  106. package/src/rules/use-entrypoints-in-examples/README.md +0 -27
  107. package/src/rules/use-entrypoints-in-examples/__tests__/rule.test.tsx +0 -34
  108. package/src/rules/use-entrypoints-in-examples/index.tsx +0 -43
  109. package/src/rules/util/__tests__/context-compat.test.ts +0 -122
  110. package/src/rules/util/compiled-utils.ts +0 -27
  111. package/src/rules/util/context-compat.ts +0 -41
  112. package/src/rules/util/file-exclusions.ts +0 -39
  113. package/src/rules/util/handle-ast-object.ts +0 -33
  114. package/src/rules/util/registration-utils.ts +0 -59
  115. package/tsconfig.app.json +0 -43
  116. package/tsconfig.dev.json +0 -40
  117. package/tsconfig.json +0 -23
  118. /package/dist/types/rules/{ensure-valid-platform-yarn-protocol-usage → no-set-immediate}/index.d.ts +0 -0
  119. /package/dist/types-ts4.5/rules/{ensure-valid-platform-yarn-protocol-usage → no-set-immediate}/index.d.ts +0 -0
@@ -1,41 +0,0 @@
1
- import type { Rule, Scope, SourceCode } from 'eslint';
2
- import type { Node } from 'estree';
3
-
4
- /**
5
- * TODO: Consider whether this should be replaced by ESLint's compat library.
6
- * Either way, this should be removed once we no longer need to support ESLint versions less than 8.40.
7
- */
8
-
9
- /**
10
- * A compatibility layer to support older versions of ESLint.
11
- * `context.sourceCode` is the preferred way to access SourceCode, as
12
- * `context.getSourceCode()` is deprecated in v8 and removed in v9.
13
- * @param context - The ESLint rule context
14
- */
15
- export const getSourceCode = (context: Rule.RuleContext): SourceCode => {
16
- return context.sourceCode ?? context.getSourceCode();
17
- };
18
-
19
- /**
20
- * A compatibility layer to support older versions of ESLint.
21
- * `context.sourceCode.getScope()` is the preferred way to access Scope, as
22
- * `context.getScope()` was removed in v9.
23
- * https://eslint.org/blog/2023/09/preparing-custom-rules-eslint-v9/#context.getscope()
24
- * @param context - The ESLint rule context
25
- * @param node - The node to get the scope for
26
- */
27
- export const getScope = (context: Rule.RuleContext, node: Node): Scope.Scope => {
28
- return getSourceCode(context)?.getScope?.(node) ?? context.getScope();
29
- };
30
-
31
- /**
32
- * A compatibility layer to support older versions of ESLint.
33
- * `context.sourceCode.getAncestors()` is the preferred way to access Ancestors, as
34
- * `context.getScope()` was removed in v9.
35
- * https://eslint.org/blog/2023/09/preparing-custom-rules-eslint-v9/#context.getancestors()
36
- * @param context - The ESLint rule context
37
- * @param node - The node to get the scope for
38
- */
39
- export const getAncestors = (context: Rule.RuleContext, node: Node): Node[] => {
40
- return getSourceCode(context)?.getAncestors?.(node) ?? context.getAncestors();
41
- };
@@ -1,39 +0,0 @@
1
- import type { Rule } from 'eslint';
2
-
3
- /**
4
- * Common patterns for test files that should be excluded from rules
5
- */
6
- const TEST_FILE_PATTERNS = ['__tests__', 'test', 'spec'] as const;
7
-
8
- /**
9
- * Checks if a file should be excluded from rules based on test file patterns
10
- * @param filename The filename to check
11
- * @returns true if the file should be excluded, false otherwise
12
- */
13
- const isTestFile = (filename: string): boolean => {
14
- return TEST_FILE_PATTERNS.some((pattern) => filename.includes(pattern));
15
- };
16
-
17
- /**
18
- * Helper function to skip rules for test files
19
- * @param context The ESLint rule context
20
- * @returns An empty RuleListener if the file is a test file, undefined otherwise
21
- */
22
- export const skipForTestFiles = (context: Rule.RuleContext): Rule.RuleListener | undefined => {
23
- if (isTestFile(context.filename)) {
24
- return {};
25
- }
26
- return undefined;
27
- };
28
-
29
- /**
30
- * Helper function to skip rules for example files
31
- * @param context The ESLint rule context
32
- * @returns An empty RuleListener if the file is an example file, undefined otherwise
33
- */
34
- export const skipForExampleFiles = (context: Rule.RuleContext): Rule.RuleListener | undefined => {
35
- if (context.filename.includes('example')) {
36
- return {};
37
- }
38
- return undefined;
39
- };
@@ -1,33 +0,0 @@
1
- import type { ObjectExpression, SimpleLiteral, RegExpLiteral, BigIntLiteral } from 'estree';
2
-
3
- export const getObjectPropertyAsLiteral = (
4
- node: ObjectExpression,
5
- property: string,
6
- ): SimpleLiteral['value'] | RegExpLiteral['value'] | BigIntLiteral['value'] => {
7
- const prop = node.properties.find(
8
- (p) => p.type === 'Property' && p.key.type === 'Literal' && p.key.value === property,
9
- );
10
-
11
- // double check for property is to make typescript happy
12
- if (prop?.type === 'Property' && prop?.value.type === 'Literal') {
13
- return prop.value.value ?? null;
14
- }
15
-
16
- return null;
17
- };
18
-
19
- export const getObjectPropertyAsObject = (
20
- node: ObjectExpression,
21
- property: string,
22
- ): ObjectExpression | null => {
23
- const prop = node.properties.find(
24
- (p) => p.type === 'Property' && p.key.type === 'Literal' && p.key.value === property,
25
- );
26
-
27
- // double check for property is to make typescript happy
28
- if (prop?.type === 'Property' && prop?.value.type === 'ObjectExpression') {
29
- return prop.value ?? null;
30
- }
31
-
32
- return null;
33
- };
@@ -1,59 +0,0 @@
1
- import readPkgUp from 'read-pkg-up';
2
- import path from 'path';
3
- import Fuse from 'fuse.js';
4
-
5
- // defines a "getter" to "type" map, if more types are required for feature flags (like string) add it here!
6
- // if you don't want to verify the type use `null` as the value
7
- export const getterIdentifierToFlagTypeMap = {
8
- getBooleanFF: 'boolean' as const,
9
- ffTest: 'boolean' as const,
10
- fg: 'boolean' as const,
11
- } as const;
12
-
13
- export type PlatformFeatureFlagRegistrationSection = {
14
- [key: string]: {
15
- // get the values of the object above
16
- type: (typeof getterIdentifierToFlagTypeMap)[keyof typeof getterIdentifierToFlagTypeMap];
17
- };
18
- };
19
-
20
- export type EnhancedPackageJson = readPkgUp.PackageJson & {
21
- 'platform-feature-flags'?: PlatformFeatureFlagRegistrationSection;
22
- };
23
-
24
- export type PkgJsonMetaData = {
25
- pkgJson: EnhancedPackageJson;
26
- fuse: Fuse<string> | null;
27
- };
28
- // make sure we cache reading the package.json so we don't end up reading it for every instance of this rule.
29
- const pkgJsonCache = new Map<string, PkgJsonMetaData>();
30
- // get the ancestor package.json for a given file
31
- export const getMetadataForFilename = (filename: string): PkgJsonMetaData => {
32
- const splitFilename = filename.split(path.sep);
33
- for (let i = 0; i < splitFilename.length; i++) {
34
- // attempt to search using the filename in the cache to see if we've read the package.json for a sibling file before
35
- const searchPath = path.join(...splitFilename.splice(0, i));
36
- const cachedMetaData = pkgJsonCache.get(searchPath);
37
-
38
- if (cachedMetaData) {
39
- return cachedMetaData;
40
- }
41
- }
42
-
43
- const { packageJson, path: pkgJsonPath } = readPkgUp.sync({
44
- cwd: filename,
45
- normalize: false,
46
- })!;
47
-
48
- const pkgJson = packageJson as EnhancedPackageJson;
49
-
50
- const fuse =
51
- packageJson['platform-feature-flags'] == null
52
- ? null
53
- : new Fuse(Object.keys(pkgJson['platform-feature-flags']!));
54
-
55
- const metaData = { pkgJson, fuse };
56
-
57
- pkgJsonCache.set(pkgJsonPath, metaData);
58
- return metaData;
59
- };
package/tsconfig.app.json DELETED
@@ -1,43 +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
- "lib": ["ES2021.String"],
31
- "composite": true,
32
- "outDir": "../../../tsDist/@atlaskit__eslint-plugin-platform/app"
33
- },
34
- "references": [
35
- {
36
- "path": "../../design-system/eslint-utils/tsconfig.app.json"
37
- },
38
- {
39
- "path": "../../monorepo-tooling/ts-loader/tsconfig.app.json"
40
- }
41
- ],
42
- "files": []
43
- }
package/tsconfig.dev.json DELETED
@@ -1,40 +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
- ],
28
- "exclude": ["./dist/**/*", "./build/**/*", "./node_modules/**/*"],
29
- "compilerOptions": {
30
- "lib": ["ES2021.String"],
31
- "composite": true,
32
- "outDir": "../../../tsDist/@atlaskit__eslint-plugin-platform/dev"
33
- },
34
- "references": [
35
- {
36
- "path": "./tsconfig.app.json"
37
- }
38
- ],
39
- "files": []
40
- }
package/tsconfig.json DELETED
@@ -1,23 +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
- "compilerOptions": {
15
- "lib": ["ES2021.String"]
16
- },
17
- "ts-node": {
18
- // It is faster to skip typechecking.
19
- "transpileOnly": true,
20
- // We must load files for third party defs - https://typestrong.org/ts-node/docs/types
21
- "files": true,
22
- }
23
- }