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

Stylelint report throws when stylelint-ignore is used #272

Open
amiller-gh opened this issue Aug 20, 2023 · 1 comment
Open

Stylelint report throws when stylelint-ignore is used #272

amiller-gh opened this issue Aug 20, 2023 · 1 comment

Comments

@amiller-gh
Copy link

Describe the bug

When /* stylelint-ignore */ is added to the top of a file, the module throws with:

TypeError: Cannot read properties of undefined (reading 'css')
    at /node_modules/vite-plugin-checker/dist/esm/logger.js:283:41
    at Array.map (<anonymous>)
    at normalizeStylelintDiagnostic (/node_modules/vite-plugin-checker/dist/esm/logger.js:258:30)
    at /node_modules/vite-plugin-checker/dist/esm/checkers/stylelint/main.js:91:47
    at Array.map (<anonymous>)
    at Object.configureServer (/node_modules/vite-plugin-checker/dist/esm/checkers/stylelint/main.js:91:36)

Reproduction

Add /* stylelint-ignore */ to the top of any file, observe the error.

Expected behavior

The process doesn't crash! ;)

System Info

System:
    OS: macOS 13.2.1
    CPU: (10) arm64 Apple M2 Pro
    Memory: 49.84 MB / 16.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 18.16.0 - ~/.nvm/versions/node/v18.16.0/bin/node
    Yarn: 1.22.19 - ~/.nvm/versions/node/v18.16.0/bin/yarn
    npm: 9.5.1 - ~/.nvm/versions/node/v18.16.0/bin/npm
  Browsers:
    Chrome: 115.0.5790.170
    Safari: 16.3


### Additional context

Offending line is here: https://github.com/fi3ework/vite-plugin-checker/blob/e564641ac312eba95286b717177af27eb48bcf07/packages/vite-plugin-checker/src/logger.ts#L427C28-L427C28

Updating with optional chaining to `diagnostic?._postcssResult?.css ?? ''` fixes the issue!

### Validations

- [X] Read the [docs](https://github.com/fi3ework/vite-plugin-checker#readme).
- [X] Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
@liukonghe
Copy link

liukonghe commented Nov 12, 2023

I've encountered a similar issue and have been working on a fix for it. You can check out my Pull Request #284 to see if it addresses your problem.

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