-
-
Notifications
You must be signed in to change notification settings - Fork 934
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
refactor fixers of selector-not-notation
and function-name-case
#7706
Conversation
🦋 Changeset detectedLatest commit: 276cdfa The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
958a04c
to
cea3150
Compare
@romainmenke @ybiquitous
I would like to have your opinions. |
|
||
return { | ||
start: { line: startline, column: pseudo.source.start.column }, | ||
end: { line: endline, column: pseudo.source.end.column + 1 }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor
questions
@romainmenke
Why do I need + 1
here?
Is this a bug?
Thinking about it more, I think a mix of the 3 is possible.
For the users it's transparent and the migration will be smoother. tl;dr: tests on |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Mouvedia Thanks for working on old issues! I'm still reading the code, but I've left a few comments for you to address.
|
||
return { | ||
start: { line: startline, column: pseudo.source.start.column }, | ||
end: { line: endline, column: pseudo.source.end.column + 1 }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm reading the code in this PR, but this seems related to endColumn
in PostCSS API: ⬇️
Column for exclusive end position in the input file with this warning’s source.
The following test code:
import postcss from 'postcss';
import selectorParser from 'postcss-selector-parser';
const print = ({ start, end }) => {
const { line: sLine, column: sCol } = start;
const { line: eLine, column: eCol } = end;
console.log('start: %o, end: %o', { line: sLine, column: sCol }, { line: eLine, column: eCol });
};
console.log('.abc {}');
console.log('1234567');
console.log('---');
print(postcss.parse('.abc {}').nodes[0].source);
print(selectorParser().astSync('.abc').nodes[0].nodes[0].source);
prints below: ⬇️
.abc {}
1234567
---
start: { line: 1, column: 1 }, end: { line: 1, column: 7 }
start: { line: 1, column: 1 }, end: { line: 1, column: 4 }
It seems that postcss
and postcss-selector-parser
are consistent for source positions.
I have rebased on |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for taking up this effort @Mouvedia!
I have one concern with this change and that is that it seems to defer the fixes.
Is that correct?
The order of execution seems to change to roughly:
- lint source with Rule A
- capture fixes for Rule A in a callback
- lint source with Rule B
- capture fixes for Rule B in a callback
- lint source with Rule C
- capture fixes for Rule C in a callback
- ...
- apply fixes for Rules A, B, C, ...
While the current order of execution is roughly :
- lint source with Rule A
- apply fixes for Rule A
- lint source with Rule B
- apply fixes for Rule B
- lint source with Rule C
- apply fixes for Rule C
- ...
This change means that we have to define what happens in these scenario's and add sufficient test coverage:
- two rules mutate the same AST node
- a rule mutates an AST node that has since been removed
- a rule inserts a new node and this new node can be autofixed by another rule (e.g. insert
:not()
and something else enforces allcaps:NOT()
, not sure if we have such conflicts, but they will definitely exist) - ...
I have tested one of your scenarios. You are completely right; this is an obvious oversight. |
#2643
Most of the rules won't require as much work as
selector-not-notation
to transition.That's why I have chosen to refactor a simpler rule to demonstrate how easy it could be.
This PR unlocks #7192 and #4664.
selector-not-notation
now reports new line ranges correctlyfunction-name-case
reports the full name instead of the first letter previouslysee #7706 (comment)
tests can be found here:
c162413
(#7729)stylelint-disable
stylelint-disable-line
stylelint-disable-next-line
stylelint-* foo-bar
stylelint-* foo-bar, qux-baz
ignoreDisables
stylelint.utils