Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[New] add TypeScript types #3097

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
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
13 changes: 13 additions & 0 deletions .github/workflows/node-pretest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,19 @@ jobs:
# skip-ls-check: true
# - run: npm run pretest

types:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ljharb/actions/node/install@main
name: 'npm install'
with:
skip-ls-check: true
# for some reason we've got to force typescript to install here
# even though the npm script has `typescript@latest`
- run: npm i --force typescript@latest
- run: npm run test-types

posttest:
runs-on: ubuntu-latest

Expand Down
33 changes: 33 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { ESLint, Linter, Rule } from 'eslint';

declare const plugin: ESLint.Plugin & {
meta: {
name: string;
version: string;
};
configs: {
'recommended': Linter.LegacyConfig;
'errors': Linter.LegacyConfig;
'warnings': Linter.LegacyConfig;
'stage-0': Linter.LegacyConfig;
'react': Linter.LegacyConfig;
'react-native': Linter.LegacyConfig;
'electron': Linter.LegacyConfig;
'typescript': Linter.LegacyConfig;
};
flatConfigs: {
'recommended': Linter.FlatConfig;
'errors': Linter.FlatConfig;
'warnings': Linter.FlatConfig;
'stage-0': Linter.FlatConfig;
'react': Linter.FlatConfig;
'react-native': Linter.FlatConfig;
'electron': Linter.FlatConfig;
'typescript': Linter.FlatConfig;
};
rules: {
[key: string]: Rule.RuleModule;
};
G-Rath marked this conversation as resolved.
Show resolved Hide resolved
};

export = plugin;
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"node": ">=4"
},
"main": "lib/index.js",
"types": "index.d.ts",
"directories": {
"test": "tests"
},
Expand All @@ -16,7 +17,8 @@
"docs",
"lib",
"config",
"memo-parser/{*.js,LICENSE,*.md}"
"memo-parser/{*.js,LICENSE,*.md}",
"index.d.ts"
],
"scripts": {
"prebuild": "rimraf lib",
Expand All @@ -34,6 +36,7 @@
"test-examples": "npm run build && npm run test-example:legacy && npm run test-example:flat",
"test-example:legacy": "cd examples/legacy && npm install && npm run lint",
"test-example:flat": "cd examples/flat && npm install && npm run lint",
"test-types": "npx --package typescript@latest tsc --noEmit index.d.ts",
G-Rath marked this conversation as resolved.
Show resolved Hide resolved
"prepublishOnly": "safe-publish-latest && npm run build",
"prepublish": "not-in-publish || npm run prepublishOnly",
"preupdate:eslint-docs": "npm run build",
Expand Down Expand Up @@ -63,6 +66,7 @@
"@angular-eslint/template-parser": "^13.5.0",
"@eslint/import-test-order-redirect-scoped": "file:./tests/files/order-redirect-scoped",
"@test-scope/some-module": "file:./tests/files/symlinked-module",
"@types/eslint": "^8.56.12",
"@typescript-eslint/parser": "^2.23.0 || ^3.3.0 || ^4.29.3 || ^5.10.0",
"babel-cli": "^6.26.0",
"babel-core": "^6.26.3",
Expand Down
Loading