Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"jsPlugins": ["./plugin.js"],
"jsPlugins": ["./plugin.ts"],
"rules": {
"basic-custom-plugin/no-debugger": "error"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export default {
import type { Plugin } from '../../../dist/index.js';

const plugin: Plugin = {
meta: {
name: 'basic-custom-plugin',
},
Expand All @@ -17,3 +19,5 @@ export default {
},
},
};

export default plugin;
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"jsPlugins": ["./plugin.js"],
"jsPlugins": ["./plugin.ts"],
"rules": {
"basic-custom-plugin/no-debugger": "error"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export default {
import type { Plugin } from '../../../dist/index.js';

const plugin: Plugin = {
meta: {
name: 'basic-custom-plugin',
},
Expand All @@ -17,3 +19,5 @@ export default {
},
},
};

export default plugin;
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"jsPlugins": ["./plugin.js"],
"jsPlugins": ["./plugin.ts"],
"rules": {
"basic-custom-plugin/no-debugger": "error",
"basic-custom-plugin/no-debugger-2": "error",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export default {
import type { Plugin } from '../../../dist/index.js';

const plugin: Plugin = {
meta: {
name: 'basic-custom-plugin',
},
Expand Down Expand Up @@ -40,3 +42,5 @@ export default {
},
},
};

export default plugin;
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"jsPlugins": ["./plugin.js"],
"jsPlugins": ["./plugin.ts"],
"rules": {
"basic-custom-plugin/no-debugger": "warn"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export default {
import type { Plugin } from '../../../dist/index.js';

const plugin: Plugin = {
meta: {
name: 'basic-custom-plugin',
},
Expand All @@ -17,3 +19,5 @@ export default {
},
},
};

export default plugin;
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"jsPlugins": ["./plugin.js"],
"jsPlugins": ["./plugin.ts"],
"categories": { "correctness": "off" },
"rules": {
"context-plugin/log-context": "error"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import { sep } from 'node:path';

import type { Plugin, Rule } from '../../../dist/index.js';

const SPAN = { start: 0, end: 0 };

const DIR_PATH_LEN = import.meta.dirname.length + 1;

const relativePath = sep === '/'
? path => path.slice(DIR_PATH_LEN)
: path => path.slice(DIR_PATH_LEN).replace(/\\/g, '/');
? (path: string) => path.slice(DIR_PATH_LEN)
: (path: string) => path.slice(DIR_PATH_LEN).replace(/\\/g, '/');

const rule = {
const rule: Rule = {
create(context) {
context.report({
message: `id: ${context.id}`,
Expand All @@ -35,11 +37,13 @@ const rule = {
},
};

export default {
const plugin: Plugin = {
meta: {
name: 'context-plugin',
},
rules: {
'log-context': rule,
},
};

export default plugin;
2 changes: 1 addition & 1 deletion apps/oxlint/test/fixtures/createOnce/.oxlintrc.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"jsPlugins": ["./plugin.js"],
"jsPlugins": ["./plugin.ts"],
"categories": { "correctness": "off" },
"rules": {
"create-once-plugin/always-run": "error",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
import { sep } from 'node:path';

import type { Plugin, Rule } from '../../../dist/index.js';

const SPAN = { start: 0, end: 0 };

const DIR_PATH_LEN = import.meta.dirname.length + 1;

const relativePath = sep === '/'
? path => path.slice(DIR_PATH_LEN)
: path => path.slice(DIR_PATH_LEN).replace(/\\/g, '/');
? (path: string) => path.slice(DIR_PATH_LEN)
: (path: string) => path.slice(DIR_PATH_LEN).replace(/\\/g, '/');

let createOnceCallCount = 0;
const alwaysRunRule = {

const alwaysRunRule: Rule = {
createOnce(context) {
createOnceCallCount++;

// `this` should be the rule object
// oxlint-disable-next-line typescript-eslint/no-this-alias
const topLevelThis = this;

// Check that these APIs throw here
Expand Down Expand Up @@ -49,7 +54,7 @@ const alwaysRunRule = {
},
};

const skipRunRule = {
const skipRunRule: Rule = {
createOnce(context) {
return {
before() {
Expand All @@ -68,7 +73,7 @@ const skipRunRule = {
},
};

const beforeOnlyRule = {
const beforeOnlyRule: Rule = {
createOnce(context) {
return {
before() {
Expand All @@ -85,7 +90,7 @@ const beforeOnlyRule = {
},
};

const afterOnlyRule = {
const afterOnlyRule: Rule = {
createOnce(context) {
return {
Identifier(node) {
Expand All @@ -102,7 +107,7 @@ const afterOnlyRule = {
},
};

const noHooksRule = {
const noHooksRule: Rule = {
createOnce(context) {
return {
Identifier(node) {
Expand All @@ -115,7 +120,7 @@ const noHooksRule = {
},
};

export default {
const plugin: Plugin = {
meta: {
name: 'create-once-plugin',
},
Expand All @@ -128,7 +133,9 @@ export default {
},
};

function tryCatch(fn) {
export default plugin;

function tryCatch(fn: () => unknown) {
try {
fn();
} catch (err) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"jsPlugins": ["./plugin.js"],
"jsPlugins": ["./plugin.ts"],
"categories": { "correctness": "off" },
"rules": {
"test-plugin/no-var": "error",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export default {
import type { Plugin } from '../../../dist/index.js';

const plugin: Plugin = {
meta: {
name: 'test-plugin',
},
Expand All @@ -19,3 +21,5 @@ export default {
},
},
};

export default plugin;
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"jsPlugins": ["./plugin.js"],
"jsPlugins": ["./plugin.ts"],
"categories": { "correctness": "off" },
"rules": {
"basic-custom-plugin/unknown-rule": "error"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
```
Failed to parse configuration file.

x Failed to load JS plugin: ./plugin.js
x Failed to load JS plugin: ./plugin.ts
| Error: whoops!
| at <root>/apps/oxlint/test/fixtures/custom_plugin_import_error/plugin.js:1:7
| at <root>/apps/oxlint/test/fixtures/custom_plugin_import_error/plugin.ts:1:7
```

# stderr
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"jsPlugins": ["./plugin.js"],
"jsPlugins": ["./plugin.ts"],
"categories": { "correctness": "off" },
"rules": {
"error-plugin/error": "error"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
x Error running JS plugin.
| File path: <root>/apps/oxlint/test/fixtures/custom_plugin_lint_after_hook_error/files/index.js
| Error: Whoops!
| at after (<root>/apps/oxlint/test/fixtures/custom_plugin_lint_after_hook_error/plugin.js:10:19)
| at after (<root>/apps/oxlint/test/fixtures/custom_plugin_lint_after_hook_error/plugin.ts:12:19)

Found 0 warnings and 1 error.
Finished in Xms on 1 file using X threads.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export default {
import type { Plugin } from '../../../dist/index.js';

const plugin: Plugin = {
meta: {
name: 'error-plugin',
},
Expand All @@ -14,3 +16,5 @@ export default {
},
},
};

export default plugin;
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"jsPlugins": ["./plugin.js"],
"jsPlugins": ["./plugin.ts"],
"categories": { "correctness": "off" },
"rules": {
"error-plugin/error": "error"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
x Error running JS plugin.
| File path: <root>/apps/oxlint/test/fixtures/custom_plugin_lint_before_hook_error/files/index.js
| Error: Whoops!
| at before (<root>/apps/oxlint/test/fixtures/custom_plugin_lint_before_hook_error/plugin.js:10:19)
| at before (<root>/apps/oxlint/test/fixtures/custom_plugin_lint_before_hook_error/plugin.ts:12:19)

Found 0 warnings and 1 error.
Finished in Xms on 1 file using X threads.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export default {
import type { Plugin } from '../../../dist/index.js';

const plugin: Plugin = {
meta: {
name: 'error-plugin',
},
Expand All @@ -14,3 +16,5 @@ export default {
},
},
};

export default plugin;
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"jsPlugins": ["./plugin.js"],
"jsPlugins": ["./plugin.ts"],
"categories": { "correctness": "off" },
"rules": {
"error-plugin/error": "error"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
```
Failed to parse configuration file.

x Failed to load JS plugin: ./plugin.js
x Failed to load JS plugin: ./plugin.ts
| Error: Whoops!
| at Object.createOnce (<root>/apps/oxlint/test/fixtures/custom_plugin_lint_createOnce_error/plugin.js:8:15)
| at Object.createOnce (<root>/apps/oxlint/test/fixtures/custom_plugin_lint_createOnce_error/plugin.ts:10:15)
```

# stderr
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export default {
import type { Plugin } from '../../../dist/index.js';

const plugin: Plugin = {
meta: {
name: 'error-plugin',
},
Expand All @@ -10,3 +12,5 @@ export default {
},
},
};

export default plugin;
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"jsPlugins": ["./plugin.js"],
"jsPlugins": ["./plugin.ts"],
"categories": { "correctness": "off" },
"rules": {
"error-plugin/error": "error"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
x Error running JS plugin.
| File path: <root>/apps/oxlint/test/fixtures/custom_plugin_lint_create_error/files/index.js
| Error: Whoops!
| at Object.create (<root>/apps/oxlint/test/fixtures/custom_plugin_lint_create_error/plugin.js:8:15)
| at Object.create (<root>/apps/oxlint/test/fixtures/custom_plugin_lint_create_error/plugin.ts:10:15)

Found 0 warnings and 1 error.
Finished in Xms on 1 file using X threads.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export default {
import type { Plugin } from '../../../dist/index.js';

const plugin: Plugin = {
meta: {
name: 'error-plugin',
},
Expand All @@ -10,3 +12,5 @@ export default {
},
},
};

export default plugin;
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"jsPlugins": ["./plugin.js"],
"jsPlugins": ["./plugin.ts"],
"categories": { "correctness": "off" },
"rules": {
"error-plugin/error": "error"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
x Error running JS plugin.
| File path: <root>/apps/oxlint/test/fixtures/custom_plugin_lint_fix_error/files/index.js
| Error: Whoops!
| at Object.fix (<root>/apps/oxlint/test/fixtures/custom_plugin_lint_fix_error/plugin.js:14:23)
| at Identifier (<root>/apps/oxlint/test/fixtures/custom_plugin_lint_fix_error/plugin.js:10:21)
| at Object.fix (<root>/apps/oxlint/test/fixtures/custom_plugin_lint_fix_error/plugin.ts:16:23)
| at Identifier (<root>/apps/oxlint/test/fixtures/custom_plugin_lint_fix_error/plugin.ts:12:21)

Found 0 warnings and 1 error.
Finished in Xms on 1 file using X threads.
Expand Down
Loading
Loading