Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
51 changes: 51 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,35 @@ jobs:
- name: Lint
run: npm run lint

build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: actions/setup-node@v6
with:
node-version: lts/*

- name: Install Packages
run: npm install

- name: Build
run: npm run build

- name: Cache dist
uses: actions/upload-artifact@v5
with:
retention-days: 3
name: dist
path: dist

test:
name: Test
strategy:
matrix:
node: [18, 20, 21, 'lts/*']
runs-on: ubuntu-latest
needs:
- build
steps:
- name: Checkout
uses: actions/checkout@v5
Expand All @@ -41,12 +64,18 @@ jobs:
node-version: ${{ matrix.node }}
- name: Install Packages
run: npm install
- name: Restore dist cache
uses: actions/download-artifact@v6
with:
name: dist
- name: Test
run: npm test

test-with-eslint-v8:
name: Test with ESLint v8
runs-on: ubuntu-latest
needs:
- build
steps:
- name: Checkout
uses: actions/checkout@v5
Expand All @@ -58,12 +87,18 @@ jobs:
run: npm install
- name: Install ESLint v8
run: npm install --save-dev eslint@8 --force
- name: Restore dist cache
uses: actions/download-artifact@v6
with:
name: dist
- name: Test
run: npm test

test-without-eslint-stylistic:
name: Test without ESLint Stylistic
runs-on: ubuntu-latest
needs:
- build
steps:
- name: Checkout
uses: actions/checkout@v5
Expand All @@ -73,6 +108,10 @@ jobs:
run: npm install
- name: Uninstall @stylistic/eslint-plugin
run: npm uninstall @stylistic/eslint-plugin
- name: Restore dist cache
uses: actions/download-artifact@v6
with:
name: dist
- name: Test
run: npm test

Expand All @@ -82,6 +121,8 @@ jobs:
matrix:
stylistic: [2, 3, 4]
runs-on: ubuntu-latest
needs:
- build
steps:
- name: Checkout
uses: actions/checkout@v5
Expand All @@ -91,12 +132,18 @@ jobs:
run: npm install
- name: Install @stylistic/eslint-plugin v${{ matrix.stylistic }}
run: npm install -D @stylistic/eslint-plugin@${{ matrix.stylistic }} --force
- name: Restore dist cache
uses: actions/download-artifact@v6
with:
name: dist
- name: Test
run: npm test

test-with-typescript-eslint-v7:
name: Test with typescript-eslint v7
runs-on: ubuntu-latest
needs:
- build
steps:
- name: Checkout
uses: actions/checkout@v5
Expand All @@ -106,5 +153,9 @@ jobs:
run: npm install
- name: Install @typescript-eslint/parser v7
run: npm install -D @typescript-eslint/parser@7 --force
- name: Restore dist cache
uses: actions/download-artifact@v6
with:
name: dist
- name: Test
run: npm test
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 @@ -79,7 +79,7 @@
],
// turn off some rules from shared configs in all files
rules: {
'eslint-plugin/require-meta-default-options': 'off', // TODO: enable when all rules have defaultOptions

Check warning on line 82 in eslint.config.mjs

View workflow job for this annotation

GitHub Actions / Lint

Unexpected 'todo' comment: 'TODO: enable when all rules have...'
'eslint-plugin/require-meta-docs-recommended': 'off', // use `categories` instead
'eslint-plugin/require-meta-schema-description': 'off',

Expand Down Expand Up @@ -275,6 +275,7 @@
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-empty-object-type': 'off',
'@typescript-eslint/no-namespace': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/triple-slash-reference': 'off',
'@typescript-eslint/unified-signatures': 'off',
'@typescript-eslint/ban-ts-comment': [
Expand Down
4 changes: 2 additions & 2 deletions lib/configs/flat/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module.exports = [
name: 'vue/base/setup',
plugins: {
get vue() {
return require('../../index')
return require('../../plugin')
}
},
languageOptions: {
Expand All @@ -20,7 +20,7 @@ module.exports = [
files: ['*.vue', '**/*.vue'],
plugins: {
get vue() {
return require('../../index')
return require('../../plugin')
}
},
languageOptions: {
Expand Down
28 changes: 28 additions & 0 deletions lib/configs/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
const configs = {
// eslintrc configs
base: require('./base'),

'vue2-essential': require('./vue2-essential'),
'vue2-strongly-recommended': require('./vue2-strongly-recommended'),
'vue2-recommended': require('./vue2-recommended'),

essential: require('./vue3-essential'),
'strongly-recommended': require('./vue3-strongly-recommended'),
recommended: require('./vue3-recommended'),

// flat configs
'flat/base': require('./flat/base.js'),

'flat/vue2-essential': require('./flat/vue2-essential.js'),
'flat/vue2-strongly-recommended': require('./flat/vue2-strongly-recommended.js'),
'flat/vue2-recommended': require('./flat/vue2-recommended.js'),

'flat/essential': require('./flat/vue3-essential.js'),
'flat/strongly-recommended': require('./flat/vue3-strongly-recommended.js'),
'flat/recommended': require('./flat/vue3-recommended.js'),

// config-format-agnostic configs
'no-layout-rules': require('./no-layout-rules')
}

module.exports = configs
4 changes: 4 additions & 0 deletions lib/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import configs from './configs/index.js'
import plugin from './plugin.js'

export default Object.assign(plugin, { configs })
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 pkg from '../package.json' with { type: 'json' }

export default { name: pkg.name, version: pkg.version }
32 changes: 3 additions & 29 deletions lib/index.js → lib/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,7 @@
'use strict'

const plugin = {
meta: require('./meta'),
configs: {
// eslintrc configs
base: require('./configs/base'),

'vue2-essential': require('./configs/vue2-essential'),
'vue2-strongly-recommended': require('./configs/vue2-strongly-recommended'),
'vue2-recommended': require('./configs/vue2-recommended'),

essential: require('./configs/vue3-essential'),
'strongly-recommended': require('./configs/vue3-strongly-recommended'),
recommended: require('./configs/vue3-recommended'),

// flat configs
'flat/base': require('./configs/flat/base.js'),

'flat/vue2-essential': require('./configs/flat/vue2-essential.js'),
'flat/vue2-strongly-recommended': require('./configs/flat/vue2-strongly-recommended.js'),
'flat/vue2-recommended': require('./configs/flat/vue2-recommended.js'),

'flat/essential': require('./configs/flat/vue3-essential.js'),
'flat/strongly-recommended': require('./configs/flat/vue3-strongly-recommended.js'),
'flat/recommended': require('./configs/flat/vue3-recommended.js'),

// config-format-agnostic configs
'no-layout-rules': require('./configs/no-layout-rules')
},
meta: require('./meta.ts').default,
rules: {
'array-bracket-newline': require('./rules/array-bracket-newline'),
'array-bracket-spacing': require('./rules/array-bracket-spacing'),
Expand Down Expand Up @@ -284,8 +258,8 @@ const plugin = {
'valid-v-text': require('./rules/valid-v-text')
},
processors: {
'.vue': require('./processor'),
vue: require('./processor')
'.vue': require('./processor.ts').default,
vue: require('./processor.ts').default
}
}

Expand Down
75 changes: 30 additions & 45 deletions lib/processor.js → lib/processor.ts
Original file line number Diff line number Diff line change
@@ -1,44 +1,34 @@
/**
* @author Toru Nagashima <https://github.com/mysticatea>
*/
'use strict'
import type { Linter } from 'eslint'
import meta from './meta.ts'

/**
* @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): string[] {
return [code]
},

/**
* @param {LintMessage[][]} messages
* @returns {LintMessage[]}
*/
postprocess(messages) {
postprocess(messages: LintMessage[][]): LintMessage[] {
const state = {
/** @type {GroupState} */
block: {
disableAllKeys: new Set(),
disableRuleKeys: new Map()
},
/** @type {GroupState} */
disableAllKeys: new Set<string>(),
disableRuleKeys: new Map<string, string[]>()
} satisfies GroupState,
line: {
disableAllKeys: new Set(),
disableRuleKeys: new Map()
}
disableAllKeys: new Set<string>(),
disableRuleKeys: new Map<string, string[]>()
} satisfies 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 @@ -136,15 +126,14 @@ module.exports = {

supportsAutofix: true,

meta: require('./meta')
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
): void {
let keys = disableRuleKeys.get(rule)
if (keys) {
keys.push(key)
Expand All @@ -154,11 +143,7 @@ function addDisableRule(disableRuleKeys, rule, key) {
}
}

/**
* @param {LintMessage} message
* @returns {string} message key
*/
function messageToKey(message) {
function messageToKey(message: LintMessage): string {
return `line:${message.line},column${
// -1 because +1 by ESLint's `report-translator`.
message.column - 1
Expand All @@ -167,11 +152,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): number {
return itemA.line - itemB.line || itemA.column - itemB.column
}
Loading
Loading