gilbarbara/codeclimate-stylelint

codeclimate-stylelint bug

davehenton opened this issue · 6 comments

Hey @gilbarbara. Dave here with Code Climate Support. I'm trying to help a user out with a potential bug they're running into.

Specifically, they're seeing the following build error using Stylelint on codeclimate.com:

engine stylelint failed with status 1 and stderr 
•• Timing: .engineConfig: 0.51s
Error: Unexpected token � in JSON at position 0
See our documentation at https://docs.codeclimate.com/docs/stylelint for more information.

From user:

When I run it standalone, like so:
./node_modules/.bin/stylelint "frontend/**/*.scss"

it works just fine. I've attached my .stylelintrc.json file.
Note: I've also tried .stylelintrc and .stylelintrc.yaml.
Package.json includes:
"stylelint": "^9.9.0",
"stylelint-config-standard": "^18.2.0",

Here's a copy of the user's stylelintrc.json:
stylelintrc.json.txt

The user attempted to reproduce the error locally (via the Code Climate CLI) and then fixed it (somehow):

I issued

docker run \
  --interactive --tty --rm \
  --env CODECLIMATE_CODE="$PWD/foo" \
  --volume "$PWD/foo":/code \
  --volume /var/run/docker.sock:/var/run/docker.sock \
  --volume /tmp/cc:/tmp/cc \
  codeclimate/codeclimate analyze -e stylelint .

and got the same E10 error.

Later, I installed the CLI wrapper fully using the 'Anywhere' script at https://github.com/codeclimate/codeclimate

I then issued codeclimate engines:install stylelint following the instructions at https://github.com/gilbarbara/codeclimate-stylelint, and now my local codeclimate is using stylelint just fine.

To confirm it, I ran the docker image directly using the exact same command up above and it's still working. I'm not sure what I changed, but apparently it helped. Perhaps I updated the version of codeclimate-stylelint I'm using and the new version has a bug fix?

Running engines:install would install an updated version of the engine, but that wouldn't explain why it seems to be erroring in production. Our production image is up to date with what the CLI should be using as well. So we're curious if this is a bug still affecting this stylelint plugin, and if it might have stopped erroring locally due to some other minor environmental change or something.

Let me know if I can provide any further help or information here. Happy to help in any way I can.

Hi, I'm the user in question. If there's any troubleshooting steps I can perform I'd love to know. I don't think this could be related to my actual styles because it seems to be dying during initialization.

Hey!

I couldn't reproduce this error. Are you sure this isn't something with the json config? Have you tried to use a js config?

I'm trying to update the dependencies and release a new version with stylelint 9.9.0 but my local codeclimate cli isn't finishing and tests are falling.
I'll try again tomorrow. It's late and I must be missing something.

@gilbarbara Thanks for the quick response!

I got the same error in CC production with the following config

// stylelint.config.js
module.exports = {
  extends: "stylelint-config-standard"
};

Error:

•• Timing: .engineConfig: 0.36s
Error: Unexpected token � in JSON at position 0
See our documentation at https://docs.codeclimate.com/docs/stylelint for more information.

I'm curious about the "U+FFFD at position 0" message. This kinda-sorta sounds like a BOM error, though I've validated that my config file has no BOM. It's also curious that even with a JS config file it's complaining about a JSON syntax error.

@davehenton I'm assuming that you can get a complete stack trace of this error. What JSON file is it talking about?

On a hunch I submitted another build with the following config:

//stylelint.config.js
I'm a bad

And I got the same error output. I don't think this is related to my config file.

I've updated the dependencies and tagged it as v2.1.0

@davehenton Can you update it on codeclimate.com?

Also, are any more users having problems with this engine? I really don't know what else can I do on my side to debug this error.

Hey @gilbabara. We recently updated the stylelint plugin Code Climate to incorporate the changes you made with v2.1.0. Unfortunately, this hasn't resolved the issue we're seeing with these failed styelint builds. Do you have other ideas on what might be at play? Let me know what other information I can provide.

@davehenton I don't, sorry.