Skip to content
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
41 changes: 33 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ jobs:
node-version: "lts/*"
- name: Install dependencies
run: npm install
- name: Build packages
run: npm run build
- name: Lint files
run: npm run lint
- name: Lint Files, Dependencies, & Exports
Expand All @@ -36,8 +34,6 @@ jobs:
node-version: lts/*
- name: Install dependencies
run: npm install
- name: Build packages
run: npm run build
- name: Prettier Check
run: npm run fmt:check

Expand All @@ -60,11 +56,42 @@ jobs:
node-version: ${{ matrix.node }}
- name: Install dependencies
run: npm install
- name: Build packages
run: npm run build
- name: Run tests
run: npm run test

test_types:
name: Test Types
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v6

- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: "lts/*"

- name: Install Packages
run: npm install

- name: Test types (eslint-scope)
run: npm run test:types -w packages/eslint-scope

- name: Test types (eslint-visitor-keys)
run: npm run test:types -w packages/eslint-visitor-keys

- name: Test types (espree)
run: npm run test:types -w packages/espree

- name: Check dist types compile (TypeScript 5.3)
run: npm run test:types:5.3

- name: Check dist types compile (TypeScript 5.x)
run: npm run test:types:5.x

- name: Check dist types compile (TypeScript 7 preview)
run: npm run test:types:7.x

are-the-types-wrong:
name: Are the types wrong?
runs-on: ubuntu-latest
Expand All @@ -76,7 +103,5 @@ jobs:
node-version: "lts/*"
- name: Install dependencies
run: npm install
- name: Build types
run: npm run build:types
- name: Are the types wrong?
run: npm run lint:types
2 changes: 1 addition & 1 deletion knip.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"entry": ["test-d/**/*.test-d.ts"]
},
"packages/espree": {
"entry": ["espree.cts", "test-d/**/*.test-d.ts", "tools/**/*.js"],
"entry": ["test-d/**/*.test-d.ts", "tools/**/*.js"],
"ignore": ["tests/fixtures/**"]
}
}
Expand Down
12 changes: 9 additions & 3 deletions package.json
Comment thread
sethamus marked this conversation as resolved.
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,19 @@
"scripts": {
"build": "npm run build --workspaces --if-present",
"build:types": "npm run build:types --workspaces --if-present",
"prepare": "npm run build",
"lint": "eslint",
"lint:fix": "eslint --fix",
"lint:types": "npm run lint:types --workspaces --if-present",
"lint:unused": "knip",
"fmt": "prettier --write .",
"fmt:check": "prettier --check .",
"test": "npm test --workspaces --if-present"
"test": "npm test --workspaces --if-present",
"test:types": "npm run test:types --workspaces --if-present",
"test:types:5.3": "npx -p [email protected] -y -- tsc -p tsconfig.dist-legacy.json",
"test:types:5.x": "npx -p [email protected] -y -- tsc -p tsconfig.dist.json",
"test:types:7.x": "npx -p @typescript/native-preview@latest -y -- tsgo -p tsconfig.dist.json",
"test:types:all": "npm run test:types && npm run test:types:5.3 && npm run test:types:5.x && npm run test:types:7.x"
},
"workspaces": [
"packages/*"
Expand All @@ -29,7 +35,7 @@
"devDependencies": {
"@arethetypeswrong/cli": "^0.18.2",
"@types/node": "^20.19.0",
"@typescript-eslint/parser": "^8.56.1",
"@typescript-eslint/parser": "^8.59.0",
"c8": "^11.0.0",
"eslint": "^10.0.3",
"eslint-config-eslint": "^14.0.0",
Expand All @@ -41,7 +47,7 @@
"mocha": "^11.1.0",
"prettier": "3.8.3",
"rollup": "^4.55.2",
"typescript": "^5.9.3",
"typescript": "^6.0.3",
"yorkie": "^2.0.0"
}
}
2 changes: 1 addition & 1 deletion packages/eslint-scope/lib/index.d.cts
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ export class Scope<
*/
constructor(
scopeManager: ScopeManager,
type: typeof this.type,
type: Scope["type"],
upperScope: Scope | null,
block: ESTree.Node,
isMethodDefinition: boolean,
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-scope/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
"estraverse": "^5.2.0"
},
"devDependencies": {
"@typescript-eslint/parser": "^8.7.0",
"@typescript-eslint/parser": "^8.59.0",
"chai": "^6.0.0",
"eslint": ">=10.0.0-rc.0 <10.0.0 || ^10.0.0",
"eslint-visitor-keys": "^5.0.1",
Expand Down
13 changes: 1 addition & 12 deletions packages/eslint-scope/tests/types/cjs-import.test.cts
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason why the named export test was removed?

This test verifies that the named export types exist correctly in the CJS export, so I think it need to be retained.

Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,4 @@
// Imports
//-----------------------------------------------------------------------------

// Make sure the named exports exist.
import {
Definition,
PatternVisitor,
Reference,
Referencer,
ScopeManager,
Scope,
Variable,
analyze,
version,
} from "eslint-scope";
import "eslint-scope";
11 changes: 9 additions & 2 deletions packages/eslint-scope/tests/types/tsconfig.json
Comment thread
sethamus marked this conversation as resolved.
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"allowJs": false,
"checkJs": false,
"strict": true
"noEmit": true,
"rootDir": "../..",
"noImplicitAny": true,
"exactOptionalPropertyTypes": true,
"verbatimModuleSyntax": true,
"erasableSyntaxOnly": true
},
"include": [".", "../../lib"]
"files": [],
"include": [".", "../../dist"]
}
18 changes: 6 additions & 12 deletions packages/eslint-scope/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
{
"extends": "../../tsconfig.base.json",
"files": ["lib/index.js"],
"compilerOptions": {
"checkJs": true,
"exactOptionalPropertyTypes": true,
"forceConsistentCasingInFileNames": true,
"lib": ["es2022"],
"module": "nodenext",
"noEmit": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"types": []
},
"include": ["lib"]
"noImplicitAny": false,
"rootDir": "lib",
"outDir": "dist"
}
}
7 changes: 6 additions & 1 deletion packages/eslint-visitor-keys/test-d/index.test-d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import { expectType, expectAssignable } from "tsd";

import { KEYS, getKeys, unionWith, VisitorKeys } from "../";
import {
KEYS,
getKeys,
unionWith,
VisitorKeys,
} from "../dist/eslint-visitor-keys.cjs";
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
} from "../dist/eslint-visitor-keys.cjs";
} from "eslint-visitor-keys";

I think simply using eslint-visitor-keys would be more accurate here, since the previous test using ../ resolved the type declaration file from the Module declaration surface rather than the CJS format. It was originally linked to lib/index.js and directed to dist/index.d.ts.

Additionally, using eslint-visitor-keys directly would be more beneficial, as it follows the same package-name type resolution path used by real consumers, since it is symlinked in node_modules and consumed like a real package.


const assignmentExpression = {
type: "AssignmentExpression",
Expand Down
20 changes: 4 additions & 16 deletions packages/eslint-visitor-keys/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,8 @@
{
"extends": "../../tsconfig.base.json",
"files": ["lib/index.js"],
"compilerOptions": {
"lib": ["esnext"],
"moduleResolution": "node",
"module": "esnext",
"resolveJsonModule": true,
"allowJs": true,
"checkJs": true,
"noEmit": false,
"declaration": true,
"declarationMap": true,
"emitDeclarationOnly": true,
"strict": true,
"exactOptionalPropertyTypes": true,
"target": "es6",
"rootDir": "lib",
"outDir": "dist"
},
"include": ["lib/**/*.js"],
"exclude": ["node_modules"]
}
}
2 changes: 0 additions & 2 deletions packages/espree/espree.cts

This file was deleted.

3 changes: 2 additions & 1 deletion packages/espree/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
"eslint-visitor-keys": "^5.0.1"
},
"devDependencies": {
"rollup-plugin-dts": "^6.4.1",
"shelljs": "^0.10.0",
"tsd": "^0.33.0"
},
Expand All @@ -58,7 +59,7 @@
"build": "rollup -c rollup.config.js && npm run build:types && node -e \"fs.rmSync('dist/lib', { recursive: true })\"",
"build:debug": "npm run build -- -m",
"build:docs": "node tools/sync-docs.js",
"build:types": "tsc && tsc -p tsconfig-cjs.json",
"build:types": "tsc",
"lint:types": "attw --pack",
"pretest": "npm run build",
"test": "npm run test:types && npm run test:cjs && npm run test:esm",
Expand Down
29 changes: 21 additions & 8 deletions packages/espree/rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,22 @@
export default {
input: "espree.js",
external: ["acorn", "acorn-jsx", "eslint-visitor-keys"],
treeshake: false,
output: {
file: "dist/espree.cjs",
format: "cjs",
import { dts } from "rollup-plugin-dts";

export default [
{
input: "espree.js",
external: ["acorn", "acorn-jsx", "eslint-visitor-keys"],
treeshake: false,
output: {
file: "dist/espree.cjs",
format: "cjs",
},
},
};
{
plugins: [dts()],
input: "espree.js",
treeshake: false,
output: {
file: "dist/espree.d.cts",
format: "cjs",
},
},
];
19 changes: 0 additions & 19 deletions packages/espree/tsconfig-cjs.json

This file was deleted.

18 changes: 3 additions & 15 deletions packages/espree/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,7 @@
{
"extends": "../../tsconfig.base.json",
"files": ["espree.js"],
"compilerOptions": {
"lib": ["ESNext"],
"moduleResolution": "nodenext",
"module": "nodenext",
"allowJs": true,
"checkJs": true,
"noEmit": false,
"declaration": true,
"declarationMap": true,
"emitDeclarationOnly": true,
"strict": true,
"exactOptionalPropertyTypes": true,
"target": "es6",
"outDir": "dist"
},
"include": ["espree.js", "lib/**/*.js"],
"exclude": ["node_modules"]
}
}
14 changes: 14 additions & 0 deletions tsconfig.base.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"compilerOptions": {
"allowImportingTsExtensions": true,
"allowJs": true,
"checkJs": true,
"declaration": true,
Comment thread
sethamus marked this conversation as resolved.
"declarationMap": true,
"emitDeclarationOnly": true,
"module": "NodeNext",
"moduleResolution": "NodeNext",
"strict": true,
"target": "ES2022"
}
}
14 changes: 14 additions & 0 deletions tsconfig.dist-legacy.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"extends": "./tsconfig.base.json",
"compilerOptions": {
"allowJs": false,
"checkJs": false,
"emitDeclarationOnly": false,
"noEmit": true,
"strict": true,
"exactOptionalPropertyTypes": true,
"verbatimModuleSyntax": true
// "erasableSyntaxOnly" is not supported in TypeScript < 5.8.
},
"include": ["packages/*/dist", "packages/*/tests/types"]
}
14 changes: 14 additions & 0 deletions tsconfig.dist.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"extends": "./tsconfig.base.json",
"compilerOptions": {
"allowJs": false,
"checkJs": false,
"emitDeclarationOnly": false,
"noEmit": true,
"strict": true,
"exactOptionalPropertyTypes": true,
"verbatimModuleSyntax": true,
"erasableSyntaxOnly": true
},
"include": ["packages/*/dist", "packages/*/tests/types"]
}