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
3 changes: 2 additions & 1 deletion apps/oxlint/conformance/src/groups/stylistic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import type {
LanguageOptions,
ParserOptions,
} from "../rule_tester.ts";
import type { Rule, RuleTester as RuleTesterType } from "#oxlint";
import type { RuleTester as RuleTesterType } from "#oxlint/rule-tester";
import type { Rule } from "#oxlint/plugin";

type Config = RuleTesterType.Config;

Expand Down
4 changes: 2 additions & 2 deletions apps/oxlint/conformance/src/rule_tester.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

// @ts-expect-error - internal module of ESLint with no types
import eslintGlobals from "../submodules/eslint/conf/globals.js";
import { RuleTester } from "#oxlint";
import { RuleTester } from "#oxlint/rule-tester";
import { describe, it, setCurrentTest } from "./capture.ts";
import { SHOULD_SKIP_CODE } from "./filter.ts";

import type { Rule } from "#oxlint";
import type { Rule } from "#oxlint/plugin";
import type { ParserDetails } from "./index.ts";
import type {
LanguageOptionsInternal,
Expand Down
2 changes: 1 addition & 1 deletion apps/oxlint/conformance/tester.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { RuleTester as ESLintRuleTester } from "eslint";
import { builtinRules } from "./submodules/eslint/lib/unsupported-api.js";
import tsEslintParser from "@typescript-eslint/parser";

import type { Rule } from "#oxlint";
import type { Rule } from "#oxlint/plugin";
import type { ValidTestCase, InvalidTestCase } from "./src/rule_tester.ts";

type ValidTestCaseWithoutCode = Omit<ValidTestCase, "code"> & { code?: string };
Expand Down
18 changes: 17 additions & 1 deletion apps/oxlint/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,23 @@
"type": "module",
"main": "dist/index.js",
"imports": {
"#oxlint": "./dist/index.js"
"#oxlint": "./dist/index.js",
"#oxlint/plugin": "./dist/plugin.js",
"#oxlint/rule-tester": "./dist/rule-tester.js"
},
"exports": {
".": {
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
},
"./plugin": {
"types": "./dist/plugin.d.ts",
"default": "./dist/plugin.js"
},
"./rule-tester": {
"types": "./dist/rule-tester.d.ts",
"default": "./dist/rule-tester.js"
}
},
"scripts": {
"build": "pnpm run build-napi-release && pnpm run build-js",
Expand Down
73 changes: 15 additions & 58 deletions apps/oxlint/src-js/index.ts
Original file line number Diff line number Diff line change
@@ -1,60 +1,17 @@
// Functions and classes
export { definePlugin, defineRule } from "./package/define.ts";
export { RuleTester } from "./package/rule_tester.ts";
import { definePlugin as _definePlugin, defineRule as _defineRule } from "./package/define.ts";
import { RuleTester as _RuleTester } from "./package/rule_tester.ts";

// ESTree types
export type * as ESTree from "./generated/types.d.ts";
/**
* @deprecated Import from `oxlint/plugin` instead
*/
export const definePlugin = _definePlugin;

// Plugin types
export type { Context, LanguageOptions } from "./plugins/context.ts";
export type { Fix, Fixer, FixFn } from "./plugins/fix.ts";
export type { Globals, Envs } from "./plugins/globals.ts";
export type { CreateOnceRule, CreateRule, Plugin, Rule } from "./plugins/load.ts";
export type { Options, RuleOptionsSchema } from "./plugins/options.ts";
export type { Diagnostic, DiagnosticData, Suggestion } from "./plugins/report.ts";
export type {
Definition,
DefinitionType,
Reference,
Scope,
ScopeManager,
ScopeType,
Variable,
} from "./plugins/scope.ts";
export type { Settings } from "./plugins/settings.ts";
export type { SourceCode } from "./plugins/source_code.ts";
export type {
CountOptions,
FilterFn,
RangeOptions,
SkipOptions,
Token,
BooleanToken,
IdentifierToken,
JSXIdentifierToken,
JSXTextToken,
KeywordToken,
NullToken,
NumericToken,
PrivateIdentifierToken,
PunctuatorToken,
RegularExpressionToken,
StringToken,
TemplateToken,
} from "./plugins/tokens.ts";
export type {
RuleMeta,
RuleDocs,
RuleDeprecatedInfo,
RuleReplacedByInfo,
RuleReplacedByExternalSpecifier,
} from "./plugins/rule_meta.ts";
export type { LineColumn, Location, Range, Ranged, Span } from "./plugins/location.ts";
export type {
AfterHook,
BeforeHook,
Comment,
Node,
Visitor,
VisitorWithHooks,
} from "./plugins/types.ts";
/**
* @deprecated Import from `oxlint/plugin` instead
*/
export const defineRule = _defineRule;

/**
* @deprecated Import from `oxlint/rule-tester` instead
*/
export const RuleTester = _RuleTester;
59 changes: 59 additions & 0 deletions apps/oxlint/src-js/plugin.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
// Entry point for definePlugin and defineRule
export { definePlugin, defineRule } from "./package/define.ts";

// ESTree types
export type * as ESTree from "./generated/types.d.ts";

// Plugin types
export type { Context, LanguageOptions } from "./plugins/context.ts";
export type { Fix, Fixer, FixFn } from "./plugins/fix.ts";
export type { Globals, Envs } from "./plugins/globals.ts";
export type { CreateOnceRule, CreateRule, Plugin, Rule } from "./plugins/load.ts";
export type { Options, RuleOptionsSchema } from "./plugins/options.ts";
export type { Diagnostic, DiagnosticData, Suggestion } from "./plugins/report.ts";
export type {
Definition,
DefinitionType,
Reference,
Scope,
ScopeManager,
ScopeType,
Variable,
} from "./plugins/scope.ts";
export type { Settings } from "./plugins/settings.ts";
export type { SourceCode } from "./plugins/source_code.ts";
export type {
CountOptions,
FilterFn,
RangeOptions,
SkipOptions,
Token,
BooleanToken,
IdentifierToken,
JSXIdentifierToken,
JSXTextToken,
KeywordToken,
NullToken,
NumericToken,
PrivateIdentifierToken,
PunctuatorToken,
RegularExpressionToken,
StringToken,
TemplateToken,
} from "./plugins/tokens.ts";
export type {
RuleMeta,
RuleDocs,
RuleDeprecatedInfo,
RuleReplacedByInfo,
RuleReplacedByExternalSpecifier,
} from "./plugins/rule_meta.ts";
export type { LineColumn, Location, Range, Ranged, Span } from "./plugins/location.ts";
export type {
AfterHook,
BeforeHook,
Comment,
Node,
Visitor,
VisitorWithHooks,
} from "./plugins/types.ts";
1 change: 1 addition & 0 deletions apps/oxlint/src-js/rule-tester.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { RuleTester } from "./package/rule_tester.ts";
2 changes: 1 addition & 1 deletion apps/oxlint/test/fixtures/basic/plugin.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Plugin } from "#oxlint";
import type { Plugin } from "#oxlint/plugin";

const plugin: Plugin = {
meta: {
Expand Down
2 changes: 1 addition & 1 deletion apps/oxlint/test/fixtures/basic_many_files/plugin.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Plugin } from "#oxlint";
import type { Plugin } from "#oxlint/plugin";

const plugin: Plugin = {
meta: {
Expand Down
2 changes: 1 addition & 1 deletion apps/oxlint/test/fixtures/basic_multiple_rules/plugin.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Plugin } from "#oxlint";
import type { Plugin } from "#oxlint/plugin";

const plugin: Plugin = {
meta: {
Expand Down
2 changes: 1 addition & 1 deletion apps/oxlint/test/fixtures/basic_no_errors/plugin.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Plugin } from "#oxlint";
import type { Plugin } from "#oxlint/plugin";

const plugin: Plugin = {
meta: {
Expand Down
2 changes: 1 addition & 1 deletion apps/oxlint/test/fixtures/basic_warn_severity/plugin.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Plugin } from "#oxlint";
import type { Plugin } from "#oxlint/plugin";

const plugin: Plugin = {
meta: {
Expand Down
2 changes: 1 addition & 1 deletion apps/oxlint/test/fixtures/bom/plugin.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Plugin } from "#oxlint";
import type { Plugin } from "#oxlint/plugin";

const plugin: Plugin = {
meta: {
Expand Down
2 changes: 1 addition & 1 deletion apps/oxlint/test/fixtures/cfg/plugin.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Plugin, Rule, ESTree } from "#oxlint";
import type { Plugin, Rule, ESTree } from "#oxlint/plugin";

type Node = ESTree.Node;

Expand Down
2 changes: 1 addition & 1 deletion apps/oxlint/test/fixtures/comments/plugin.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import assert from "node:assert";

import type { Comment, Plugin, Rule } from "#oxlint";
import type { Comment, Plugin, Rule } from "#oxlint/plugin";

function formatComments(comments: Comment[]): string {
let text = `${comments.length} comment${comments.length === 1 ? "" : "s"}`;
Expand Down
2 changes: 1 addition & 1 deletion apps/oxlint/test/fixtures/context_properties/plugin.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Node, Plugin, Rule } from "#oxlint";
import type { Node, Plugin, Rule } from "#oxlint/plugin";

const SPAN: Node = {
start: 0,
Expand Down
2 changes: 1 addition & 1 deletion apps/oxlint/test/fixtures/context_wrapping/plugin.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Plugin, Rule, Context, Diagnostic, Node } from "#oxlint";
import type { Plugin, Rule, Context, Diagnostic, Node } from "#oxlint/plugin";

const SPAN: Node = {
start: 0,
Expand Down
2 changes: 1 addition & 1 deletion apps/oxlint/test/fixtures/createOnce/plugin.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Node, Plugin, Rule } from "#oxlint";
import type { Node, Plugin, Rule } from "#oxlint/plugin";

const SPAN: Node = {
start: 0,
Expand Down
4 changes: 2 additions & 2 deletions apps/oxlint/test/fixtures/definePlugin/plugin.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { definePlugin } from "#oxlint";
import { definePlugin } from "#oxlint/plugin";

import type { Node, Rule } from "#oxlint";
import type { Node, Rule } from "#oxlint/plugin";

const SPAN: Node = {
start: 0,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { definePlugin, defineRule } from "#oxlint";
import { definePlugin, defineRule } from "#oxlint/plugin";

import type { Node } from "#oxlint";
import type { Node } from "#oxlint/plugin";

const SPAN: Node = {
start: 0,
Expand Down
4 changes: 2 additions & 2 deletions apps/oxlint/test/fixtures/defineRule/plugin.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { defineRule } from "#oxlint";
import { defineRule } from "#oxlint/plugin";

import type { Node } from "#oxlint";
import type { Node } from "#oxlint/plugin";

const SPAN: Node = {
start: 0,
Expand Down
2 changes: 1 addition & 1 deletion apps/oxlint/test/fixtures/diagnostic_loc/plugin.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Plugin } from "#oxlint";
import type { Plugin } from "#oxlint/plugin";

const plugin: Plugin = {
meta: {
Expand Down
2 changes: 1 addition & 1 deletion apps/oxlint/test/fixtures/disable_directives/plugin.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Plugin } from "#oxlint";
import type { Plugin } from "#oxlint/plugin";

const plugin: Plugin = {
meta: {
Expand Down
2 changes: 1 addition & 1 deletion apps/oxlint/test/fixtures/estree/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import assert from "node:assert";

import type { Plugin } from "#oxlint";
import type { Plugin } from "#oxlint/plugin";

const plugin: Plugin = {
meta: {
Expand Down
2 changes: 1 addition & 1 deletion apps/oxlint/test/fixtures/fixes/plugin.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Diagnostic, Node, Plugin } from "#oxlint";
import type { Diagnostic, Node, Plugin } from "#oxlint/plugin";

const plugin: Plugin = {
meta: {
Expand Down
2 changes: 1 addition & 1 deletion apps/oxlint/test/fixtures/getNodeByRangeIndex/plugin.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Plugin, Rule } from "#oxlint";
import type { Plugin, Rule } from "#oxlint/plugin";

const rule: Rule = {
create(context) {
Expand Down
2 changes: 1 addition & 1 deletion apps/oxlint/test/fixtures/globals/plugin.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Node, Plugin } from "#oxlint";
import type { Node, Plugin } from "#oxlint/plugin";

const SPAN: Node = {
start: 0,
Expand Down
2 changes: 1 addition & 1 deletion apps/oxlint/test/fixtures/isSpaceBetween/plugin.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import assert from "node:assert";

import type { Plugin, Rule, Node } from "#oxlint";
import type { Plugin, Rule, Node } from "#oxlint/plugin";

const testRule: Rule = {
create(context) {
Expand Down
2 changes: 1 addition & 1 deletion apps/oxlint/test/fixtures/languageOptions/plugin.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import assert from "node:assert";

import type { Plugin, Node } from "#oxlint";
import type { Plugin, Node } from "#oxlint/plugin";

const SPAN: Node = {
start: 0,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Plugin } from "#oxlint";
import type { Plugin } from "#oxlint/plugin";

const plugin: Plugin = {
meta: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Plugin } from "#oxlint";
import type { Plugin } from "#oxlint/plugin";

const plugin: Plugin = {
meta: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Plugin } from "#oxlint";
import type { Plugin } from "#oxlint/plugin";

const plugin: Plugin = {
meta: {
Expand Down
2 changes: 1 addition & 1 deletion apps/oxlint/test/fixtures/lint_create_error/plugin.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Plugin } from "#oxlint";
import type { Plugin } from "#oxlint/plugin";

const plugin: Plugin = {
meta: {
Expand Down
2 changes: 1 addition & 1 deletion apps/oxlint/test/fixtures/lint_fix_error/plugin.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Plugin } from "#oxlint";
import type { Plugin } from "#oxlint/plugin";

const plugin: Plugin = {
meta: {
Expand Down
2 changes: 1 addition & 1 deletion apps/oxlint/test/fixtures/lint_visit_cfg_error/plugin.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import assert from "node:assert";

import type { Plugin, Rule, ESTree } from "#oxlint";
import type { Plugin, Rule, ESTree } from "#oxlint/plugin";

type Node = ESTree.Node;

Expand Down
2 changes: 1 addition & 1 deletion apps/oxlint/test/fixtures/lint_visit_error/plugin.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import assert from "node:assert";

import type { Plugin, Rule } from "#oxlint";
import type { Plugin, Rule } from "#oxlint/plugin";

// Aim of this test is:
//
Expand Down
2 changes: 1 addition & 1 deletion apps/oxlint/test/fixtures/load_paths/plugins/plugin4.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Plugin } from "#oxlint";
import type { Plugin } from "#oxlint/plugin";

const plugin: Plugin = {
meta: {
Expand Down
Loading
Loading