Skip to content

Conflicts with lint-staged and stylelint #459

@m-shum

Description

@m-shum

Describe the bug

Code gets re-formatted (incorrectly) when running lint-staged. Specifically, code that was broken onto multiple lines gets reformatted onto one line, causing style/max-statements-per-line errors.

For example:

  watch(isHydrated, () => {
    nextTick(() => {
      scrollY.value = window.scrollY
    })
  })

When running eslint --fix in lint-staged, the above becomes a single line. This does not happen when running lint in the terminal, nor does it happen on save so I suspect it's an issue that's tied to lint-staged, however lint-staged should be reading the same eslint config as VSCode.

The lint-staged command just runs eslint and stylelint (which shouldn't be linting <script></script>)

  "lint-staged": {
  "*.{js,ts,vue,scss,css}": [
    "eslint --fix",
    "stylelint \"**/*.{vue,css,scss}\" --fix"
  ]
}

Reproduction

https://stackblitz.com/edit/github-yosb9t?file=app.vue,package.json,.husky%2Fpre-commit,.husky%2F_%2F.gitignore,.husky%2F_%2Fhusky.sh,eslint.config.js

System Info

System:
    OS: macOS 14.4.1
    CPU: (10) arm64 Apple M1 Pro
    Memory: 104.28 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 18.12.0 - ~/.nvm/versions/node/v18.12.0/bin/node
    npm: 9.8.1 - ~/.nvm/versions/node/v18.12.0/bin/npm
  Browsers:
    Chrome: 124.0.6367.62
    Safari: 17.4.1

Used Package Manager

npm

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions