Skip to content
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

eslint --fix 格式化特定的 less 报错 #36

Closed
5 of 7 tasks
Yuan-ZW opened this issue Nov 27, 2024 · 2 comments
Closed
5 of 7 tasks

eslint --fix 格式化特定的 less 报错 #36

Yuan-ZW opened this issue Nov 27, 2024 · 2 comments

Comments

@Yuan-ZW
Copy link

Yuan-ZW commented Nov 27, 2024

Describe the bug

当使用 @antfu/eslint-config 并开启 formatters: true 时, 对以下代码执行 eslint --fix 会报错:

<template>
  <div>test</div>
</template>

<style lang="less" scoped>
.a {
.b {
  .c {
    padding: 1rem;
  }
}
  
}
</style>

: 其中倒数第三行的空行包含两个空格
执行 eslint --fix 报错:

> eslint --fix test.vue


Oops! Something went wrong! :(

ESLint: 9.15.0

TypeError: Cannot read properties of undefined (reading 'range')
    at attemptFix (D:\YZW\Desktop\minimal-demo\node_modules\.pnpm\[email protected]\node_modules\eslint\lib\linter\source-code-fixer.js:88:27)
    at SourceCodeFixer.applyFixes (D:\YZW\Desktop\minimal-demo\node_modules\.pnpm\[email protected]\node_modules\eslint\lib\linter\source-code-fixer.js:123:17)
    at Linter.verifyAndFix (D:\YZW\Desktop\minimal-demo\node_modules\.pnpm\[email protected]\node_modules\eslint\lib\linter\linter.js:2329:43)
    at verifyText (D:\YZW\Desktop\minimal-demo\node_modules\.pnpm\[email protected]\node_modules\eslint\lib\eslint\eslint.js:329:48)
    at D:\YZW\Desktop\minimal-demo\node_modules\.pnpm\[email protected]\node_modules\eslint\lib\eslint\eslint.js:810:40
 ELIFECYCLE  Command failed with exit code 2.

同时, 针对 less 文件:

.a {
.b {
  .c {
    padding: 1rem;
  }
}
  
}

: 同样倒数第二行的空行也包含两个空格
执行 eslint --fix 之后 less 文件变成:

.a {
  .b {
    .c {
      padding: 1rem;
    }

}

同时报错:

> eslint --fix test.less


D:\YZW\Desktop\minimal-demo\test.less
  1:2  error  Parsing error: CssSyntaxError: Unclosed block  format/prettier

✖ 1 problem (1 error, 0 warnings)

 ELIFECYCLE  Command failed with exit code 1.

Reproduction

https://github.com/Yuan-ZW/eslint-minimal-example

System Info

System:
    OS: Windows 11 10.0.26120
    CPU: (12) x64 12th Gen Intel(R) Core(TM) i5-12450H
    Memory: 3.32 GB / 15.71 GB
  Binaries:
    Node: 20.10.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.21 - C:\Program Files\nodejs\yarn.CMD
    npm: 10.2.3 - C:\Program Files\nodejs\npm.CMD
    pnpm: 9.12.1 - C:\Program Files\nodejs\pnpm.CMD
  Browsers:
    Edge: Chromium (127.0.2651.86)
    Internet Explorer: 11.0.26100.1

Used Package Manager

pnpm

Validations

  • Follow our Code of Conduct
  • Read the Contributing Guide.
  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • Check that this is a concrete bug. For Q&A, please open a GitHub Discussion instead.
  • The provided reproduction is a minimal reproducible of the bug.

Contributions

  • I am willing to submit a PR to fix this issue
  • I am willing to submit a PR with failing tests (actually just go ahead and do it, thanks!)
@ntnyq
Copy link

ntnyq commented Nov 30, 2024

Related: antfu/eslint-config#607

And you should report this issue to https://github.com/antfu/eslint-config

@Yuan-ZW
Copy link
Author

Yuan-ZW commented Dec 1, 2024

提错地方了😂

@Yuan-ZW Yuan-ZW closed this as not planned Won't fix, can't repro, duplicate, stale Jan 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants