gilbarbara / codeclimate-stylelint

A Code Climate engine for the mighty, modern CSS linter
24 stars 18 forks source link

Resolve ignoreFiles relative paths #48

Closed fede-moya closed 3 years ago

fede-moya commented 3 years ago

This is the second attempt for fixing an issue related the use of relative paths on a given stylelint configuration file.

On the first attempt I tried to point stylelint's base dir to /code where the source code to analyze is. This was actually a bad diagnose, it only worked because in the users's source code there was a node_modules folder containing the necessary stylelint's packages.

Reading stylelint's api docs more carefully I found the following:

https://stylelint.io/user-guide/configure#ignorefiles

-- ignoreFiles

You can provide a glob or array of globs to ignore specific files.

For example, you can ignore all JavaScript files:

{
  "ignoreFiles": ["**/*.js"]
}

stylelint ignores the node_modules directory by default. However, this is overridden if ignoreFiles is set.

If the globs are absolute paths, they are used as is. If they are relative, they are analyzed relative to

  • configBasedir, if it's provided;
  • the config's filepath, if the config is a file that stylelint found a loaded;
  • or process.cwd().

So, if you set configBaseDir then that dir will became the root for relative paths indicated in the ignoreFiles config. If we want to set the configBaseDir to indicate stylelint from where to extract the necessary packages then we will need to modify user's ignoreFiles configuration to use absolute paths.

gilbarbara commented 3 years ago

I can't accept merge commits, besides the conflict. Please rebase your branch properly.

Also, since this PR adds new dependencies, please add tests to cover the changes.

fede-moya commented 3 years ago

I can't accept merge commits, besides the conflict. Please rebase your branch properly.

Also, since this PR adds new dependencies, please add tests to cover the changes.

@gilbarbara Sorry for the mess, and thank you for the indications. Updated.

fede-moya commented 3 years ago

@gilbarbara 🙌🏼

efueger commented 3 years ago

Hi @gilbarbara - thanks for your help with this! LMK if you need anything else from Code Climate's side.

efueger commented 3 years ago

@gilbarbara - checking to see if you can merge this. Thanks in advance for the help!