Skip to content

Commit

Permalink
Add type definitions for eslint packages (babel#16854)
Browse files Browse the repository at this point in the history
  • Loading branch information
liuxingbaoyu authored Sep 26, 2024
1 parent 61d0573 commit 76a4cbc
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 3 deletions.
2 changes: 2 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ export default [
allowDefaultProject: [
"packages/babel-helpers/src/helpers/applyDecs2305.ts",
"scripts/repo-utils/index.d.cts",
"eslint/babel-eslint-plugin/types.d.cts",
"eslint/babel-eslint-parser/types.d.cts",
],
},
},
Expand Down
11 changes: 9 additions & 2 deletions eslint/babel-eslint-parser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,16 @@
},
"main": "./lib/index.cjs",
"type": "module",
"types": "./types.d.cts",
"exports": {
".": "./lib/index.cjs",
"./experimental-worker": "./lib/experimental-worker.cjs",
".": {
"default": "./lib/index.cjs",
"types": "./types.d.cts"
},
"./experimental-worker": {
"default": "./lib/experimental-worker.cjs",
"types": "./types.d.cts"
},
"./package.json": "./package.json"
},
"peerDependencies": {
Expand Down
9 changes: 9 additions & 0 deletions eslint/babel-eslint-parser/types.d.cts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import type { ESLint, Linter, AST } from "eslint";

export declare const meta: ESLint.ObjectMetaProperties["meta"];

export declare const parse: (text: string, options?: any) => AST.Program;
export declare const parseForESLint: (
text: string,
options?: any
) => Linter.ESLintParseResult;
6 changes: 5 additions & 1 deletion eslint/babel-eslint-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@
"description": "Companion rules for @babel/eslint-parser",
"main": "./lib/index.cjs",
"type": "module",
"types": "./types.d.cts",
"exports": {
".": "./lib/index.cjs",
".": {
"default": "./lib/index.cjs",
"types": "./types.d.cts"
},
"./package.json": "./package.json"
},
"publishConfig": {
Expand Down
13 changes: 13 additions & 0 deletions eslint/babel-eslint-plugin/types.d.cts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import type { ESLint, Rule } from "eslint";

type Rules =
| "new-cap"
| "no-invalid-this"
| "no-undef"
| "no-unused-expressions"
| "object-curly-spacing"
| "semi";

export declare const meta: ESLint.ObjectMetaProperties["meta"];
export declare const rules: Record<Rules, Rule.RuleModule>;
export declare const rulesConfig: Record<Rules, string>;

0 comments on commit 76a4cbc

Please sign in to comment.