Skip to content

Add absolute path for reading file contents #108

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 25, 2024
Merged
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
4 changes: 3 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import vueParser from 'vue-eslint-parser'
import pluginVue from 'eslint-plugin-vue'

import fg from 'fast-glob'
import path from 'node:path'

type ExtendableConfigName = keyof typeof tseslint.configs
type ScriptLang = 'ts' | 'tsx' | 'js' | 'jsx'
Expand Down Expand Up @@ -33,7 +34,8 @@ export default function createConfig({
})
.reduce(
(acc, file) => {
const contents = fs.readFileSync(file, 'utf8')
const absolutePath = path.resolve(rootDir, file)
const contents = fs.readFileSync(absolutePath, 'utf8')
// contents matches the <script lang="ts"> (there can be anything but `>` between `script` and `lang`)
if (/<script[^>]*\blang\s*=\s*"ts"[^>]*>/i.test(contents)) {
acc.vueFilesWithScriptTs.push(file)
Expand Down