@mui/internal-code-infra 0.1.1-canary.22 → 0.1.1-canary.24

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,4 +1,5 @@
1
1
  export * from './baseConfig.mjs';
2
2
  export * from './docsConfig.mjs';
3
+ export * from './nodeSupportConfig.mjs';
3
4
  export * from './testConfig.mjs';
4
5
  export * from './extensions.mjs';
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Reports syntax, ECMAScript built-ins and Node.js APIs in package sources that the Node.js
3
+ * versions allowed by the package's "engines.node" don't support. The ESM bundle is compiled for
4
+ * the "stable" browserslist environment rather than for "engines.node", and nothing polyfills
5
+ * built-ins, so all of them reach Node.js consumers as written.
6
+ * Only packages that declare "engines.node", meaning they're intended to run in Node.js, are
7
+ * checked.
8
+ * @param {string} baseDirectory - The repository root. File patterns are resolved against it.
9
+ * @returns {import('eslint').Linter.Config[]}
10
+ */
11
+ export declare function createNodeSupportConfig(baseDirectory: string): import('eslint').Linter.Config[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mui/internal-code-infra",
3
- "version": "0.1.1-canary.22",
3
+ "version": "0.1.1-canary.24",
4
4
  "author": "MUI Team",
5
5
  "description": "Infra scripts and configs to be used across MUI repos.",
6
6
  "license": "MIT",
@@ -67,23 +67,23 @@
67
67
  "@eslint/compat": "^2.1.1",
68
68
  "@eslint/js": "^10.0.1",
69
69
  "@eslint/json": "^2.1.1",
70
- "@inquirer/confirm": "^6.3.3",
71
- "@inquirer/select": "^5.2.6",
70
+ "@inquirer/confirm": "^6.3.4",
71
+ "@inquirer/select": "^5.2.7",
72
72
  "@mui/internal-babel-plugin-display-name": "2.0.1-canary.2",
73
73
  "@mui/internal-babel-plugin-minify-errors": "3.0.1-canary.2",
74
74
  "@mui/internal-babel-plugin-resolve-imports": "3.0.1-canary.3",
75
- "@napi-rs/keyring": "^2.1.1",
75
+ "@napi-rs/keyring": "^2.1.2",
76
76
  "@octokit/auth-action": "^6.0.3",
77
77
  "@octokit/oauth-methods": "^6.0.5",
78
78
  "@octokit/plugin-retry": "^8.1.1",
79
79
  "@octokit/plugin-throttling": "^11.0.5",
80
80
  "@octokit/rest": "^22.0.1",
81
- "@pnpm/config.version-policy": "^1100.2.8",
81
+ "@pnpm/config.version-policy": "^1100.2.9",
82
82
  "@pnpm/find-workspace-dir": "^1000.1.5",
83
83
  "@pnpm/parse-wanted-dependency": "^1001.0.0",
84
- "@typescript-eslint/types": "^8.71.2",
85
- "@typescript-eslint/utils": "^8.71.2",
86
- "@vitest/eslint-plugin": "^1.6.27",
84
+ "@typescript-eslint/types": "^8.72.0",
85
+ "@typescript-eslint/utils": "^8.72.0",
86
+ "@vitest/eslint-plugin": "^1.6.28",
87
87
  "babel-plugin-optimize-clsx": "^2.6.2",
88
88
  "babel-plugin-react-compiler": "^1.0.0",
89
89
  "babel-plugin-transform-import-meta": "^3.1.0",
@@ -100,19 +100,20 @@
100
100
  "eslint-plugin-compat": "^7.0.2",
101
101
  "eslint-plugin-import": "^2.32.0",
102
102
  "eslint-plugin-jsx-a11y": "^6.10.2",
103
- "eslint-plugin-mdx": "^3.8.1",
103
+ "eslint-plugin-mdx": "^3.8.2",
104
+ "eslint-plugin-n": "^18.5.0",
104
105
  "eslint-plugin-package-json": "^1.10.1",
105
106
  "eslint-plugin-react": "^7.37.5",
106
107
  "eslint-plugin-react-compiler": "^19.1.0-rc.2",
107
108
  "eslint-plugin-react-hooks": "^7.1.1",
108
109
  "eslint-plugin-testing-library": "^7.16.2",
109
- "execa": "^10.1.1",
110
+ "execa": "^10.2.0",
110
111
  "git-url-parse": "^16.1.0",
111
112
  "globals": "^17.13.0",
112
113
  "globby": "^16.2.4",
113
- "html-validate": "^11.16.2",
114
+ "html-validate": "^11.17.0",
114
115
  "minimatch": "^10.2.6",
115
- "node-html-parser": "^9.0.4",
116
+ "node-html-parser": "^9.0.5",
116
117
  "open": "^11.0.4",
117
118
  "postcss-styled-syntax": "^0.7.4",
118
119
  "regexp.escape": "^2.0.1",
@@ -137,7 +138,7 @@
137
138
  "resolve-pkg-maps": "^1.0.0",
138
139
  "semver": "^7.8.5",
139
140
  "stylelint-config-standard": "^40.0.0",
140
- "typescript-eslint": "^8.71.2",
141
+ "typescript-eslint": "^8.72.0",
141
142
  "unified": "^11.0.5",
142
143
  "unified-lint-rule": "^3.0.1",
143
144
  "unist-util-visit": "^5.1.0",
@@ -166,10 +167,10 @@
166
167
  "@types/mdast": "4.0.4",
167
168
  "@types/regexp.escape": "2.0.0",
168
169
  "@types/yargs": "17.0.35",
169
- "@typescript-eslint/parser": "8.71.2",
170
- "@typescript-eslint/rule-tester": "8.71.2",
170
+ "@typescript-eslint/parser": "8.72.0",
171
+ "@typescript-eslint/rule-tester": "8.72.0",
171
172
  "@typescript/native": "npm:typescript@7.0.2",
172
- "eslint": "10.12.0",
173
+ "eslint": "10.13.0",
173
174
  "get-port": "7.2.0",
174
175
  "prettier": "3.9.10",
175
176
  "remark": "15.0.1",
@@ -190,7 +191,7 @@
190
191
  "publishConfig": {
191
192
  "access": "public"
192
193
  },
193
- "gitSha": "7be938414716e74df30e861271c65d7885da8c98",
194
+ "gitSha": "d14c1ec7e620c0bf10d09090e718ff376a8a190d",
194
195
  "scripts": {
195
196
  "build": "tsc -p tsconfig.build.json",
196
197
  "typescript": "tsc -noEmit",
@@ -3,6 +3,7 @@ import eslintJs from '@eslint/js';
3
3
  import { defineConfig } from 'eslint/config';
4
4
  import prettier from 'eslint-config-prettier/flat';
5
5
  import compatPlugin from 'eslint-plugin-compat';
6
+ import nPlugin from 'eslint-plugin-n';
6
7
  import importPlugin from 'eslint-plugin-import';
7
8
  import jsxA11yPlugin from 'eslint-plugin-jsx-a11y';
8
9
  import reactPlugin from 'eslint-plugin-react';
@@ -17,6 +18,7 @@ import { createCoreConfig } from './mui/config.mjs';
17
18
  import muiPlugin from './mui/index.mjs';
18
19
  import { EXTENSION_TS } from './extensions.mjs';
19
20
  import { createJsonConfig } from './jsonConfig.mjs';
21
+ import { createNodeSupportConfig } from './nodeSupportConfig.mjs';
20
22
  import { createPackageJsonConfig } from './packageJsonConfig.mjs';
21
23
 
22
24
  /**
@@ -59,6 +61,9 @@ export function createBaseConfig({
59
61
  },
60
62
  plugins: {
61
63
  mui: muiPlugin,
64
+ // Registered once for all files, so consumers can enable `n/*` rules without registering
65
+ // a second, possibly different, instance of the plugin.
66
+ n: nPlugin,
62
67
  },
63
68
  settings: {
64
69
  react: {
@@ -74,6 +79,7 @@ export function createBaseConfig({
74
79
  includeIgnoreIfExists(path.join(baseDirectory, '.gitignore'), `Ignore rules from .gitignore`),
75
80
  includeIgnoreIfExists(path.join(baseDirectory, '.lintignore'), `Ignore rules from .lintignore`),
76
81
  createJsonConfig(),
82
+ createNodeSupportConfig(baseDirectory),
77
83
  createPackageJsonConfig(),
78
84
  prettier,
79
85
  // Markdown + MDX linting via eslint-plugin-mdx. Severities for markdown
@@ -3,5 +3,6 @@
3
3
 
4
4
  export * from './baseConfig.mjs';
5
5
  export * from './docsConfig.mjs';
6
+ export * from './nodeSupportConfig.mjs';
6
7
  export * from './testConfig.mjs';
7
8
  export * from './extensions.mjs';
@@ -0,0 +1,70 @@
1
+ import * as fs from 'node:fs';
2
+ import * as path from 'node:path';
3
+ import { defineConfig } from 'eslint/config';
4
+ import nPlugin from 'eslint-plugin-n';
5
+ import { globbySync } from 'globby';
6
+ import { EXTENSION_TEST_FILE, EXTENSION_TS } from './extensions.mjs';
7
+
8
+ /**
9
+ * Finds the packages in the `packages*` directories of the repository that declare the Node.js
10
+ * versions they support in "engines.node". Packages without it, like development tooling, run
11
+ * on the repository's own Node.js version.
12
+ * @param {string} baseDirectory
13
+ * @returns {string[]} Package directories, relative to `baseDirectory`.
14
+ */
15
+ function findPackageDirsWithEnginesNode(baseDirectory) {
16
+ return globbySync('packages*/*/package.json', { cwd: baseDirectory })
17
+ .filter((packageJsonPath) => {
18
+ const packageJson = JSON.parse(
19
+ fs.readFileSync(path.join(baseDirectory, packageJsonPath), 'utf8'),
20
+ );
21
+ return typeof packageJson.engines?.node === 'string';
22
+ })
23
+ .map((packageJsonPath) => path.posix.dirname(packageJsonPath));
24
+ }
25
+
26
+ /**
27
+ * Reports syntax, ECMAScript built-ins and Node.js APIs in package sources that the Node.js
28
+ * versions allowed by the package's "engines.node" don't support. The ESM bundle is compiled for
29
+ * the "stable" browserslist environment rather than for "engines.node", and nothing polyfills
30
+ * built-ins, so all of them reach Node.js consumers as written.
31
+ * Only packages that declare "engines.node", meaning they're intended to run in Node.js, are
32
+ * checked.
33
+ * @param {string} baseDirectory - The repository root. File patterns are resolved against it.
34
+ * @returns {import('eslint').Linter.Config[]}
35
+ */
36
+ export function createNodeSupportConfig(baseDirectory) {
37
+ const packageDirs = findPackageDirsWithEnginesNode(baseDirectory);
38
+ if (packageDirs.length === 0) {
39
+ return [];
40
+ }
41
+ return defineConfig([
42
+ {
43
+ name: 'Node.js support of package sources',
44
+ basePath: baseDirectory,
45
+ files: packageDirs.map((packageDir) => `${packageDir}/src/**/*${EXTENSION_TS}`),
46
+ ignores: [`**/*${EXTENSION_TEST_FILE}`, `**/*.spec${EXTENSION_TS}`],
47
+ plugins: { n: nPlugin },
48
+ rules: {
49
+ 'n/no-unsupported-features/es-builtins': 'error',
50
+ 'n/no-unsupported-features/es-syntax': 'error',
51
+ 'n/no-unsupported-features/node-builtins': [
52
+ 'error',
53
+ // Browser APIs that Node.js also exposes, behind an experimental flag. In packages that
54
+ // combine Node.js tooling with browser code, these refer to the browser API.
55
+ {
56
+ ignores: [
57
+ 'localStorage',
58
+ 'sessionStorage',
59
+ 'Storage',
60
+ 'navigator',
61
+ 'Navigator',
62
+ 'Worker',
63
+ 'ErrorEvent',
64
+ ],
65
+ },
66
+ ],
67
+ },
68
+ },
69
+ ]);
70
+ }