Skip to content

Commit

Permalink
chore: add type definitions for the eslint-config-eslint package (#…
Browse files Browse the repository at this point in the history
…19050)

feat: Add type definitions for `eslint-config-eslint`

Resolves #19043
  • Loading branch information
aryaemami59 authored Dec 6, 2024
1 parent ba098bd commit 9bf2204
Show file tree
Hide file tree
Showing 18 changed files with 343 additions and 138 deletions.
29 changes: 24 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -114,17 +114,36 @@ jobs:
wdio-logs/*.log
test_types:
name: Types Test
name: Test Types of ${{ matrix.package.name }}
runs-on: ubuntu-latest

strategy:
matrix:
package:
[
{ name: eslint, directory: . },
{
name: eslint-config-eslint,
directory: packages/eslint-config-eslint,
},
{
name: '@eslint/js',
directory: packages/js,
},
]

steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "lts/*"
- name: Install Packages
run: npm install
- name: Test eslint types
run: npm run test:types
- name: Test @eslint/js types

- name: Install Packages for ${{ matrix.package.name }}
working-directory: ${{ matrix.package.directory }}
run: npm install

- name: Test types for ${{ matrix.package.name }}
working-directory: ${{ matrix.package.directory }}
run: npm run test:types
working-directory: packages/js
20 changes: 15 additions & 5 deletions .github/workflows/types-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -150,20 +150,30 @@ jobs:
are-the-types-wrong:
name: Are the types wrong?
runs-on: ubuntu-latest

strategy:
matrix:
package:
[
{ name: eslint, directory: . },
{
name: eslint-config-eslint,
directory: packages/eslint-config-eslint,
},
]

steps:
- name: Checkout eslint
- name: Checkout ${{ matrix.package.name }}
uses: actions/checkout@v4
with:
path: eslint

- uses: actions/setup-node@v4
with:
node-version: "lts/*"

- name: Install Packages
working-directory: eslint
working-directory: ${{ matrix.package.directory }}
run: npm install

- name: Check validity of type definitions
working-directory: eslint
working-directory: ${{ matrix.package.directory }}
run: npm run lint:types
5 changes: 4 additions & 1 deletion eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ function createInternalFilesPatterns(pattern = null) {
}));
}

/**
* @type {import("./lib/types/index.js").Linter.Config[]}
*/
module.exports = [
...eslintConfigESLintCJS.map(config => ({
...config,
Expand Down Expand Up @@ -296,7 +299,7 @@ module.exports = [
languageOptions: {
parser: tsParser,
parserOptions: {
project: ["tests/lib/types/tsconfig.json", "packages/js/tests/types/tsconfig.json"]
project: ["tests/lib/types/tsconfig.json", "packages/js/tests/types/tsconfig.json", "packages/eslint-config-eslint/tsconfig.json"]
}
},
plugins: {
Expand Down
3 changes: 2 additions & 1 deletion knip.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
},
// Workspaces with default configs:
"packages/*": {
"ignore": ["tests/types/**"]
"ignore": ["tests/types/**"],
"ignoreDependencies": ["eslint"]
},
"tools/internal-rules": {}
}
Expand Down
15 changes: 15 additions & 0 deletions packages/eslint-config-eslint/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ const eslintCommentsPluginConfigs = require("@eslint-community/eslint-plugin-esl
const unicorn = require("eslint-plugin-unicorn");

// extends eslint recommended config
/**
* @type {import("eslint").Linter.Config[]}
*/
const jsConfigs = [js.configs.recommended, {
name: "eslint-config-eslint/js",
rules: {
Expand Down Expand Up @@ -142,6 +145,9 @@ const jsConfigs = [js.configs.recommended, {
}];

// extends eslint-plugin-jsdoc's recommended config
/**
* @type {import("eslint").Linter.Config[]}
*/
const jsdocConfigs = [jsdoc.configs["flat/recommended"], {
name: "eslint-config-eslint/jsdoc",
settings: {
Expand Down Expand Up @@ -234,6 +240,9 @@ const jsdocConfigs = [jsdoc.configs["flat/recommended"], {
}];

// extends eslint-plugin-unicorn's config
/**
* @type {import("eslint").Linter.Config[]}
*/
const unicornConfigs = [{
name: "eslint-config-eslint/unicorn",
plugins: { unicorn },
Expand All @@ -253,6 +262,9 @@ const unicornConfigs = [{
}];

// extends @eslint-community/eslint-plugin-eslint-comments's recommended config
/**
* @type {import("eslint").Linter.Config[]}
*/
const eslintCommentsConfigs = [eslintCommentsPluginConfigs.recommended, {
name: "eslint-config-eslint/eslint-comments",
rules: {
Expand All @@ -262,6 +274,9 @@ const eslintCommentsConfigs = [eslintCommentsPluginConfigs.recommended, {
}
}];

/**
* @type {import("eslint").Linter.Config[]}
*/
module.exports = [
{ name: "eslint-config-eslint/base", linterOptions: { reportUnusedDisableDirectives: "error" } },
...jsConfigs,
Expand Down
3 changes: 3 additions & 0 deletions packages/eslint-config-eslint/cjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
const baseConfigs = require("./base");
const { cjsConfigs } = require("./nodejs");

/**
* @type {import("eslint").Linter.Config[]}
*/
module.exports = [
...baseConfigs,
...cjsConfigs
Expand Down
Loading

0 comments on commit 9bf2204

Please sign in to comment.