diff --git a/napi/oxlint2/test/__snapshots__/e2e.test.ts.snap b/napi/oxlint2/test/__snapshots__/e2e.test.ts.snap index 62a131c56d3f8..d03ec159a8942 100644 --- a/napi/oxlint2/test/__snapshots__/e2e.test.ts.snap +++ b/napi/oxlint2/test/__snapshots__/e2e.test.ts.snap @@ -56,6 +56,272 @@ Found 1 warning and 1 error. Finished in Xms on 1 file using X threads." `; +exports[`cli options for bundling > should load a custom plugin with multiple files 1`] = ` +" + ! ]8;;https://oxc.rs/docs/guide/usage/linter/rules/eslint/no-debugger.html\\eslint(no-debugger)]8;;\\: \`debugger\` statement is not allowed + ,-[files/01.js:1:1] + 1 | debugger; + : ^^^^^^^^^ + \`---- + help: Remove the debugger statement + + x basic-custom-plugin(no-debugger): Unexpected Debugger Statement + ,-[files/01.js:1:1] + 1 | debugger; + : ^ + \`---- + + ! ]8;;https://oxc.rs/docs/guide/usage/linter/rules/eslint/no-debugger.html\\eslint(no-debugger)]8;;\\: \`debugger\` statement is not allowed + ,-[files/02.js:1:1] + 1 | debugger; + : ^^^^^^^^^ + \`---- + help: Remove the debugger statement + + x basic-custom-plugin(no-debugger): Unexpected Debugger Statement + ,-[files/02.js:1:1] + 1 | debugger; + : ^ + \`---- + + ! ]8;;https://oxc.rs/docs/guide/usage/linter/rules/eslint/no-debugger.html\\eslint(no-debugger)]8;;\\: \`debugger\` statement is not allowed + ,-[files/03.js:1:1] + 1 | debugger; + : ^^^^^^^^^ + \`---- + help: Remove the debugger statement + + x basic-custom-plugin(no-debugger): Unexpected Debugger Statement + ,-[files/03.js:1:1] + 1 | debugger; + : ^ + \`---- + + ! ]8;;https://oxc.rs/docs/guide/usage/linter/rules/eslint/no-debugger.html\\eslint(no-debugger)]8;;\\: \`debugger\` statement is not allowed + ,-[files/04.js:1:1] + 1 | debugger; + : ^^^^^^^^^ + \`---- + help: Remove the debugger statement + + x basic-custom-plugin(no-debugger): Unexpected Debugger Statement + ,-[files/04.js:1:1] + 1 | debugger; + : ^ + \`---- + + ! ]8;;https://oxc.rs/docs/guide/usage/linter/rules/eslint/no-debugger.html\\eslint(no-debugger)]8;;\\: \`debugger\` statement is not allowed + ,-[files/05.js:1:1] + 1 | debugger; + : ^^^^^^^^^ + \`---- + help: Remove the debugger statement + + x basic-custom-plugin(no-debugger): Unexpected Debugger Statement + ,-[files/05.js:1:1] + 1 | debugger; + : ^ + \`---- + + ! ]8;;https://oxc.rs/docs/guide/usage/linter/rules/eslint/no-debugger.html\\eslint(no-debugger)]8;;\\: \`debugger\` statement is not allowed + ,-[files/06.js:1:1] + 1 | debugger; + : ^^^^^^^^^ + \`---- + help: Remove the debugger statement + + x basic-custom-plugin(no-debugger): Unexpected Debugger Statement + ,-[files/06.js:1:1] + 1 | debugger; + : ^ + \`---- + + ! ]8;;https://oxc.rs/docs/guide/usage/linter/rules/eslint/no-debugger.html\\eslint(no-debugger)]8;;\\: \`debugger\` statement is not allowed + ,-[files/07.js:1:1] + 1 | debugger; + : ^^^^^^^^^ + \`---- + help: Remove the debugger statement + + x basic-custom-plugin(no-debugger): Unexpected Debugger Statement + ,-[files/07.js:1:1] + 1 | debugger; + : ^ + \`---- + + ! ]8;;https://oxc.rs/docs/guide/usage/linter/rules/eslint/no-debugger.html\\eslint(no-debugger)]8;;\\: \`debugger\` statement is not allowed + ,-[files/08.js:1:1] + 1 | debugger; + : ^^^^^^^^^ + \`---- + help: Remove the debugger statement + + x basic-custom-plugin(no-debugger): Unexpected Debugger Statement + ,-[files/08.js:1:1] + 1 | debugger; + : ^ + \`---- + + ! ]8;;https://oxc.rs/docs/guide/usage/linter/rules/eslint/no-debugger.html\\eslint(no-debugger)]8;;\\: \`debugger\` statement is not allowed + ,-[files/09.js:1:1] + 1 | debugger; + : ^^^^^^^^^ + \`---- + help: Remove the debugger statement + + x basic-custom-plugin(no-debugger): Unexpected Debugger Statement + ,-[files/09.js:1:1] + 1 | debugger; + : ^ + \`---- + + ! ]8;;https://oxc.rs/docs/guide/usage/linter/rules/eslint/no-debugger.html\\eslint(no-debugger)]8;;\\: \`debugger\` statement is not allowed + ,-[files/10.js:1:1] + 1 | debugger; + : ^^^^^^^^^ + \`---- + help: Remove the debugger statement + + x basic-custom-plugin(no-debugger): Unexpected Debugger Statement + ,-[files/10.js:1:1] + 1 | debugger; + : ^ + \`---- + + ! ]8;;https://oxc.rs/docs/guide/usage/linter/rules/eslint/no-debugger.html\\eslint(no-debugger)]8;;\\: \`debugger\` statement is not allowed + ,-[files/11.js:1:1] + 1 | debugger; + : ^^^^^^^^^ + \`---- + help: Remove the debugger statement + + x basic-custom-plugin(no-debugger): Unexpected Debugger Statement + ,-[files/11.js:1:1] + 1 | debugger; + : ^ + \`---- + + ! ]8;;https://oxc.rs/docs/guide/usage/linter/rules/eslint/no-debugger.html\\eslint(no-debugger)]8;;\\: \`debugger\` statement is not allowed + ,-[files/12.js:1:1] + 1 | debugger; + : ^^^^^^^^^ + \`---- + help: Remove the debugger statement + + x basic-custom-plugin(no-debugger): Unexpected Debugger Statement + ,-[files/12.js:1:1] + 1 | debugger; + : ^ + \`---- + + ! ]8;;https://oxc.rs/docs/guide/usage/linter/rules/eslint/no-debugger.html\\eslint(no-debugger)]8;;\\: \`debugger\` statement is not allowed + ,-[files/13.js:1:1] + 1 | debugger; + : ^^^^^^^^^ + \`---- + help: Remove the debugger statement + + x basic-custom-plugin(no-debugger): Unexpected Debugger Statement + ,-[files/13.js:1:1] + 1 | debugger; + : ^ + \`---- + + ! ]8;;https://oxc.rs/docs/guide/usage/linter/rules/eslint/no-debugger.html\\eslint(no-debugger)]8;;\\: \`debugger\` statement is not allowed + ,-[files/14.js:1:1] + 1 | debugger; + : ^^^^^^^^^ + \`---- + help: Remove the debugger statement + + x basic-custom-plugin(no-debugger): Unexpected Debugger Statement + ,-[files/14.js:1:1] + 1 | debugger; + : ^ + \`---- + + ! ]8;;https://oxc.rs/docs/guide/usage/linter/rules/eslint/no-debugger.html\\eslint(no-debugger)]8;;\\: \`debugger\` statement is not allowed + ,-[files/15.js:1:1] + 1 | debugger; + : ^^^^^^^^^ + \`---- + help: Remove the debugger statement + + x basic-custom-plugin(no-debugger): Unexpected Debugger Statement + ,-[files/15.js:1:1] + 1 | debugger; + : ^ + \`---- + + ! ]8;;https://oxc.rs/docs/guide/usage/linter/rules/eslint/no-debugger.html\\eslint(no-debugger)]8;;\\: \`debugger\` statement is not allowed + ,-[files/16.js:1:1] + 1 | debugger; + : ^^^^^^^^^ + \`---- + help: Remove the debugger statement + + x basic-custom-plugin(no-debugger): Unexpected Debugger Statement + ,-[files/16.js:1:1] + 1 | debugger; + : ^ + \`---- + + ! ]8;;https://oxc.rs/docs/guide/usage/linter/rules/eslint/no-debugger.html\\eslint(no-debugger)]8;;\\: \`debugger\` statement is not allowed + ,-[files/17.js:1:1] + 1 | debugger; + : ^^^^^^^^^ + \`---- + help: Remove the debugger statement + + x basic-custom-plugin(no-debugger): Unexpected Debugger Statement + ,-[files/17.js:1:1] + 1 | debugger; + : ^ + \`---- + + ! ]8;;https://oxc.rs/docs/guide/usage/linter/rules/eslint/no-debugger.html\\eslint(no-debugger)]8;;\\: \`debugger\` statement is not allowed + ,-[files/18.js:1:1] + 1 | debugger; + : ^^^^^^^^^ + \`---- + help: Remove the debugger statement + + x basic-custom-plugin(no-debugger): Unexpected Debugger Statement + ,-[files/18.js:1:1] + 1 | debugger; + : ^ + \`---- + + ! ]8;;https://oxc.rs/docs/guide/usage/linter/rules/eslint/no-debugger.html\\eslint(no-debugger)]8;;\\: \`debugger\` statement is not allowed + ,-[files/19.js:1:1] + 1 | debugger; + : ^^^^^^^^^ + \`---- + help: Remove the debugger statement + + x basic-custom-plugin(no-debugger): Unexpected Debugger Statement + ,-[files/19.js:1:1] + 1 | debugger; + : ^ + \`---- + + ! ]8;;https://oxc.rs/docs/guide/usage/linter/rules/eslint/no-debugger.html\\eslint(no-debugger)]8;;\\: \`debugger\` statement is not allowed + ,-[files/20.js:1:1] + 1 | debugger; + : ^^^^^^^^^ + \`---- + help: Remove the debugger statement + + x basic-custom-plugin(no-debugger): Unexpected Debugger Statement + ,-[files/20.js:1:1] + 1 | debugger; + : ^ + \`---- + +Found 20 warnings and 20 errors. +Finished in Xms on 20 files using X threads." +`; + exports[`cli options for bundling > should report an error if a custom plugin cannot be loaded 1`] = ` "Failed to parse configuration file. diff --git a/napi/oxlint2/test/e2e.test.ts b/napi/oxlint2/test/e2e.test.ts index 87d0147fef215..3368b210630d1 100644 --- a/napi/oxlint2/test/e2e.test.ts +++ b/napi/oxlint2/test/e2e.test.ts @@ -48,6 +48,15 @@ describe('cli options for bundling', () => { expect(normalizeOutput(stdout)).toMatchSnapshot(); }); + it('should load a custom plugin with multiple files', async () => { + const { stdout, exitCode } = await runOxlint( + 'test/fixtures/basic_custom_plugin_many_files', + ); + + expect(exitCode).toBe(1); + expect(normalizeOutput(stdout)).toMatchSnapshot(); + }); + it('should load a custom plugin when configured in overrides', async () => { const { stdout, exitCode } = await runOxlint( 'test/fixtures/custom_plugin_via_overrides', diff --git a/napi/oxlint2/test/fixtures/basic_custom_plugin_many_files/.oxlintrc.json b/napi/oxlint2/test/fixtures/basic_custom_plugin_many_files/.oxlintrc.json new file mode 100644 index 0000000000000..9c8cb3cddcbd8 --- /dev/null +++ b/napi/oxlint2/test/fixtures/basic_custom_plugin_many_files/.oxlintrc.json @@ -0,0 +1,7 @@ +{ + "plugins": ["./test_plugin"], + "rules": { + "basic-custom-plugin/no-debugger": "error" + }, + "ignorePatterns": ["test_plugin"] +} diff --git a/napi/oxlint2/test/fixtures/basic_custom_plugin_many_files/files/01.js b/napi/oxlint2/test/fixtures/basic_custom_plugin_many_files/files/01.js new file mode 100644 index 0000000000000..eab74692130a6 --- /dev/null +++ b/napi/oxlint2/test/fixtures/basic_custom_plugin_many_files/files/01.js @@ -0,0 +1 @@ +debugger; diff --git a/napi/oxlint2/test/fixtures/basic_custom_plugin_many_files/files/02.js b/napi/oxlint2/test/fixtures/basic_custom_plugin_many_files/files/02.js new file mode 100644 index 0000000000000..eab74692130a6 --- /dev/null +++ b/napi/oxlint2/test/fixtures/basic_custom_plugin_many_files/files/02.js @@ -0,0 +1 @@ +debugger; diff --git a/napi/oxlint2/test/fixtures/basic_custom_plugin_many_files/files/03.js b/napi/oxlint2/test/fixtures/basic_custom_plugin_many_files/files/03.js new file mode 100644 index 0000000000000..eab74692130a6 --- /dev/null +++ b/napi/oxlint2/test/fixtures/basic_custom_plugin_many_files/files/03.js @@ -0,0 +1 @@ +debugger; diff --git a/napi/oxlint2/test/fixtures/basic_custom_plugin_many_files/files/04.js b/napi/oxlint2/test/fixtures/basic_custom_plugin_many_files/files/04.js new file mode 100644 index 0000000000000..eab74692130a6 --- /dev/null +++ b/napi/oxlint2/test/fixtures/basic_custom_plugin_many_files/files/04.js @@ -0,0 +1 @@ +debugger; diff --git a/napi/oxlint2/test/fixtures/basic_custom_plugin_many_files/files/05.js b/napi/oxlint2/test/fixtures/basic_custom_plugin_many_files/files/05.js new file mode 100644 index 0000000000000..eab74692130a6 --- /dev/null +++ b/napi/oxlint2/test/fixtures/basic_custom_plugin_many_files/files/05.js @@ -0,0 +1 @@ +debugger; diff --git a/napi/oxlint2/test/fixtures/basic_custom_plugin_many_files/files/06.js b/napi/oxlint2/test/fixtures/basic_custom_plugin_many_files/files/06.js new file mode 100644 index 0000000000000..eab74692130a6 --- /dev/null +++ b/napi/oxlint2/test/fixtures/basic_custom_plugin_many_files/files/06.js @@ -0,0 +1 @@ +debugger; diff --git a/napi/oxlint2/test/fixtures/basic_custom_plugin_many_files/files/07.js b/napi/oxlint2/test/fixtures/basic_custom_plugin_many_files/files/07.js new file mode 100644 index 0000000000000..eab74692130a6 --- /dev/null +++ b/napi/oxlint2/test/fixtures/basic_custom_plugin_many_files/files/07.js @@ -0,0 +1 @@ +debugger; diff --git a/napi/oxlint2/test/fixtures/basic_custom_plugin_many_files/files/08.js b/napi/oxlint2/test/fixtures/basic_custom_plugin_many_files/files/08.js new file mode 100644 index 0000000000000..eab74692130a6 --- /dev/null +++ b/napi/oxlint2/test/fixtures/basic_custom_plugin_many_files/files/08.js @@ -0,0 +1 @@ +debugger; diff --git a/napi/oxlint2/test/fixtures/basic_custom_plugin_many_files/files/09.js b/napi/oxlint2/test/fixtures/basic_custom_plugin_many_files/files/09.js new file mode 100644 index 0000000000000..eab74692130a6 --- /dev/null +++ b/napi/oxlint2/test/fixtures/basic_custom_plugin_many_files/files/09.js @@ -0,0 +1 @@ +debugger; diff --git a/napi/oxlint2/test/fixtures/basic_custom_plugin_many_files/files/10.js b/napi/oxlint2/test/fixtures/basic_custom_plugin_many_files/files/10.js new file mode 100644 index 0000000000000..eab74692130a6 --- /dev/null +++ b/napi/oxlint2/test/fixtures/basic_custom_plugin_many_files/files/10.js @@ -0,0 +1 @@ +debugger; diff --git a/napi/oxlint2/test/fixtures/basic_custom_plugin_many_files/files/11.js b/napi/oxlint2/test/fixtures/basic_custom_plugin_many_files/files/11.js new file mode 100644 index 0000000000000..eab74692130a6 --- /dev/null +++ b/napi/oxlint2/test/fixtures/basic_custom_plugin_many_files/files/11.js @@ -0,0 +1 @@ +debugger; diff --git a/napi/oxlint2/test/fixtures/basic_custom_plugin_many_files/files/12.js b/napi/oxlint2/test/fixtures/basic_custom_plugin_many_files/files/12.js new file mode 100644 index 0000000000000..eab74692130a6 --- /dev/null +++ b/napi/oxlint2/test/fixtures/basic_custom_plugin_many_files/files/12.js @@ -0,0 +1 @@ +debugger; diff --git a/napi/oxlint2/test/fixtures/basic_custom_plugin_many_files/files/13.js b/napi/oxlint2/test/fixtures/basic_custom_plugin_many_files/files/13.js new file mode 100644 index 0000000000000..eab74692130a6 --- /dev/null +++ b/napi/oxlint2/test/fixtures/basic_custom_plugin_many_files/files/13.js @@ -0,0 +1 @@ +debugger; diff --git a/napi/oxlint2/test/fixtures/basic_custom_plugin_many_files/files/14.js b/napi/oxlint2/test/fixtures/basic_custom_plugin_many_files/files/14.js new file mode 100644 index 0000000000000..eab74692130a6 --- /dev/null +++ b/napi/oxlint2/test/fixtures/basic_custom_plugin_many_files/files/14.js @@ -0,0 +1 @@ +debugger; diff --git a/napi/oxlint2/test/fixtures/basic_custom_plugin_many_files/files/15.js b/napi/oxlint2/test/fixtures/basic_custom_plugin_many_files/files/15.js new file mode 100644 index 0000000000000..eab74692130a6 --- /dev/null +++ b/napi/oxlint2/test/fixtures/basic_custom_plugin_many_files/files/15.js @@ -0,0 +1 @@ +debugger; diff --git a/napi/oxlint2/test/fixtures/basic_custom_plugin_many_files/files/16.js b/napi/oxlint2/test/fixtures/basic_custom_plugin_many_files/files/16.js new file mode 100644 index 0000000000000..eab74692130a6 --- /dev/null +++ b/napi/oxlint2/test/fixtures/basic_custom_plugin_many_files/files/16.js @@ -0,0 +1 @@ +debugger; diff --git a/napi/oxlint2/test/fixtures/basic_custom_plugin_many_files/files/17.js b/napi/oxlint2/test/fixtures/basic_custom_plugin_many_files/files/17.js new file mode 100644 index 0000000000000..eab74692130a6 --- /dev/null +++ b/napi/oxlint2/test/fixtures/basic_custom_plugin_many_files/files/17.js @@ -0,0 +1 @@ +debugger; diff --git a/napi/oxlint2/test/fixtures/basic_custom_plugin_many_files/files/18.js b/napi/oxlint2/test/fixtures/basic_custom_plugin_many_files/files/18.js new file mode 100644 index 0000000000000..eab74692130a6 --- /dev/null +++ b/napi/oxlint2/test/fixtures/basic_custom_plugin_many_files/files/18.js @@ -0,0 +1 @@ +debugger; diff --git a/napi/oxlint2/test/fixtures/basic_custom_plugin_many_files/files/19.js b/napi/oxlint2/test/fixtures/basic_custom_plugin_many_files/files/19.js new file mode 100644 index 0000000000000..eab74692130a6 --- /dev/null +++ b/napi/oxlint2/test/fixtures/basic_custom_plugin_many_files/files/19.js @@ -0,0 +1 @@ +debugger; diff --git a/napi/oxlint2/test/fixtures/basic_custom_plugin_many_files/files/20.js b/napi/oxlint2/test/fixtures/basic_custom_plugin_many_files/files/20.js new file mode 100644 index 0000000000000..eab74692130a6 --- /dev/null +++ b/napi/oxlint2/test/fixtures/basic_custom_plugin_many_files/files/20.js @@ -0,0 +1 @@ +debugger; diff --git a/napi/oxlint2/test/fixtures/basic_custom_plugin_many_files/test_plugin/index.js b/napi/oxlint2/test/fixtures/basic_custom_plugin_many_files/test_plugin/index.js new file mode 100644 index 0000000000000..b8cdb2bdb73fa --- /dev/null +++ b/napi/oxlint2/test/fixtures/basic_custom_plugin_many_files/test_plugin/index.js @@ -0,0 +1,19 @@ +export default { + meta: { + name: "basic-custom-plugin", + }, + rules: { + "no-debugger": { + create(context) { + // TODO: move this call into `DebuggerStatement`, once we are walking the ast. + context.report({ + message: "Unexpected Debugger Statement", + node: { start: 0, end: 0 }, + }); + return { + DebuggerStatement(_debuggerStatement) {}, + }; + }, + }, + }, +};