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
Fix overrides.files
in config for glob patterns like *.vue
#6525
Comments
@sronveaux Thanks for the report with the reproduction repository. The |
Hi @ybiquitous and thanks for the very fast reply. I tried as suggested to run with
Whether I write To clarify a little bit more a concrete use case where this config is used, I have a project where I have a Django backend serving multiple Vue SPA. The whole Django part is inside a That's why I was wondering if it wouldn't be logical that the content of the I currently simply installed stylelint at the root of my repository for this to work properly, but this structure is not very tidy and should be avoided. I should also add that I encounter problems with the |
I understand your pain point. However, let me make the reproduction steps clear. $ git clone https://github.com/sronveaux/stylelint-bug-report
...
$ cd stylelint-bug-report/stylelintInstall
$ npm install
...
$ ./node_modules/.bin/stylelint ../filesToLint/*
../filesToLint/test.css
1:1 ✖ Expected class selector ".trucBidule" to be kebab-case selector-class-pattern
2:24 ✖ Unexpected missing generic font family font-family-no-missing-generic-family-keyword
2:24 ✖ Unexpected duplicate name Roboto font-family-no-duplicate-names
../filesToLint/test.html
10:57 ✖ Unexpected missing generic font family font-family-no-missing-generic-family-keyword
10:57 ✖ Unexpected duplicate name Roboto font-family-no-duplicate-names
5 problems (5 errors, 0 warnings) Everything works here. $ cd ..
$ ./stylelintInstall/node_modules/.bin/stylelint ./filesToLint/*
Error: Could not find "stylelint-config-standard". Do you need a `configBasedir`?
... We get the error, as you commented. $ ./stylelintInstall/node_modules/.bin/stylelint ./filesToLint/* --config-basedir "$PWD/stylelintInstall"
/Users/koba/tmp/stylelint-bug-report/filesToLint/test.html: When linting something other than CSS, you should install an appropriate syntax, e.g. "postcss-html", and use the "customSyntax" option
filesToLint/test.css
1:1 ✖ Expected class selector ".trucBidule" to be kebab-case selector-class-pattern
2:24 ✖ Unexpected missing generic font family font-family-no-missing-generic-family-keyword
2:24 ✖ Unexpected duplicate name Roboto font-family-no-duplicate-names
filesToLint/test.html
1:1 ✖ Unknown word CssSyntaxError
4 problems (4 errors, 0 warnings) Now, an error about Are the reproduction steps above what you expect? |
Hi @ybiquitous and thanks again, That's exactly the reproduction steps. To keep it simple, from there, I wonder how I can manage to lint the .html files without changing the |
Thanks. I found a bug in the I believe Line 390 in e30ec86
stylelint/lib/getPostcssResult.js Line 95 in e30ec86
We need to pass stylelint/lib/augmentConfig.js Line 155 in e30ec86
So, I will try writing a patch to fix the bug within a few days. Or if you are interested in the contribution, please consider contributing. Thank you so much for the detailed report! |
customSyntax
resolution with configBasedir
Many thanks for the fast investigation here! I'm not 100% sure solving this bug will solve the reported problem but as I've said earlier, I haven't delved in the source code enough to fully understand all the consequences of such a change... What you've found clearly makes sense and the proposed solution would be more logical for sure ! I'll be very happy if the detailed report helps to make stylelint better! Thanks again! |
@sronveaux I've opened PR #6536 which could fix your problem. If you have time, could you try it? You can install it via: npm install 'github:stylelint/stylelint#issue-6525' |
@ybiquitous thanks for the fast reply and patch, unfortunately, this doesn't solve my problem as I still have to write the overrides part of the config file as
and writing It seems that what you write inside It also seems, on my computer, not to fix what you had written above in reproduction steps:
I personally still encounter this problem, except if I patch the |
Oh, sorry, my bad. Actually, PR #6536 doesn't fix your problem. The cause is that relative
// .stylelintrc.js
module.exports = {
overrides: [
{
files: ["../*.vue", "../**/*.vue"],
extends: ["stylelint-config-recommended", "stylelint-config-html"],
rules: require("stylelint-config-recommended-vue/lib/vue-specific-rules"),
},
],
}
I would be happy to find another excellent solution, but unfortunately, I can't think of one right now... |
@ybiquitous, thanks for the fast reply. No problem, that's how I'm working for now, having I personally think there is something to be improved in the future here as the idea of having a single installation of In fact, what could be improved is linked to this part of the documentation:
I personally think as the first point says that configs such as Many thanks again for your time, and thanks for sharing such a great project ! Seasons greetings, |
customSyntax
resolution with configBasedir
overrides.files
in config for glob patterns like *.vue
@sronveaux I've created another PR #6547 to fix the problem of glob patterns like npm install 'github:stylelint/stylelint#issue-6525' |
@ybiquitous thanks again for the fast reply to my last answer. I just tried PR #6547 and I can tell you that it fixes everything! Many thanks again for the time spent on this issue, the result works better than expected! Hope this will be added to the next release! Thanks for the excellent work and the excellent software which is Cheers, |
What steps are needed to reproduce the bug?
Well, I'll try to be clear here as it is not easy to explain...
I created a simple repo that you can clone to reproduce the bug: https://github.com/sronveaux/stylelint-bug-report
Here's the smallest code base I managed to get to and that can be used to reproduce the bug:
The .stylelintrc content is very simple:
If I get to the stylelintInstall directory and run the following commands:
everything works as expected. However, if configBasedir is added:
The .html files cannot be linted anymore and the following message is returned:
This can be made working back again by changing the content of the .stylelintrc file like this:
However this manual patch doesn't work when used in conjuction with extensions like
stylelint-config-standard-vue
, not to mention how it fails when used through theVSCode extension
...What Stylelint configuration is needed to reproduce the bug?
How did you run Stylelint?
CLI
Which version of Stylelint are you using?
14.16.0 under Windows 11
What did you expect to happen?
Shouldn't the glob patterns we write in the .stylelintrc file be relative to this config file instead of being interpreted differently when used in conjunction with --config-basedir ?
What actually happened?
It seems like the file matching in the
overrides
part of the config is dependent on theconfig-basedir
as the problem can be solved by changing the glob pattern written in theoverrides
part.Does the bug relate to non-standard syntax?
No response
Proposal to fix the bug
Not sure exactly and haven't read the source code long enough, but this could be linked to this part:
stylelint/lib/augmentConfig.js
Lines 106 to 113 in e30ec86
Here we can see that
configDir
(which is in factconfigBasedir
) is passed twice to theaugmentConfigBasic
function.stylelint/lib/augmentConfig.js
Lines 34 to 63 in e30ec86
Then
augmentConfigBasic
seems to callapplyOverrides
with therootConfigDir
parameter which perhaps should be the directory where the config file is and notconfigBasedir
...The text was updated successfully, but these errors were encountered: