Closed spend-cloud-tom closed 10 months ago
We temporarily closed this due to the lack of enough information. We could not identify whether it was a bug or a userland misconfiguration with the given info. Please provide a minimal reproduction to reopen the issue. Thanks.
export default antfu(
{
vueVersion: 2,
},
)
There is indeed this issue, please lock the 2.3.4
version.
我这边也出现了这个问题,好像是eslint-processor-vue-blocks
引起的
vscode 日志:
2024-01-24T10:08:11.658Z eslint:flat-eslint Searching for eslint.config.js
2024-01-24T10:08:11.658Z eslint:flat-eslint Loading config from /Users/xxxxx/temp/eslint-issues-367/eslint.config.js
2024-01-24T10:08:11.658Z eslint:flat-eslint Config file URL is file:///Users/xxxxx/temp/eslint-issues-367/eslint.config.js
2024-01-24T10:08:11.718Z eslint:flat-eslint Lint /Users/xxxxx/temp/eslint-issues-367/src/components/TheWelcome.vue
2024-01-24T10:08:11.718Z eslint:linter Linting code for /Users/xxxxx/temp/eslint-issues-367/src/components/TheWelcome.vue (pass 1)
2024-01-24T10:08:11.718Z eslint:linter Verify
2024-01-24T10:08:11.718Z eslint:linter With flat config: /Users/xxxxx/temp/eslint-issues-367/src/components/TheWelcome.vue
2024-01-24T10:08:11.718Z eslint:linter Apply the processor: { meta: { name: 'merged-processor:eslint-plugin-vue+eslint-processor-vue-blocks' }, supportsAutofix: true, preprocess: [Function: preprocess], postprocess: [Function: postprocess] }
2024-01-24T10:08:11.718Z eslint:linter Preprocessing error: Cannot read properties of undefined (reading 'styles')
TypeError: Cannot read properties of undefined (reading 'styles')
at Object.preprocess (file:///Users/xxxxx/temp/eslint-issues-367/node_modules/.pnpm/eslint-processor-vue-blocks@0.1.1_eslint@8.56.0/node_modules/eslint-processor-vue-blocks/dist/index.mjs:73:20)
at /Users/xxxxx/temp/eslint-issues-367/node_modules/.pnpm/eslint-merge-processors@0.1.0_eslint@8.56.0/node_modules/eslint-merge-processors/dist/index.cjs:14:46
at Array.flatMap (<anonymous>)
at preprocess (/Users/xxxxx/temp/eslint-issues-367/node_modules/.pnpm/eslint-merge-processors@0.1.0_eslint@8.56.0/node_modules/eslint-merge-processors/dist/index.cjs:13:25)
at Linter._verifyWithFlatConfigArrayAndProcessor (/Users/xxxxx/temp/eslint-issues-367/node_modules/.pnpm/eslint@8.56.0/node_modules/eslint/lib/linter/linter.js:1479:22)
at Linter._verifyWithFlatConfigArray (/Users/xxxxx/temp/eslint-issues-367/node_modules/.pnpm/eslint@8.56.0/node_modules/eslint/lib/linter/linter.js:1848:25)
at Linter.verify (/Users/xxxxx/temp/eslint-issues-367/node_modules/.pnpm/eslint@8.56.0/node_modules/eslint/lib/linter/linter.js:1433:65)
at Linter.verifyAndFix (/Users/xxxxx/temp/eslint-issues-367/node_modules/.pnpm/eslint@8.56.0/node_modules/eslint/lib/linter/linter.js:2068:29)
at verifyText (/Users/xxxxx/temp/eslint-issues-367/node_modules/.pnpm/eslint@8.56.0/node_modules/eslint/lib/eslint/flat-eslint.js:474:48)
at FlatESLint.lintText (/Users/xxxxx/temp/eslint-issues-367/node_modules/.pnpm/eslint@8.56.0/node_modules/eslint/lib/eslint/flat-eslint.js:957:26)
2024-01-24T10:08:11.719Z eslint:linter Generating fixed text for /Users/xxxxx/temp/eslint-issues-367/src/components/TheWelcome.vue (pass 1)
2024-01-24T10:08:11.719Z eslint:source-code-fixer Applying fixes
2024-01-24T10:08:11.719Z eslint:source-code-fixer shouldFix parameter was false, not attempting fixes
2024-01-24T10:08:11.719Z eslint:flat-eslint Linting complete in: 60ms
eslint.config.js
:
const antfu = require('@antfu/eslint-config').default
module.exports = antfu({
vue: {
// 设置成false就不会报错
sfcBlocks: true,
vueVersion: 2,
},
})
复现demo: https://github.com/whitexie/eslint-issues-367
我的环境:
System:
OS: macOS 14.2.1
Shell: 5.9 - /bin/zsh
Binaries:
Node: 16.18.0 - ~/.nvm/versions/node/v16.18.0/bin/node
Yarn: 1.22.19 - ~/.yarn/bin/yarn
npm: 8.19.2 - ~/.nvm/versions/node/v16.18.0/bin/npm
pnpm: 7.19.0 - ~/Library/pnpm/pnpm
Browsers:
Chrome: 119.0.6045.105
Safari: 17.2.1
@antfu @whitexie It's useless if you set it like this, the settings in formatters
still won't take effect.
{
vue: {
vueVersion: 2,
sfcBlocks: false,
},
formatters: {
css: true, // Not effective
html: true, // Not effective
markdown: 'prettier', // Not effective
},
}
@usercao 有安装eslint-plugin-format
吗? formatters 依赖它
@antfu eslint-processor-vue-blocks
对于@vue/compiler-sfc
的依赖版本是3.3以上, 但是本地引用的是@vue/compiler-sfc@2.7.16
版本。
@whitexie Installing eslint-plugin-format
does not work.
@usercao 如果是.vue
中的style,需要将sfcBlocks
设置为true
;
但eslint-processor-vue-blocks
依赖@vue/compiler-sfc
的3.3以上版本;
我从yarn
迁移到pnpm
之后,pnpm
可以解决这个依赖冲突的问题。
删除node_modules
,
在项目根路径下创建.npmrc
, 写入:
auto-install-peers=true
重新安装依赖就可以了。
@whitexie Is there any solution to using yarn
?
不知道哈,没找到相关解决办法。
@whitexie 👌thanks
This configuration seem to help to avoid this error by ignoring styles
block.
sfcBlocks: {
blocks: {
styles: false,
},
},
@whitexie Is there any solution to using
yarn
?
It seems to be solved with PNPM
Here I give a yarn
solution. In package.json
, add:
"resolutions": {
"**/eslint-processor-vue-blocks/@vue/compiler-sfc": "^3.3.0"
}
Then the problem is solved. @usercao
Describe the bug
I'm running the config @ 2.3.x on a project using vue@2.7.15, this runs fine. Whenever I update the config to 2.4.x I'm getting these errors, which I believe have to do with a template parser mismatch.
This is my config:
Reproduction
Use linter config 2.4.x on a vue 2 project
System Info
Used Package Manager
npm
Validations