-
-
Notifications
You must be signed in to change notification settings - Fork 722
Labels
A-linter-pluginsArea - Linter JS pluginsArea - Linter JS pluginsC-bugCategory - BugCategory - BugP-highPriority - HighPriority - High
Description
What version of Oxlint are you using?
1.19.0
What command did you run?
oxlint
What does your .oxlintrc.json config file look like?
import { definePlugin, defineRule } from 'oxlint';
// oxlint-disable-next-line no-default-export
export default definePlugin({
meta: { name: 'my-custom-plugin' },
rules: {
'no-switch': defineRule({
create: context => ({
SwitchStatement: node =>
context.report({node: node, message: 'Do not use switch 🙏'}),
}),
}),
},
});What happened?
WARNING: JS plugins are experimental and not subject to semver.
Breaking changes are possible while JS plugins support is under development.
Failed to parse configuration file.
× Failed to load JS plugin: ./my-custom-plugin.js
│ Error [ERR_UNSUPPORTED_ESM_URL_SCHEME]: Only URLs with a scheme in: file, data, and node are supported by the default ESM loader. On Windows, absolute paths must be valid file:// URLs. Received protocol 'c:'
│ at throwIfUnsupportedURLScheme (node:internal/modules/esm/load:183:11)
│ at defaultLoad (node:internal/modules/esm/load:78:3)
│ at ModuleLoader.load (node:internal/modules/esm/loader:819:12)
│ at ModuleLoader.loadAndTranslate (node:internal/modules/esm/loader:596:43)
│ at #createModuleJob (node:internal/modules/esm/loader:621:36)
│ at #getJobFromResolveResult (node:internal/modules/esm/loader:346:34)
│ at ModuleLoader.getModuleJobForImport (node:internal/modules/esm/loader:311:41)
│ at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:663:25)
I also tried to use absolute (just or testing not committable) with /Users/MyUser/Project/my-custom-plugin.js
× Failed to load JS plugin: /Users/my-custom-plugin.js
│ TypeError [ERR_INVALID_MODULE_SPECIFIER]: Invalid module "\Users\MyUser\Project\my-custom-plugin.js" is not a valid package name imported from C:\Users\MyUser\Project\node_modules\.pnpm\oxlint@1.19.0\node_modules\oxlint\dist\plugins.js
│ at parsePackageName (node:internal/modules/package_json_reader:224:11)
│ at Object.getPackageJSONURL (node:internal/modules/package_json_reader:235:53)
│ at packageResolve (node:internal/modules/esm/resolve:768:81
Then I tried absolute pointing on a directory having a package.json with a main the plugin but gave the same error. Changing main in package.json made it not finding the js file. Also tried .cjs with no success either.
EDM115
Metadata
Metadata
Assignees
Labels
A-linter-pluginsArea - Linter JS pluginsArea - Linter JS pluginsC-bugCategory - BugCategory - BugP-highPriority - HighPriority - High
{ "$schema": "./node_modules/oxlint/configuration_schema.json", "plugins": [ "eslint", "import", "typescript", "unicorn", "react", "react-hooks", "react-perf", "oxc", "vitest" ], "jsPlugins": [ "./customPlugins/my-custom.js" ], "rules": { "my-custom/no-switch": "error" }, }