@arcgis/eslint-config 5.2.0-next.0 → 5.2.0-next.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.
@@ -1,10 +1,3 @@
1
- /**
2
- * While the main index.js config strives to be comprehensive, this config
3
- * disables rules that are less important for applications compared to libraries.
4
- */
5
- declare const _default: (import('eslint/config').Config | {
6
- files: string[];
7
- name?: string;
8
- rules?: object;
9
- })[];
1
+ import { TSESLint } from '@typescript-eslint/utils';
2
+ declare const _default: TSESLint.FlatConfig.Config[];
10
3
  export default _default;
@@ -1,6 +1,6 @@
1
- import defaultConfig from "./index.js";
1
+ import config from "./index.js";
2
2
  const applications = [
3
- ...defaultConfig,
3
+ ...config,
4
4
  {
5
5
  rules: {
6
6
  // Not autofixable. Can be annoying
@@ -1,23 +1,3 @@
1
- /**
2
- * See setup documentation & rationale behind ESLint:
3
- * https://webgis.esri.com/references/support-packages/eslint
4
- *
5
- * Some advice on editing rules:
6
- * - prioritize autofixable rules to make adoption in existing codebases easier
7
- * - disable redundant rules (rules redundant with TypeScript, or each other),
8
- * to reduce noise and performance impact
9
- * - if rule is always auto-fixable, it may be a good idea to emit it as a
10
- * warning instead of an error to be less disruptive when the developer is
11
- * typing code
12
- * - emit rules that have a lot of false positives as warnings instead of errors
13
- * - provide justification for enabling opinionated rules
14
- * - provide justification for disabling default rules
15
- * - if rule is disabled because it's buggy, describe how so
16
- * (code sample, GitHub issue, permalink to file, etc)
17
- */
18
- declare const _default: (import('eslint/config').Config | {
19
- files: string[];
20
- name?: string;
21
- rules?: object;
22
- })[];
23
- export default _default;
1
+ import { TSESLint } from '@typescript-eslint/utils';
2
+ declare const config: TSESLint.FlatConfig.ConfigArray;
3
+ export default config;
@@ -6,23 +6,25 @@ import { webgisPlugin } from "../plugins/webgis/index.js";
6
6
  import { globalIgnores } from "eslint/config";
7
7
  import markdown from "@eslint/markdown";
8
8
  import packageJson from "eslint-plugin-package-json";
9
+ import { importX } from "eslint-plugin-import-x";
9
10
  const packageJsonSortableCollections = packageJson.rules["sort-collections"].meta.defaultOptions[0].filter(
10
11
  (collection) => !["scripts", "exports"].includes(collection)
11
12
  ) ?? [];
12
- const defaultConfig = [
13
+ const config = [
13
14
  globalIgnores(["**/www", "**/dist", "**/assets", "**/coverage", "**/.docs"]),
14
15
  {
15
16
  files: ["**/*.js", "**/*.mjs", "**/*.cjs"],
16
17
  ...eslint.configs.recommended
17
18
  },
18
- ...[...tsEslint.configs.strictTypeChecked, ...tsEslint.configs.stylisticTypeChecked].map((config) => ({
19
- ...config,
19
+ ...[...tsEslint.configs.strictTypeChecked, ...tsEslint.configs.stylisticTypeChecked].map((config2) => ({
20
+ ...config2,
20
21
  files: ["**/*.ts", "**/*.tsx"]
21
22
  })),
22
23
  {
23
24
  ...webgisPlugin.configs.recommended,
24
25
  files: ["**/*.ts", "**/*.tsx"]
25
26
  },
27
+ importX.flatConfigs.typescript,
26
28
  {
27
29
  files: ["**/*.ts", "**/*.tsx"],
28
30
  linterOptions: {
@@ -653,5 +655,5 @@ const defaultConfig = [
653
655
  }
654
656
  ];
655
657
  export {
656
- defaultConfig as default
658
+ config as default
657
659
  };
@@ -1,5 +1,5 @@
1
1
  import { ESLintUtils, AST_NODE_TYPES } from "@typescript-eslint/utils";
2
- const version = "5.2.0-next.0";
2
+ const version = "5.2.0-next.1";
3
3
  const packageJson = {
4
4
  version
5
5
  };
@@ -1,4 +1,4 @@
1
- import { m as makeEslintPlugin, l as luminaJsxExportName, a as luminaEntrypointName, b as luminaTestEntrypointName, s as sourceCodeDeclaresComponent, p as parsePropertyDecorator, c as getProperty, i as isGetterWithoutSetter, e as extractDeclareElementsInterface, d as isCreateEvent, h as hasDecorator, f as getName, j as checkForLuminaJsx, k as isBindThisCallee, g as getComponentDeclaration, u as unwrapExpression } from "../../estree-D4NC8KvY.js";
1
+ import { m as makeEslintPlugin, l as luminaJsxExportName, a as luminaEntrypointName, b as luminaTestEntrypointName, s as sourceCodeDeclaresComponent, p as parsePropertyDecorator, c as getProperty, i as isGetterWithoutSetter, e as extractDeclareElementsInterface, d as isCreateEvent, h as hasDecorator, f as getName, j as checkForLuminaJsx, k as isBindThisCallee, g as getComponentDeclaration, u as unwrapExpression } from "../../estree-CqRqIhAW.js";
2
2
  import { AST_NODE_TYPES, ESLintUtils, AST_TOKEN_TYPES } from "@typescript-eslint/utils";
3
3
  import ts from "typescript";
4
4
  import { camelToKebab } from "@arcgis/toolkit/string";
@@ -1,4 +1,4 @@
1
- import { m as makeEslintPlugin, e as extractDeclareElementsInterface, g as getComponentDeclaration } from "../../estree-D4NC8KvY.js";
1
+ import { m as makeEslintPlugin, e as extractDeclareElementsInterface, g as getComponentDeclaration } from "../../estree-CqRqIhAW.js";
2
2
  import { resolve } from "path/posix";
3
3
  import { AST_NODE_TYPES } from "@typescript-eslint/utils";
4
4
  const plugin = makeEslintPlugin(
@@ -0,0 +1,44 @@
1
+ import { TSESLint } from '@typescript-eslint/utils';
2
+ /**
3
+ * Restrict which parts of the package can import what packages.
4
+ *
5
+ * @public
6
+ */
7
+ export interface Boundaries<BoundaryNames extends string, DependencyNames extends string> {
8
+ /**
9
+ * List all dependencies that may be imported in src/.
10
+ *
11
+ * @public
12
+ */
13
+ dependencyNames: readonly DependencyNames[];
14
+ /**
15
+ * Define the boundaries within the package and their allowed dependencies.
16
+ * Boundary name must start with `./` and be a path relative to the src/ folder.
17
+ * For example, `./components`
18
+ *
19
+ * @public
20
+ */
21
+ boundaries: Record<BoundaryNames, Boundary<BoundaryNames, DependencyNames>>;
22
+ }
23
+ /** @public */
24
+ export type Boundary<BoundaryNames extends string, DependencyNames extends string> = {
25
+ /**
26
+ * Dependencies this boundary may import.
27
+ *
28
+ * @public
29
+ */
30
+ allowedDependencies: readonly DependencyNames[];
31
+ /**
32
+ * Boundaries this boundary may import.
33
+ *
34
+ * @public
35
+ */
36
+ allowedBoundaries: readonly BoundaryNames[];
37
+ };
38
+ /**
39
+ * @param boundaries
40
+ * @param monorepoRoot
41
+ * @param basePath example: "packages/ai-packages/ai-components/src"
42
+ * @public
43
+ */
44
+ export declare function boundariesToEslintRules(boundaries: Boundaries<string, string>, monorepoRoot: string, basePath: string, message: string): TSESLint.FlatConfig.Config[];
@@ -0,0 +1,50 @@
1
+ function boundariesToEslintRules(boundaries, monorepoRoot, basePath, message) {
2
+ const boundaryNames = Object.keys(boundaries.boundaries);
3
+ const boundaryEntries = Object.entries(boundaries.boundaries);
4
+ return [
5
+ {
6
+ files: [`${basePath}/**/*.+(ts|tsx)`],
7
+ rules: {
8
+ "import-x/no-restricted-paths": [
9
+ "error",
10
+ {
11
+ basePath: `${monorepoRoot}${basePath}`,
12
+ zones: boundaryEntries.flatMap(
13
+ ([boundaryName, boundary]) => boundaryNames.filter((name) => name !== boundaryName && !boundary.allowedBoundaries.includes(name)).map((targetBoundary) => ({
14
+ from: targetBoundary,
15
+ target: boundaryName,
16
+ message
17
+ }))
18
+ )
19
+ }
20
+ ]
21
+ }
22
+ },
23
+ ...boundaryEntries.flatMap(([boundaryName, boundary]) => {
24
+ const blockedDependencies = boundaries.dependencyNames.filter(
25
+ (dependency) => !boundary.allowedDependencies.includes(dependency)
26
+ );
27
+ return blockedDependencies.length === 0 ? [] : [
28
+ {
29
+ files: [`${basePath}/${boundaryName.slice(2)}/**/*.+(ts|tsx)`],
30
+ rules: {
31
+ "@typescript-eslint/no-restricted-imports": [
32
+ "error",
33
+ {
34
+ patterns: [
35
+ {
36
+ group: blockedDependencies.map((dependency) => `/${dependency}`),
37
+ message
38
+ }
39
+ ]
40
+ }
41
+ ]
42
+ }
43
+ }
44
+ ];
45
+ })
46
+ ];
47
+ }
48
+ export {
49
+ boundariesToEslintRules
50
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcgis/eslint-config",
3
- "version": "5.2.0-next.0",
3
+ "version": "5.2.0-next.1",
4
4
  "description": "ESLint configuration for WebGIS SDK",
5
5
  "type": "module",
6
6
  "exports": {
@@ -10,7 +10,8 @@
10
10
  "./lumina": "./dist/config/lumina.js",
11
11
  "./plugins/webgis": "./dist/plugins/webgis/index.js",
12
12
  "./plugins/lumina": "./dist/plugins/lumina/index.js",
13
- "./utils/disable-rules": "./dist/utils/disable-rules.js",
13
+ "./utils/defineBoundaries": "./dist/utils/defineBoundaries.js",
14
+ "./utils/disableRules": "./dist/utils/disableRules.js",
14
15
  "./package.json": "./package.json"
15
16
  },
16
17
  "files": [
@@ -23,6 +24,8 @@
23
24
  "@types/confusing-browser-globals": "^1.0.3",
24
25
  "@typescript-eslint/utils": "^8.58.0",
25
26
  "confusing-browser-globals": "^1.0.11",
27
+ "eslint-import-resolver-typescript": "^4.4.4",
28
+ "eslint-plugin-import-x": "^4.16.2",
26
29
  "eslint-plugin-package-json": "~0.91.1",
27
30
  "eslint-plugin-storybook": "^10.3.4",
28
31
  "globals": "^16.5.0",
@@ -30,7 +33,7 @@
30
33
  "tslib": "^2.8.1",
31
34
  "typescript": "~6.0.2",
32
35
  "typescript-eslint": "^8.58.0",
33
- "@arcgis/toolkit": "5.2.0-next.0"
36
+ "@arcgis/toolkit": "5.2.0-next.1"
34
37
  },
35
38
  "peerDependencies": {
36
39
  "eslint": "^10.2.0"