Skip to content
Open
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
b9ad774
feat: introduce `tsdown`, support js & ts
9romise Aug 21, 2025
928fe26
fix: dont bundle typescript
9romise Aug 21, 2025
1b24273
chore: update
9romise Aug 22, 2025
0f786d8
chore: update
9romise Aug 22, 2025
aedcd8d
refactor: rewrite `processor` in ts
9romise Aug 22, 2025
bd930b7
chore: specific tsdown target
9romise Aug 22, 2025
79d440d
fix: dont touch docs
9romise Aug 22, 2025
18d7488
ci: try fix
9romise Aug 22, 2025
861c1d6
fix: correct docs dev & build
9romise Aug 22, 2025
3d7f91c
chore: update
9romise Aug 22, 2025
f1c5923
chore: update
9romise Aug 25, 2025
eb2d18d
build: remove specific node version
9romise Oct 30, 2025
27f3479
chore: use `import` instead of `require` in esm files
9romise Oct 30, 2025
8c11d97
Merge branch 'master' into rewrite-ts
9romise Nov 20, 2025
17974eb
chore: update `tsdown`
9romise Nov 20, 2025
5e71d49
ci: add build in workflow
9romise Nov 20, 2025
6c4041b
fix: don't fix extension
9romise Nov 20, 2025
8d33d93
chore: update
9romise Nov 20, 2025
f081f42
Merge branch 'master' into pr/2916
9romise Nov 20, 2025
7108c0a
chore: use pkg.pr.new/rolldown temporarily
9romise Nov 20, 2025
1d7a583
ci: run build on node lts
9romise Nov 20, 2025
e9f7c7e
ci: cleanup
9romise Nov 20, 2025
3b54278
ci: add `needs`
9romise Nov 20, 2025
4438e9f
chore: update
9romise Nov 20, 2025
7633074
Merge remote-tracking branch 'upstream/master' into rewrite-ts
9romise Nov 22, 2025
75b42d3
chore: update typegen
9romise Nov 22, 2025
34f9c2b
cherry-pick: #2967
9romise Nov 22, 2025
4f2f525
chore: update `plugin.js`
9romise Nov 22, 2025
7cfa8d0
refactor: rewrite `index` in `.ts`
9romise Nov 22, 2025
e3dbe93
cherry-pick: #2968
9romise Nov 22, 2025
b92bc9c
chore: fix lint
9romise Nov 22, 2025
46ac044
Merge branch 'master' into rewrite-ts
9romise Nov 27, 2025
9c58e1f
chore: use latest `tsdown`, don't override `rolldown`
9romise Nov 27, 2025
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ yarn-error.log
/docs/.vitepress/cache
typings/eslint/lib/rules
eslint-typegen.d.ts
dist
2 changes: 1 addition & 1 deletion docs/.vitepress/theme/components/eslint-code-block.vue
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ export default {
this.height = `${Math.max(120, 20 * (1 + lines))}px`
// Load linter.
const [plugin, { Linter }, vueEslintParser, globals] = await Promise.all([
import('../../../..'),
import('../../../../lib/index'),
import('eslint'),
import('vue-eslint-parser'),
import('globals')
Expand Down
1 change: 1 addition & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ const MD_LINKS_FOR_DOCS = {
export default typegen([
{
ignores: [
'dist',
'.nyc_output',
'coverage',
'node_modules',
Expand Down
3 changes: 0 additions & 3 deletions lib/meta.js

This file was deleted.

3 changes: 3 additions & 0 deletions lib/meta.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { name, version } from '../package.json' with { type: 'json' }

export { name, version }
72 changes: 28 additions & 44 deletions lib/processor.js → lib/processor.ts
Original file line number Diff line number Diff line change
@@ -1,44 +1,33 @@
/**
* @author Toru Nagashima <https://github.com/mysticatea>
*/
'use strict'
import type { Linter } from 'eslint'

/**
* @typedef {import('eslint').Linter.LintMessage} LintMessage
*/
/**
* @typedef {object} GroupState
* @property {Set<string>} GroupState.disableAllKeys
* @property {Map<string, string[]>} GroupState.disableRuleKeys
*/
type LintMessage = Linter.LintMessage

interface GroupState {
disableAllKeys: Set<string>
disableRuleKeys: Map<string, string[]>
}

module.exports = {
/** @param {string} code */
preprocess(code) {
export default {
preprocess(code: string) {
return [code]
},

/**
* @param {LintMessage[][]} messages
* @returns {LintMessage[]}
*/
postprocess(messages) {
postprocess(messages: LintMessage[][]) {
const state = {
/** @type {GroupState} */
block: {
disableAllKeys: new Set(),
disableRuleKeys: new Map()
},
/** @type {GroupState} */
disableAllKeys: new Set<string>(),
disableRuleKeys: new Map<string, string[]>()
} as GroupState,
line: {
disableAllKeys: new Set(),
disableRuleKeys: new Map()
}
disableAllKeys: new Set<string>(),
disableRuleKeys: new Map<string, string[]>()
} as GroupState
}
/** @type {string[]} */
const usedDisableDirectiveKeys = []
/** @type {Map<string,LintMessage>} */
const unusedDisableDirectiveReports = new Map()
const usedDisableDirectiveKeys: string[] = []
const unusedDisableDirectiveReports = new Map<string, LintMessage>()

// Filter messages which are in disabled area.
const filteredMessages = messages[0].filter((message) => {
Expand Down Expand Up @@ -139,12 +128,11 @@ module.exports = {
meta: require('./meta')
}

/**
* @param {Map<string, string[]>} disableRuleKeys
* @param {string} rule
* @param {string} key
*/
function addDisableRule(disableRuleKeys, rule, key) {
function addDisableRule(
disableRuleKeys: GroupState['disableRuleKeys'],
rule: string,
key: string
) {
let keys = disableRuleKeys.get(rule)
if (keys) {
keys.push(key)
Expand All @@ -154,11 +142,7 @@ function addDisableRule(disableRuleKeys, rule, key) {
}
}

/**
* @param {LintMessage} message
* @returns {string} message key
*/
function messageToKey(message) {
function messageToKey(message: LintMessage) {
return `line:${message.line},column${
// -1 because +1 by ESLint's `report-translator`.
message.column - 1
Expand All @@ -167,11 +151,11 @@ function messageToKey(message) {

/**
* Compares the locations of two objects in a source file
* @param {Position} itemA The first object
* @param {Position} itemB The second object
* @returns {number} A value less than 1 if itemA appears before itemB in the source file, greater than 1 if
* @param itemA The first object
* @param itemB The second object
* @returns A value less than 1 if itemA appears before itemB in the source file, greater than 1 if
* itemA appears after itemB in the source file, or 0 if itemA and itemB have the same location.
*/
function compareLocations(itemA, itemB) {
function compareLocations(itemA: Position, itemB: Position) {
return itemA.line - itemB.line || itemA.column - itemB.column
}
11 changes: 7 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"name": "eslint-plugin-vue",
"version": "10.4.0",
"description": "Official ESLint plugin for Vue.js",
"main": "lib/index.js",
"types": "lib/index.d.ts",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"scripts": {
"new": "node tools/new-rule.js",
"start": "npm run test:base -- --watch --growl",
Expand All @@ -22,15 +22,17 @@
"update": "node ./tools/update.js",
"update-resources": "node ./tools/update-resources.js",
"typegen": "node ./tools/generate-typegen.mjs",
"build": "tsdown",
"docs:watch": "vitepress dev docs",
"predocs:build": "npm run update",
"docs:build": "vitepress build docs",
"generate:version": "env-cmd -e version npm run update && npm run lint -- --fix",
"changeset:version": "changeset version && npm run generate:version && git add --all",
"changeset:publish": "npm run typegen && changeset publish"
"changeset:publish": "npm run typegen && changeset publish",
"prepublishOnly": "npm run build"
},
"files": [
"lib"
"dist"
],
"homepage": "https://eslint.vuejs.org",
"keywords": [
Expand Down Expand Up @@ -115,6 +117,7 @@
"markdownlint-cli": "^0.42.0",
"pathe": "^1.1.2",
"prettier": "^3.3.3",
"tsdown": "^0.14.1",
"typescript": "^5.7.2",
"vite-plugin-eslint4b": "^0.5.1",
"vitepress": "^1.4.1",
Expand Down
8 changes: 5 additions & 3 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"compilerOptions": {
"target": "ES2019",
"module": "node16",
"moduleResolution": "Node16",
"target": "esnext",
"module": "preserve",
"moduleResolution": "bundler",
"lib": ["es2020"],
"allowJs": true,
"checkJs": true,
Expand All @@ -17,6 +17,8 @@
"noFallthroughCasesInSwitch": true,
"esModuleInterop": true,
"resolveJsonModule": true,
"isolatedModules": true,
"noUncheckedSideEffectImports": true,
"baseUrl": ".",
"paths": {
"*": ["typings/*"]
Expand Down
11 changes: 11 additions & 0 deletions tsdown.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { defineConfig } from 'tsdown'

export default defineConfig({
target: 'node18',
entry: ['lib/index.js'],
format: ['cjs'],
copy: ['lib/index.d.ts'],
dts: false,
external: ['typescriopt'],
unbundle: true
})