Skip to content
Merged
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
7 changes: 0 additions & 7 deletions docs/.eslintrc.js

This file was deleted.

11 changes: 5 additions & 6 deletions docs/.vitepress/config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import './build-system/build.mjs'

const dirname = path.dirname(fileURLToPath(import.meta.url))

// eslint-disable-next-line unicorn/no-anonymous-default-export
export default async () => {
const rulesPath = '../../tools/lib/rules.js' // Avoid bundle
const rules: typeof import('../../tools/lib/rules.js') = await import(
Expand Down Expand Up @@ -87,12 +88,10 @@ export default async () => {
)
return !exists
})
.map(({ ruleId, name }) => {
return {
text: ruleId,
link: `/rules/${name}`
}
})
.map(({ ruleId, name }) => ({
text: ruleId,
link: `/rules/${name}`
}))

if (children.length === 0) {
continue
Expand Down
14 changes: 6 additions & 8 deletions docs/.vitepress/theme/index.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
// @ts-expect-error -- Browser
if (typeof window !== 'undefined') {
if (typeof require === 'undefined') {
// @ts-expect-error -- Browser
;(window as any).require = () => {
const e = new Error('require is not defined')
;(e as any).code = 'MODULE_NOT_FOUND'
throw e
}
if (typeof window !== 'undefined' && typeof require === 'undefined') {
// @ts-expect-error -- Browser
;(window as any).require = () => {
const e = new Error('require is not defined')
;(e as any).code = 'MODULE_NOT_FOUND'
throw e
}
}
// @ts-expect-error -- Cannot change `module` option
Expand Down
21 changes: 12 additions & 9 deletions docs/.vitepress/vite-plugin.mts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const libRoot = path.join(fileURLToPath(import.meta.url), '../../../lib')
export function vitePluginRequireResolve(): Plugin {
return {
name: 'vite-plugin-require.resolve',
transform(code, id, _options) {
transform(code, id) {
if (id.startsWith(libRoot)) {
return code.replace(/require\.resolve/gu, '(function(){return 0})')
}
Expand All @@ -34,8 +34,9 @@ export function viteCommonjs(): Plugin {
format: 'esm'
})
return transformed.code
} catch (e) {
console.error('Transform error. base code:\n' + base, e)
} catch (error) {
// eslint-disable-next-line no-console
console.error(`Transform error. base code:\n${base}`, error)
}
return undefined
}
Expand All @@ -58,24 +59,26 @@ function transformRequire(code: string) {
}

let id =
// eslint-disable-next-line prefer-template
'__' +
moduleString.replace(/[^a-zA-Z0-9_$]+/gu, '_') +
Math.random().toString(32).substring(2)
Math.random().toString(32).slice(2)
while (code.includes(id) || modules.has(id)) {
id += Math.random().toString(32).substring(2)
id += Math.random().toString(32).slice(2)
}
modules.set(id, moduleString)
return id + '()'
return `${id}()`
}
)

return (
// eslint-disable-next-line prefer-template
[...modules]
.map(([id, moduleString]) => {
return `import * as __temp_${id} from ${moduleString};
.map(
([id, moduleString]) => `import * as __temp_${id} from ${moduleString};
const ${id} = () => __temp_${id}.default || __temp_${id};
`
})
)
.join('') +
';\n' +
replaced
Expand Down
50 changes: 48 additions & 2 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import eslintPluginUnicorn from 'eslint-plugin-unicorn'
import eslintMarkdown from '@eslint/markdown'
import eslintPluginMarkdownPreferences from 'eslint-plugin-markdown-preferences'
import eslintPluginTs from '@typescript-eslint/eslint-plugin'
import tsEslintParser from '@typescript-eslint/parser'
import vueEslintParser from 'vue-eslint-parser'
import noInvalidMeta from './eslint-internal-rules/no-invalid-meta.js'
import noInvalidMetaDocsCategories from './eslint-internal-rules/no-invalid-meta-docs-categories.js'
Expand Down Expand Up @@ -50,6 +52,7 @@
{
ignores: [
'.nyc_output',
'eslint-typegen.d.ts',
'coverage',
'node_modules',
'.changeset/**/*.md',
Expand Down Expand Up @@ -78,14 +81,14 @@
}
},
...defineConfig({
files: ['**/*.js'],
files: ['**/*.{js,mjs,ts,mts}'],
extends: [
eslintPluginEslintPlugin,
eslintPluginUnicorn.configs['flat/recommended']
],
// 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 91 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 All @@ -105,7 +108,21 @@
}),

{
files: ['**/*.js'],
name: 'typescript/setup',
files: ['**/*.{ts,mts}'],
languageOptions: {
parser: tsEslintParser,
parserOptions: {
sourceType: 'module'
}
},
plugins: {
'@typescript-eslint': eslintPluginTs
}
},

{
files: ['**/*.{js,mjs,ts,mts}'],
languageOptions: {
ecmaVersion: 'latest',
sourceType: 'commonjs',
Expand Down Expand Up @@ -249,6 +266,35 @@
'internal/require-eslint-community': ['error']
}
},

{
files: ['**/*.{mjs,ts,mts}'],
languageOptions: {
sourceType: 'module'
}
},

{
files: ['**/*.{ts,mts}'],
rules: {
...eslintPluginTs.configs.strict.rules,
...eslintPluginTs.configs['flat/eslint-recommended'].rules,
'no-redeclare': 'off',
'@typescript-eslint/no-redeclare': 'error',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-empty-object-type': 'off',
'@typescript-eslint/no-namespace': 'off',
'@typescript-eslint/triple-slash-reference': 'off',
'@typescript-eslint/unified-signatures': 'off',
'@typescript-eslint/ban-ts-comment': [
'error',
{
minimumDescriptionLength: 3
}
]
}
},

{
files: ['./**/*.vue'],
languageOptions: {
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
"@types/node": "^24.0.8",
"@types/semver": "^7.5.8",
"@types/xml-name-validator": "^4.0.3",
"@typescript-eslint/eslint-plugin": "^8.35.1",
"@typescript-eslint/parser": "^8.35.1",
"@typescript-eslint/types": "^8.35.1",
"@vitest/coverage-v8": "^3.2.4",
Expand Down
2 changes: 1 addition & 1 deletion typings/eslint-plugin-vue/util-types/ast/es-ast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ export interface PrivateIdentifier extends HasParentNode {
}
export interface Literal extends HasParentNode {
type: 'Literal'
value: string | boolean | null | number | RegExp | BigInt
value: string | boolean | null | number | RegExp | bigint
raw: string
regex?: {
pattern: string
Expand Down
20 changes: 6 additions & 14 deletions vitest.config.mts
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import { defineConfig } from 'vitest/config'

import { defineConfig } from 'vitest/config';
export default defineConfig({
test: {
include: [
'tests/lib/**/*.js',
'tests/integrations/**/*.js'
],
include: ['tests/lib/**/*.js', 'tests/integrations/**/*.js'],
exclude: [
'**/node_modules/**',
'**/dist/**',
Expand All @@ -18,15 +15,10 @@ export default defineConfig({
coverage: {
provider: 'v8',
include: ['lib/**/*.js'],
exclude: [
'tests/**',
'dist/**',
'tools/**',
'node_modules/**'
],
exclude: ['tests/**', 'dist/**', 'tools/**', 'node_modules/**'],
reporter: ['text', 'lcov', 'json-summary', 'html'],
all: true,
reportsDirectory: './coverage'
},
},
});
}
}
})
Loading