vscode-stylelint icon indicating copy to clipboard operation
vscode-stylelint copied to clipboard

feat: add ignorePath setting

Open tom-fletcher opened this issue 2 years ago • 2 comments

Summary

Adds an ignorePath setting to allow the user to set a custom path to an ignore file. Closes #158.

Additionally, passes the cwd to Stylelint in options. Closes #155.

Rationale

Add ignorePath setting

Stylelint CLI supports setting an --ignore-path path to a file containing patterns describing files to ignore. Stylelint API supports this with the ignorePath option. Currently the VSCode plugin does not provide this setting.

Setting an ignorePath is useful. Many people want to set this to use .gitignore or to use a file such as .lintignore (or similar) that it used by multiple linters.

Without this setting, the alternatives are to either only use the default .stylelintignore file, or to symlink .stylelintignore to the preferred file. In both cases, the requirement is to change the codebase structure to accommodate the plugin.

Providing this setting aligns the VSCode plugin's capabilities with the linter.

Pass cwd to Stylelint

As a side effect of adding the ignorePath setting, when using workspace folders it is also necessary to set Stylelint's cwd to that workspace folder.

Without setting the cwd, Stylelint's cwd will be the first folder in the workspace. As Stylelint will not ignore any paths that start with .., this means that files with relative paths to another workspace folder will be linted and not ignored (regardless of whether they have an ignorePath setting or the default .stylelintignore).

Fixing this was also necessary in order to create the e2e tests for ignorePath, since these tests are run in workspace folders.

Fix default ignore test

This PR also fixes and re-enables the e2e test for the default .stylelintignore case, which was marked as TODO.

Changes

Changes are non-breaking. If ignorePath is not set the plugin continues to look for a default .stylelintignore. cwd changes fix existing bug.

How did you test this change?

Implemented unit tests and e2e tests to cover. e2e tests also now cover the default .stylelintignore case.

Tested and verified manually against an existing codebase.

tom-fletcher avatar Apr 20 '22 02:04 tom-fletcher

any process?

tal-rofe avatar Jul 08 '22 17:07 tal-rofe

any progress?

tal-rofe avatar Jan 24 '23 19:01 tal-rofe

Closing due to no engagement from repo maintainers. Since, I don't use stylelint any more I would not be able to contribute to any future changes to this PR to bring it up to date with the main branch, so this just feels stale now.

tom-fletcher avatar Apr 06 '24 22:04 tom-fletcher

I am "fixing" it with a manually disable note in all ignored files.

Selection_778x138_20240421-14:06:14

davidsneighbour avatar Apr 21 '24 07:04 davidsneighbour