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
46 changes: 43 additions & 3 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,62 @@ extends:
- plugin:@eslint-community/mysticatea/es2015
- plugin:@eslint-community/mysticatea/+eslint-plugin

rules:
"@eslint-community/mysticatea/node/file-extension-in-import":
- error
- always
- ".ts": "always"
"@eslint-community/mysticatea/ts/naming-convention":
- off
"@eslint-community/mysticatea/ts/prefer-readonly-parameter-types":
- off
"@eslint-community/mysticatea/ts/no-unsafe-member-access":
- off
"@eslint-community/mysticatea/ts/no-var-requires":
- off
"@eslint-community/mysticatea/ts/no-require-imports":
- off
"@eslint-community/mysticatea/ts/no-unsafe-assignment":
- off
"@eslint-community/mysticatea/ts/no-unsafe-call":
- off
"@eslint-community/mysticatea/ts/no-unsafe-argument":
- off
"@eslint-community/mysticatea/ts/no-unsafe-return":
- off
"@eslint-community/mysticatea/ts/ban-ts-comment":
- off
"@eslint-community/mysticatea/ts/no-non-null-asserted-optional-chain":
- off
"@eslint-community/mysticatea/ts/prefer-optional-chain":
- off
"@eslint-community/mysticatea/ts/prefer-nullish-coalescing":
- off
"@eslint-community/mysticatea/ts/no-floating-promises":
- off
"@eslint-community/mysticatea/ts/no-unnecessary-type-assertion":
- off
"no-shadow":
- off
"@eslint-community/mysticatea/node/no-missing-import": off
"@eslint-community/mysticatea/node/no-unpublished-import": off

overrides:
- files: "docs/.vuepress/components/*.vue"
parserOptions:
parser: "@babel/eslint-parser"

- files: "lib/rules/*.js"
- files: "lib/rules/*.ts"
rules:
"@eslint-community/mysticatea/eslint-plugin/require-meta-docs-url":
- error
- pattern: "https://eslint-community.github.io/eslint-plugin-eslint-comments/rules/{{name}}.html"

- files: ["lib/configs.js", "lib/rules.js", "lib/utils.js"]
- files: ["lib/configs.ts", "lib/rules.ts", "lib/utils.ts"]
rules:
"@eslint-community/mysticatea/node/global-require": off

- files: ["tests/**/*.js", "scripts/**/*.js"]
- files: ["tests/**/*.ts", "scripts/**/*.ts"]
rules:
"@eslint-community/mysticatea/node/global-require": off
"@eslint-community/mysticatea/node/no-sync": off
92 changes: 80 additions & 12 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
- name: ⎔ Setup Node
uses: actions/setup-node@v4
with:
node-version: 18
node-version: 22

- name: 📥 Install dependencies
run: npm install
Expand All @@ -43,33 +43,32 @@ 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
matrix:
eslint: [8]
node: [12.22.0, 12, 14.17.0, 14, 16.0.0, 16, 18.0.0, 18, 20, 22, 24]
node: [22, 24]

Choose a reason for hiding this comment

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

Removing these entries from the CI matrix, when the engines list haven't been reduced is creating a blind spot. Is there a reason these versions were dropped?

os: [ubuntu-latest]
include:
# On other platforms
- os: windows-latest
eslint: 8
node: 18
node: 22
- os: macos-latest
eslint: 8
node: 18
node: 22
# On ESLint 9
- eslint: 9
node: 18
node: 22
os: ubuntu-latest
# On old ESLint versions
- eslint: 7
node: 18
node: 22
os: ubuntu-latest
- eslint: 6
node: 18
node: 22
os: ubuntu-latest
# On the minimum supported ESLint/Node.js version
- eslint: 6.0.0
Expand All @@ -84,25 +83,94 @@ jobs:
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
check-latest: true

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

- name: 📥 Build
run: npm run build

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

- name: ▶️ Run test script
env:
NODE_OPTIONS: --experimental-transform-types
run: npm run test

- 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: 22

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

- name: ▶️ Run check-exports script
run: npm run check-exports

- name: ▶️ Run typecheck script
run: npm run typecheck

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.7", "5.8", "5.9"]

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

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

- 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 typecheck script
run: npm run typecheck

- 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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
/node_modules
/npm-debug.log
/test.js
dist/
22 changes: 0 additions & 22 deletions configs.js

This file was deleted.

64 changes: 64 additions & 0 deletions configs.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import type { ESLint, Linter, Rule } from "eslint"
import { rulesRecommended } from "./lib/configs/recommended.ts"
import { rules } from "./lib/rules.ts"
import packageJson from "./package.json" with { type: "json" }

const plugin: {
meta: {
name: string
version: string
}
rules: {
"disable-enable-pair": Rule.RuleModule
"no-aggregating-enable": Rule.RuleModule
"no-duplicate-disable": Rule.RuleModule
"no-restricted-disable": Rule.RuleModule
"no-unlimited": Rule.RuleModule
"no-unused-disable": Rule.RuleModule
"no-unused-enable": Rule.RuleModule
"no-use": Rule.RuleModule
"require-description": Rule.RuleModule
}
Comment on lines +7 to +21

Choose a reason for hiding this comment

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

Why is this type annotation needed when you're using satisfies?

} = {
meta: {
name: packageJson.name,
version: packageJson.version,
},
rules,
} as const satisfies ESLint.Plugin

export const recommended: {
name: "@eslint-community/eslint-comments/recommended"
plugins: {
"@eslint-community/eslint-comments": {
meta: {
name: string
version: string
}
rules: {
"disable-enable-pair": Rule.RuleModule
"no-aggregating-enable": Rule.RuleModule
"no-duplicate-disable": Rule.RuleModule
"no-restricted-disable": Rule.RuleModule
"no-unlimited": Rule.RuleModule
"no-unused-disable": Rule.RuleModule
"no-unused-enable": Rule.RuleModule
"no-use": Rule.RuleModule
"require-description": Rule.RuleModule
}
}
}
rules: {
"@eslint-community/eslint-comments/disable-enable-pair": "error"
"@eslint-community/eslint-comments/no-aggregating-enable": "error"
"@eslint-community/eslint-comments/no-duplicate-disable": "error"
"@eslint-community/eslint-comments/no-unlimited-disable": "error"
"@eslint-community/eslint-comments/no-unused-enable": "error"
}
Comment on lines +31 to +57

Choose a reason for hiding this comment

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

Similar question here. Why is satisfies not enough here?

} = {
name: "@eslint-community/eslint-comments/recommended",
plugins: {
"@eslint-community/eslint-comments": plugin,
},
rules: rulesRecommended,
} as const satisfies Linter.FlatConfig
8 changes: 0 additions & 8 deletions index.js

This file was deleted.

3 changes: 3 additions & 0 deletions index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export * as configs from "./lib/configs.ts"
export { rules } from "./lib/rules.ts"
export * as utils from "./lib/utils.ts"
6 changes: 0 additions & 6 deletions lib/configs.js

This file was deleted.

1 change: 1 addition & 0 deletions lib/configs.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * as recommended from "./configs/recommended.ts"
13 changes: 0 additions & 13 deletions lib/configs/recommended.js

This file was deleted.

20 changes: 20 additions & 0 deletions lib/configs/recommended.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import type { BaseConfig, RulesConfig } from "@eslint/core"
import type { Linter } from "eslint"

export const plugins: string[] = [
"@eslint-community/eslint-comments",
] as const satisfies BaseConfig["plugins"]

export const rulesRecommended: {
"@eslint-community/eslint-comments/disable-enable-pair": "error"
"@eslint-community/eslint-comments/no-aggregating-enable": "error"
"@eslint-community/eslint-comments/no-duplicate-disable": "error"
"@eslint-community/eslint-comments/no-unlimited-disable": "error"
"@eslint-community/eslint-comments/no-unused-enable": "error"
} = {
"@eslint-community/eslint-comments/disable-enable-pair": "error",
"@eslint-community/eslint-comments/no-aggregating-enable": "error",
"@eslint-community/eslint-comments/no-duplicate-disable": "error",
"@eslint-community/eslint-comments/no-unlimited-disable": "error",
"@eslint-community/eslint-comments/no-unused-enable": "error",
} as const satisfies Linter.RulesRecord satisfies RulesConfig
Loading