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
72 changes: 67 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ jobs:
run: npm run lint

test:
name:
🧪 Test (Node@${{ matrix.node }} - ESLint@${{ matrix.eslint }} - ${{
name: 🧪 Test (Node@${{ matrix.node }} - ESLint@${{ matrix.eslint }} - ${{
matrix.os }})
strategy:
fail-fast: false
Expand Down Expand Up @@ -97,12 +96,75 @@ jobs:
- name: ⬆️ Upload coverage report
uses: codecov/codecov-action@v4

are-the-types-wrong:
name: 🤔 Are the types wrong?
runs-on: ubuntu-latest
steps:
- name: ⬇️ Checkout repo
uses: actions/checkout@v4

- name: ⎔ Setup Node
uses: actions/setup-node@v4
with:
node-version: 18

- name: 📥 Install dependencies
run: npm install --legacy-peer-deps

- name: ▶️ Run check-exports script
run: npm run check-exports -- --format=table

- name: ▶️ Run test:types script
run: npm run test:types

type-tests:
name: 🧪 Type tests with ESLint ${{ matrix.eslint }} and TypeScript ${{ matrix.ts }}
runs-on: ubuntu-latest

strategy:
fail-fast: false

matrix:
eslint: [8, 9]
ts: ["5.0", "5.1", "5.2", "5.3", "5.4", "5.5", "5.6", "5.7", "5.8"]

steps:
- name: ⬇️ Checkout repo
uses: actions/checkout@v4

- name: ⎔ Setup Node
uses: actions/setup-node@v4
with:
node-version: 18

- name: 📥 Install dependencies
run: npm install

- name: Pack the package
id: pack
run: npm install "$(npm pack | tail -n1)"

- name: 📥 Uninstall @types/eslint
if: matrix.eslint != 8
run: npm uninstall @types/eslint

- name: 📥 Install ESLint version ${{ matrix.eslint }}
run: npm install --save-dev eslint@${{ matrix.eslint }}

- name: 📥 Install TypeScript version ${{ matrix.ts }}
run: npm install --save-dev typescript@${{ matrix.ts }} -f

- name: ▶️ Run test:types script
run: npm run test:types

- name: 📝 List version of ESLint
run: npm why eslint @types/eslint

release:
name: 🚀 Release
needs: [ lint, test ]
needs: [lint, test]
runs-on: ubuntu-latest
if:
github.repository == 'eslint-community/eslint-plugin-eslint-comments' &&
if: github.repository == 'eslint-community/eslint-plugin-eslint-comments' &&
contains('refs/heads/main,refs/heads/next,refs/heads/beta,refs/heads/alpha',
github.ref) && github.event_name == 'push'
steps:
Expand Down
16 changes: 9 additions & 7 deletions configs.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,16 @@ const plugin = {
rules,
}

const recommended = {
name: "@eslint-community/eslint-comments/recommended",
plugins: {
"@eslint-community/eslint-comments": plugin,
},
rules: rulesRecommended,
}

module.exports = {
recommended: {
name: '@eslint-community/eslint-comments/recommended',
plugins: {
"@eslint-community/eslint-comments": plugin,
},
rules: rulesRecommended,
},
recommended,
}

module.exports.default = module.exports
11 changes: 7 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
/** DON'T EDIT THIS FILE WHICH WAS CREATED BY 'scripts/generate-index.js'. */
"use strict"

const rules = require("./lib/rules")
const utils = require("./lib/utils")
const configs = require("./lib/configs")

module.exports = {
configs: require("./lib/configs"),
rules: require("./lib/rules"),
utils: require("./lib/utils"),
configs,
rules,
utils,
}
28 changes: 25 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,30 @@
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
},
"main": "index.js",
"types": "./types/index.d.ts",
"type": "commonjs",
"files": [
"configs.js",
"lib"
"lib",
"types"
],
"exports": {
"./configs": "./configs.js",
".": "./index.js"
"./package.json": "./package.json",
"./configs": {
"types": "./types/configs.d.ts",
"default": "./configs.js"
},
".": {
"types": "./types/index.d.ts",
"default": "./index.js"
}
},
"typesVersions": {
"*": {
"configs": [
"./types/configs.d.ts"
]
}
},
"peerDependencies": {
"eslint": "^6.0.0 || ^7.0.0 || ^8.0.0 || ^9.0.0"
Expand All @@ -23,23 +39,27 @@
"ignore": "^5.2.4"
},
"devDependencies": {
"@arethetypeswrong/cli": "^0.18.2",
"@babel/core": "^7.22.9",
"@babel/eslint-parser": "^7.22.9",
"@eslint-community/eslint-plugin-mysticatea": "^15.5.1",
"@eslint/core": "^0.13.0",
"@eslint/css": "^0.6.0",
"@types/eslint": "^8",
"@types/node": "^14.18.54",
"@vuepress/plugin-pwa": "^1.9.9",
"cross-spawn": "^7.0.3",
"esbuild": "^0.19.3",
"eslint": "^8.46.0",
"expect-type": "^1.2.2",
"fs-extra": "^10.1.0",
"mocha": "^10.4.0",
"monaco-editor": "^0.47.0",
"nyc": "^15.1.0",
"opener": "^1.5.2",
"rimraf": "^3.0.2",
"semver": "^7.5.4",
"typescript": "^5.9.3",
"vite-plugin-eslint4b": "^0.2.1",
"vitepress": "^1.0.0-rc.15"
},
Expand All @@ -53,6 +73,8 @@
"lint": "eslint lib scripts tests",
"test": "nyc npm run debug",
"debug": "mocha \"tests/lib/**/*.js\" --reporter dot --timeout 8000",
"test:types": "tsc -p tsconfig.json",
"check-exports": "attw --pack",
"coverage": "nyc report --reporter lcov && opener coverage/lcov-report/index.html",
"watch": "npm run -s test -- --watch --growl"
},
Expand Down
18 changes: 18 additions & 0 deletions tests/types/configs.test-d.cts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import configs = require("@eslint-community/eslint-plugin-eslint-comments/configs")
import expectTypeModule = require("expect-type")

import type { Linter } from "eslint"

import expectTypeOf = expectTypeModule.expectTypeOf

expectTypeOf(configs)
.toHaveProperty("recommended")
.toExtend<Linter.FlatConfig>()

expectTypeOf([configs.recommended]).toExtend<Linter.FlatConfig[]>()

expectTypeOf(configs.recommended).toExtend<Linter.FlatConfig>()

expectTypeOf(configs)
.toHaveProperty("recommended")
.toExtend<Linter.FlatConfig>()
15 changes: 15 additions & 0 deletions tests/types/configs.test-d.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import configs from "@eslint-community/eslint-plugin-eslint-comments/configs"
import type { Linter } from "eslint"
import { expectTypeOf } from "expect-type"

expectTypeOf(configs)
.toHaveProperty("recommended")
.toExtend<Linter.FlatConfig>()

expectTypeOf([configs.recommended]).toExtend<Linter.FlatConfig[]>()

expectTypeOf(configs.recommended).toExtend<Linter.FlatConfig>()

expectTypeOf(configs)
.toHaveProperty("recommended")
.toExtend<Linter.FlatConfig>()
20 changes: 20 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"compilerOptions": {
"allowSyntheticDefaultImports": false,
"esModuleInterop": false,
"forceConsistentCasingInFileNames": true,
"isolatedModules": true,
"lib": ["ESNext"],
"module": "NodeNext",
"moduleResolution": "NodeNext",
"noEmit": true,
"resolveJsonModule": true,
"skipLibCheck": true,
"strict": true,
"target": "ESNext",
"useDefineForClassFields": true,
"useUnknownInCatchVariables": true,
"verbatimModuleSyntax": true
},
"include": ["."]
}
11 changes: 11 additions & 0 deletions types/configs.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import type { Linter } from "eslint"

declare namespace Configs {
import defaultExports = Configs

export const recommended: Linter.FlatConfig

export { defaultExports as default }
}

export = Configs
7 changes: 7 additions & 0 deletions types/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import type { ESLint, Linter } from "eslint"

export declare const configs: { recommended: Linter.LegacyConfig }

export declare const rules: NonNullable<ESLint.Plugin["rules"]>

export declare const utils: { patch: (ruleId?: string) => void }