oxlint-plugin-stamhoofd 2.157.1 → 2.160.0

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.
package/LICENSE.md CHANGED
@@ -5,25 +5,25 @@ Copyright 2020 Codawood BV
5
5
  Permission is hereby granted, free of charge, to any non-profit organization with fewer than 2,000 members (each, a “Licensee”), to use this software and associated documentation files (the “Software”), subject to the following conditions:
6
6
 
7
7
  1. Eligibility:
8
- This license applies only if neither the Licensee nor, if applicable, its parent or umbrella organization, is already subject to an existing license for this project. For the purposes of this license, a “parent or umbrella organization” means any organization with which the Licensee is affiliated, coordinated, or represented as part of a larger collective, including but not limited to national associations or federations.
8
+ This license applies only if neither the Licensee nor, if applicable, its parent or umbrella organization, is already subject to an existing license for this project. For the purposes of this license, a “parent or umbrella organization” means any organization with which the Licensee is affiliated, coordinated, or represented as part of a larger collective, including but not limited to national associations or federations.
9
9
 
10
10
  2. Modifications:
11
- Modifications to the Software are permitted only if they are published publicly under the MIT License, covering only the modifications; the original Software remains under this license and may not be sublicensed without a separate agreement. Any modification made by a Licensee (other than modifications by the original author, its representatives, or the copyright owner) shall be deemed to be distributed under the MIT License. Submission of modifications through publicly accessible channels, including but not limited to pull requests on code repositories such as GitHub, shall be considered an explicit acknowledgment and grant by the Licensee that such modifications are made available under the MIT License. Licensees may not sublicense, transfer, or assign the rights granted under this license except as expressly permitted herein.
11
+ Modifications to the Software are permitted only if they are published publicly under the MIT License, covering only the modifications; the original Software remains under this license and may not be sublicensed without a separate agreement. Any modification made by a Licensee (other than modifications by the original author, its representatives, or the copyright owner) shall be deemed to be distributed under the MIT License. Submission of modifications through publicly accessible channels, including but not limited to pull requests on code repositories such as GitHub, shall be considered an explicit acknowledgment and grant by the Licensee that such modifications are made available under the MIT License. Licensees may not sublicense, transfer, or assign the rights granted under this license except as expressly permitted herein.
12
12
 
13
13
  3. Precedence of Existing Licenses:
14
- If the Licensee, or its parent or umbrella organization, is already subject to an existing license for this project, that license shall take precedence, and no additional free license is granted. Nothing in this license shall be construed to override any pre-existing exclusive license agreement.
14
+ If the Licensee, or its parent or umbrella organization, is already subject to an existing license for this project, that license shall take precedence, and no additional free license is granted. Nothing in this license shall be construed to override any pre-existing exclusive license agreement.
15
15
 
16
16
  4. Data Protection / GDPR Responsibility:
17
- Licensees are solely responsible for ensuring that any processing of personal data using this software complies with applicable data protection laws, including the EU General Data Protection Regulation (GDPR).
17
+ Licensees are solely responsible for ensuring that any processing of personal data using this software complies with applicable data protection laws, including the EU General Data Protection Regulation (GDPR).
18
18
 
19
19
  5. Termination and Revocation:
20
- The copyright holders may revoke this license at any time, at their sole discretion.
20
+ The copyright holders may revoke this license at any time, at their sole discretion.
21
21
 
22
22
  6. Governing Law:
23
- This license shall be governed by and construed in accordance with the laws of Belgium, without regard to conflict of law principles.
23
+ This license shall be governed by and construed in accordance with the laws of Belgium, without regard to conflict of law principles.
24
24
 
25
25
  7. Third-Party Licenses:
26
- Certain files or components included in the Software may be governed by separate licenses, including open-source licenses, or contributed by third parties under different terms. Such files are not automatically covered by this license. Licensees are responsible for reviewing and complying with any additional license terms that apply to these files.
26
+ Certain files or components included in the Software may be governed by separate licenses, including open-source licenses, or contributed by third parties under different terms. Such files are not automatically covered by this license. Licensees are responsible for reviewing and complying with any additional license terms that apply to these files.
27
27
 
28
28
  For the purposes of this license, a “non-profit organization” means an entity recognized as non-profit under applicable law in its jurisdiction, which does not distribute profits to its members or owners.
29
29
 
package/README.md CHANGED
@@ -1 +1,67 @@
1
- This is still WIP
1
+ # Shared Oxlint configuration
2
+
3
+ Each package uses one source linter/formatter pair: ESLint, or Oxlint and Oxfmt.
4
+ The authoritative Oxc package allowlist is
5
+ [`shared/eslint/src/ownership.js`](../eslint/src/ownership.js). Unlisted packages
6
+ retain ESLint, including Vue/Nuxt packages and Vue integration tests. Non-code
7
+ formats remain owned by Oxfmt throughout the repository.
8
+
9
+ ## Policy and compatibility
10
+
11
+ `createOxlintConfig` uses the maintained `@oxlint/migrate` API to convert the same
12
+ policy definitions used by ESLint, preserving package overrides. It omits layout
13
+ rules because Oxfmt owns formatting. No ESLint process runs on migrated files.
14
+ Unsupported required checks cause configuration loading to fail, not silently
15
+ disappear. Semantic checks use the pinned `oxlint-tsgolint` backend; ordinary
16
+ TypeScript checks remain separate.
17
+
18
+ Security, regexp, DOM-sanitization, and custom self-import checks use the existing
19
+ upstream JS plugins. Compatibility aliases retain these upstream rules:
20
+
21
+ | ESLint rule | Oxlint rule |
22
+ | ---------------------------------------------------------------------------------- | ----------------------------------------- |
23
+ | `unicorn/no-unsafe-json-serialization` | `unicorn-js/no-unsafe-json-serialization` |
24
+ | `import/no-extraneous-dependencies` | `import-js/no-extraneous-dependencies` |
25
+ | `import/no-relative-packages` | `import-js/no-relative-packages` |
26
+ | `n/file-extension-in-import` | `node-js/file-extension-in-import` |
27
+ | `no-restricted-imports`, `no-dupe-args`, `no-octal`, `no-unsafe-optional-chaining` | The same rule under `eslint-js/` |
28
+
29
+ The last group references ESLint's maintained core rule implementations directly,
30
+ without copying them or invoking ESLint as another linter. Restricted-import
31
+ reporting uses the upstream rule because native reporting differs for repeated
32
+ pattern matches. Inline suppressions must use the corresponding alias when a rule
33
+ is renamed; retain the justification.
34
+
35
+ The renderer remains entirely on ESLint because the pinned type-aware backend
36
+ reports an async `Promise.finally` callback differently from typescript-eslint.
37
+ `shared/object-differ` also retains ESLint: tsgolint rejects its test setup files
38
+ outside `rootDir`. Neither check is disabled or bypassed to force migration.
39
+
40
+ ## Migrating another package
41
+
42
+ 1. Verify its source, tests, and configuration do not depend on Vue or Nuxt.
43
+ 2. Add an `oxlint.config.mts` exporting `configs.shared` or `configs.backend` from
44
+ this package. For package-specific overrides, import the local policy and use
45
+ `await createOxlintConfig(policy)`. Keep that policy as the shared definition;
46
+ its ESLint ownership exclusion prevents ESLint from executing on the package.
47
+ 3. Declare `oxlint-plugin-stamhoofd` as a development dependency and change `lint`
48
+ to `oxlint . --quiet --type-aware --threads 2`.
49
+ 4. Verify its required checks, overrides, suppressions, and type-aware behavior.
50
+ Incompatible packages stay entirely on ESLint; do not add an ESLint fallback
51
+ or disable correctness/security rules merely to complete a migration.
52
+ 5. Add the whole directory to the ownership allowlist, apply Oxfmt, inspect the
53
+ mechanical diff, and run package lint, typechecking, and tests through `stam`.
54
+
55
+ Root Oxlint enables type-aware editor checks; package scripts pass `--type-aware`
56
+ explicitly because that option cannot be declared in nested configurations.
57
+ The root and package configuration paths support direct and filtered CLI checks.
58
+ Turbo still prepares declarations and fingerprints transitive sources and both
59
+ configuration packages. Fix mode bypasses Turbo's result cache.
60
+
61
+ ## Editors
62
+
63
+ ESLint and Oxc fixes on save respect ownership exclusions. VS Code cannot select a
64
+ different default formatter by package within a single-root workspace: retained
65
+ JS/TS/Vue packages keep the ESLint default; use **Format Document With… Oxfmt** in
66
+ migrated packages, or run `stam check format --fix`. Selecting the wrong formatter
67
+ does not transfer ownership or permit edits to ignored source files.
package/package.json CHANGED
@@ -1,18 +1,26 @@
1
1
  {
2
- "name": "oxlint-plugin-stamhoofd",
3
- "version": "2.157.1",
4
- "type": "module",
5
- "main": "./src/index.js",
6
- "sideEffects": false,
7
- "files": [
8
- "src"
9
- ],
10
- "dependencies": {
11
- "oxlint-tsgolint": "0.25.0"
12
- },
13
- "license": "UNLICENCED",
14
- "publishConfig": {
15
- "access": "public"
16
- },
17
- "gitHead": "140dd6d1c195238ae78a6cb10d9e423b30933366"
18
- }
2
+ "name": "oxlint-plugin-stamhoofd",
3
+ "version": "2.160.0",
4
+ "repository": {
5
+ "type": "git",
6
+ "url": "git+https://github.com/stamhoofd/stamhoofd.git",
7
+ "directory": "shared/oxlint"
8
+ },
9
+ "type": "module",
10
+ "main": "./src/index.js",
11
+ "sideEffects": false,
12
+ "files": [
13
+ "src"
14
+ ],
15
+ "dependencies": {
16
+ "@oxlint/migrate": "1.94.0",
17
+ "eslint": "10.15.0",
18
+ "eslint-plugin-stamhoofd": "2.160.0",
19
+ "oxlint": "1.94.0",
20
+ "oxlint-tsgolint": "7.0.2007"
21
+ },
22
+ "license": "UNLICENCED",
23
+ "publishConfig": {
24
+ "access": "public"
25
+ }
26
+ }
package/src/compat.js ADDED
@@ -0,0 +1,7 @@
1
+ import { builtinRules } from 'eslint/use-at-your-own-risk';
2
+
3
+ // Use the maintained upstream rules where native Oxlint behavior is not equivalent.
4
+ export default {
5
+ meta: { name: 'eslint-js' },
6
+ rules: Object.fromEntries(['no-restricted-imports', 'no-dupe-args', 'no-octal', 'no-unsafe-optional-chaining'].map(name => [name, builtinRules.get(name)])),
7
+ };
package/src/index.js CHANGED
@@ -1,54 +1,18 @@
1
- 'use strict';
1
+ import eslint from 'eslint-plugin-stamhoofd';
2
+ import { createOxlintConfig } from './migrate.js';
2
3
 
3
- // Configs
4
- import frontend from './configs/frontend.js';
5
- import node from './configs/node.js';
6
- import baseRules from './configs/default.js';
4
+ export { createOxlintConfig };
7
5
 
8
- function merge(...a) {
9
- if (a.length === 0) {
10
- return {
11
- plugins: [],
12
- rules: {},
6
+ // Inherited repository/backend configs anchor tests/** above package directories.
7
+ // Only the recursive test-file patterns apply inside these packages.
8
+ const inherited = configs => configs.map(config => config.files
9
+ ? {
10
+ ...config,
11
+ files: config.files.filter(pattern => pattern !== 'tests/**'),
13
12
  }
14
- }
15
- if (a.length === 1) {
16
- return a;
17
- }
18
- if (a.length === 2) {
19
- return mergeTwo(a[0], a[1]);
20
- }
21
- return merge(mergeTwo(a[0], a[1]), ...a.slice(2));
22
- }
13
+ : config);
23
14
 
24
- function mergeTwo(a, b) {
25
- return {
26
- plugins: [...new Set([...a.plugins, ...b.plugins]).values()],
27
- rules: {
28
- ...a.rules,
29
- ...b.rules
30
- },
31
- overrides: [
32
- ...(a.overrides ?? []),
33
- ...(b.overrides ?? [])
34
- ]
35
- }
36
- }
37
-
38
- export default {
39
- configs: {
40
- base: baseRules,
41
- frontend: merge(
42
- baseRules,
43
- frontend
44
- ),
45
- backend: merge(
46
- baseRules,
47
- node
48
- ),
49
- shared: merge(
50
- baseRules,
51
- node
52
- )
53
- },
15
+ export const configs = {
16
+ shared: await createOxlintConfig(inherited(eslint.configs.shared)),
17
+ backend: await createOxlintConfig(inherited(eslint.configs.backend)),
54
18
  };
package/src/migrate.js ADDED
@@ -0,0 +1,69 @@
1
+ import { createRequire } from 'node:module';
2
+ import { fileURLToPath } from 'node:url';
3
+ import { builtinRules } from 'eslint/use-at-your-own-risk';
4
+ import migrate from '@oxlint/migrate';
5
+ import stamhoofd from 'eslint-plugin-stamhoofd';
6
+ import compat from './compat.js';
7
+
8
+ const eslintRequire = createRequire(import.meta.resolve('eslint-plugin-stamhoofd'));
9
+ const plugins = Object.assign({}, ...Object.values(stamhoofd.configs).flat().map(config => config.plugins));
10
+ const aliases = {
11
+ 'unicorn/no-unsafe-json-serialization': 'unicorn-js',
12
+ 'import/no-extraneous-dependencies': 'import-js',
13
+ 'import/no-relative-packages': 'import-js',
14
+ 'n/file-extension-in-import': 'node-js',
15
+ 'no-restricted-imports': 'eslint-js',
16
+ 'no-dupe-args': 'eslint-js',
17
+ 'no-octal': 'eslint-js',
18
+ 'no-unsafe-optional-chaining': 'eslint-js',
19
+ };
20
+ const extraPlugins = Object.fromEntries(Object.entries({ 'unicorn-js': plugins.unicorn, 'import-js': plugins.import, 'node-js': plugins.n, 'eslint-js': compat }).map(([name, plugin]) => [name, {
21
+ ...plugin,
22
+ meta: { ...plugin.meta, name: `eslint-plugin-${name}` },
23
+ }]));
24
+ const pluginPaths = {
25
+ 'unicorn-js': eslintRequire.resolve('eslint-plugin-unicorn'),
26
+ 'import-js': eslintRequire.resolve('eslint-plugin-import'),
27
+ 'node-js': eslintRequire.resolve('eslint-plugin-n'),
28
+ 'eslint-js': fileURLToPath(new URL('./compat.js', import.meta.url)),
29
+ };
30
+
31
+ /** Convert the owning ESLint policy, failing rather than silently omitting unsupported checks. */
32
+ export async function createOxlintConfig(configs) {
33
+ const skipped = new Set();
34
+ const source = configs.filter(config => config.name !== 'stamhoofd/oxc-ownership').map((config) => {
35
+ const rules = {};
36
+ for (const [id, value] of Object.entries(config.rules ?? {})) {
37
+ const slash = id.lastIndexOf('/');
38
+ const definition = slash < 0 ? builtinRules.get(id) : plugins[id.slice(0, slash)]?.rules?.[id.slice(slash + 1)];
39
+ if (definition?.meta?.type === 'layout') continue;
40
+ const alias = aliases[id];
41
+ rules[alias ? `${alias}/${id.slice(slash + 1)}` : id] = value;
42
+ }
43
+ return { ...config, rules, plugins: { ...config.plugins, ...extraPlugins } };
44
+ });
45
+ const config = await migrate(source, undefined, {
46
+ typeAware: true,
47
+ withNursery: true,
48
+ jsPlugins: true,
49
+ reporter: {
50
+ markSkipped: rule => skipped.add(rule),
51
+ removeSkipped: rule => skipped.delete(rule),
52
+ addWarning: () => {},
53
+ },
54
+ });
55
+ if (skipped.size) throw new Error(`Oxlint cannot preserve these checks: ${[...skipped].join(', ')}`);
56
+ const resolvePlugins = (entries = []) => entries.map((entry) => {
57
+ const name = typeof entry === 'string' ? entry.replace(/^eslint-plugin-/, '') : entry.name;
58
+ const specifier = typeof entry === 'string' ? entry : entry.specifier;
59
+ return { name, specifier: pluginPaths[name] ?? eslintRequire.resolve(specifier) };
60
+ });
61
+ config.jsPlugins = resolvePlugins(config.jsPlugins);
62
+ for (const override of config.overrides ?? []) {
63
+ if (override.jsPlugins) override.jsPlugins = resolvePlugins(override.jsPlugins);
64
+ }
65
+ config.settings = Object.assign({}, ...configs.map(config => config.settings));
66
+ // Type-aware options are root-only when Oxlint discovers nested package configs.
67
+ delete config.options.typeAware;
68
+ return config;
69
+ }
@@ -1,76 +0,0 @@
1
- export default {
2
- plugins: ['import'],
3
- rules: {
4
- // Recommended
5
- 'constructor-super': 'error',
6
- 'for-direction': 'error',
7
- 'getter-return': 'error',
8
- 'no-async-promise-executor': 'error',
9
- 'no-case-declarations': 'error',
10
- 'no-class-assign': 'error',
11
- 'no-compare-neg-zero': 'error',
12
- 'no-cond-assign': 'error',
13
- 'no-const-assign': 'error',
14
- 'no-constant-binary-expression': 'error',
15
- 'no-constant-condition': 'error',
16
- 'no-control-regex': 'error',
17
- 'no-debugger': 'error',
18
- 'no-delete-var': 'error',
19
- 'no-dupe-args': 'error',
20
- 'no-dupe-class-members': 'error',
21
- 'no-dupe-else-if': 'error',
22
- 'no-dupe-keys': 'error',
23
- 'no-duplicate-case': 'error',
24
- 'no-empty': 'error',
25
- 'no-empty-character-class': 'error',
26
- 'no-empty-pattern': 'error',
27
- 'no-empty-static-block': 'error',
28
- 'no-ex-assign': 'error',
29
- 'no-extra-boolean-cast': 'error',
30
- 'no-fallthrough': 'error',
31
- 'no-func-assign': 'error',
32
- 'no-global-assign': 'error',
33
- 'no-import-assign': 'error',
34
- 'no-invalid-regexp': 'error',
35
- 'no-irregular-whitespace': 'error',
36
- 'no-loss-of-precision': 'error',
37
- 'no-misleading-character-class': 'error',
38
- 'no-new-native-nonconstructor': 'error',
39
- 'no-nonoctal-decimal-escape': 'error',
40
- 'no-obj-calls': 'error',
41
- 'no-octal': 'error',
42
- 'no-prototype-builtins': 'error',
43
- 'no-redeclare': 'error',
44
- 'no-regex-spaces': 'error',
45
- 'no-self-assign': 'error',
46
- 'no-setter-return': 'error',
47
- 'no-shadow-restricted-names': 'error',
48
- 'no-sparse-arrays': 'error',
49
- 'no-this-before-super': 'error',
50
- 'no-undef': 'error',
51
- 'no-unexpected-multiline': 'error',
52
- 'no-unreachable': 'error',
53
- 'no-unsafe-finally': 'error',
54
- 'no-unsafe-negation': 'error',
55
- 'no-unsafe-optional-chaining': 'error',
56
- 'no-unused-labels': 'error',
57
- 'no-unused-private-class-members': 'error',
58
- 'no-unused-vars': 'error',
59
- 'no-useless-backreference': 'error',
60
- 'no-useless-catch': 'error',
61
- 'no-useless-escape': 'error',
62
- 'no-with': 'error',
63
- 'require-yield': 'error',
64
- 'use-isnan': 'error',
65
- 'valid-typeof': 'error',
66
-
67
- // Overrides
68
- 'no-console': 'off',
69
- 'sort-imports': 'off',
70
- 'keyword-spacing': 'warn',
71
- 'eqeqeq': ['warn', 'always'],
72
-
73
- // Import
74
- 'import/no-cycle': ['warn', { maxDepth: 30, ignoreExternal: false }],
75
- },
76
- };
@@ -1,6 +0,0 @@
1
-
2
-
3
- export default {
4
- plugins: [],
5
- rules: {}
6
- };
@@ -1,11 +0,0 @@
1
-
2
-
3
- export default {
4
- plugins: ['import'],
5
- rules: {
6
- "import/extensions": [
7
- "error",
8
- "always"
9
- ]
10
- }
11
- }
@@ -1,62 +0,0 @@
1
- export default {
2
- plugins: [
3
- 'typescript'
4
- ],
5
- rules: {
6
- // Recommended
7
- '@typescript-eslint/ban-ts-comment': 'error',
8
- 'no-array-constructor': 'off',
9
- '@typescript-eslint/no-array-constructor': 'error',
10
- '@typescript-eslint/no-duplicate-enum-values': 'error',
11
- '@typescript-eslint/no-empty-object-type': 'error',
12
- '@typescript-eslint/no-explicit-any': 'error',
13
- '@typescript-eslint/no-extra-non-null-assertion': 'error',
14
- '@typescript-eslint/no-misused-new': 'error',
15
- '@typescript-eslint/no-namespace': 'error',
16
- '@typescript-eslint/no-non-null-asserted-optional-chain': 'error',
17
- '@typescript-eslint/no-require-imports': 'error',
18
- '@typescript-eslint/no-this-alias': 'error',
19
- '@typescript-eslint/no-unnecessary-type-constraint': 'error',
20
- '@typescript-eslint/no-unsafe-declaration-merging': 'error',
21
- '@typescript-eslint/no-unsafe-function-type': 'error',
22
- 'no-unused-expressions': 'off',
23
- '@typescript-eslint/no-unused-expressions': 'error',
24
- 'no-unused-vars': 'off',
25
- '@typescript-eslint/no-unused-vars': 'error',
26
- '@typescript-eslint/no-wrapper-object-types': 'error',
27
- '@typescript-eslint/prefer-as-const': 'error',
28
- '@typescript-eslint/prefer-namespace-keyword': 'error',
29
- '@typescript-eslint/triple-slash-reference': 'error',
30
-
31
- // Overrides
32
- "no-undef": "off", // Does not work with TypeScript
33
-
34
- "@typescript-eslint/explicit-function-return-type": "off",
35
- "@typescript-eslint/no-explicit-any": "off",
36
-
37
- "no-unused-vars": "off",
38
- "@typescript-eslint/no-unused-vars": ["warn", { argsIgnorePattern: "^_", "caughtErrors": "none", }],
39
-
40
- "prefer-promise-reject-errors": "off",
41
- "@typescript-eslint/prefer-promise-reject-errors": "off", // Does not work correctly when passing on 'any' errors in a try catch block using reject()
42
-
43
- "@typescript-eslint/no-namespace": "off",
44
- "@typescript-eslint/no-floating-promises": "error",
45
- "@typescript-eslint/no-misused-promises": "error",
46
- "@typescript-eslint/prefer-for-of": "warn",
47
- "@typescript-eslint/no-empty-interface": "off", // It is convenient to have placeholder interfaces
48
- "@typescript-eslint/no-this-alias": "off", // No idea why we need this. This breaks code that is just fine. Prohibit the use of function() instead of this rule
49
- "@typescript-eslint/unbound-method": "off", // Methods are automatically bound in vue, it would break removeEventListeners if we bound it every time unless we save every method in variables again...
50
- "@typescript-eslint/no-unnecessary-type-assertion": "off", // There is a bug in the autofix that breaks Vue code (it changes code on the wrong position)
51
- "@typescript-eslint/explicit-module-boundary-types": "off", // Don't need this, since we don't export methods, and is annoying for async methods without return values
52
-
53
- "@typescript-eslint/no-unsafe-assignment": "off", // This is impossible to use with dependencies that don't have types yet, such as tiptap
54
- "@typescript-eslint/no-unsafe-return": "off", // This is impossible to use with dependencies that don't have types yet, such as tiptap
55
- "@typescript-eslint/no-unsafe-call": "off", // This is impossible to use with dependencies that don't have types yet, such as tiptap
56
- "@typescript-eslint/no-unsafe-member-access": "off", // This is impossible to use with dependencies that don't have types yet, such as tiptap
57
- "@typescript-eslint/restrict-plus-operands": "off", // bullshit one
58
- "@typescript-eslint/require-await": "off", // You should be able to define async methods if you need to match required interfaces or types
59
-
60
- "@typescript-eslint/no-redundant-type-constituents": "off", // Weird behaviour and reduces code readability
61
- "@typescript-eslint/ban-ts-comment": "off",
62
- }