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
Deprecate stylistic rules handled by Prettier #6504
Conversation
I've created a one-time script to rewrite a lot of rule files. Usage: ```shell node scripts/deprecate-stylistic-rules-handled-by-prettier.mjs ```
🦋 Changeset detectedLatest commit: 23a4e75 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 |
@@ -1,5 +1,7 @@ | |||
# at-rule-name-case | |||
|
|||
> **Warning** This rule is deprecated and will be removed in the future. | |||
|
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.
[ask] I believe the warning message is helpful, but what do you think?
[note] GitHub renders the > **Warning**
text as follows:
On the other hand, Docusaurus has a different rendering syntax called Admonitions. E.g.
:::caution
This rule is deprecated and will be removed in the future.
:::
If using Admonitions, we need to rewrite the warning syntax on the stylelint.io repo.
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 believe the warning message is helpful, but what do you think?
LGTM
we need to rewrite the warning syntax on the stylelint.io repo.
Yes, but only if it's quick to do as:
- I think it'll look good enough on the website
- we'll be removing the rules in the next major release
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.
Agree. It looks like we don't need to add an extra process.
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.
@ybiquitous This is fantastic, thank you!
I've added a commit to add a migration entry. Although, not a breaking change it's a significant one that we need to walk our users through.
@@ -6,6 +6,25 @@ Please help us create, enhance, and debug our rules! | |||
|
|||
You should get yourself ready to [contribute code](../../CONTRIBUTING.md#code-contributions). | |||
|
|||
### Define the rule |
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.
[Note] Pulled this out so that the list of rules is near the top of the page.
@@ -1,12 +1,65 @@ | |||
# Migrating to 15.0.0 | |||
|
|||
## Remove support for processors | |||
This release contains significant and breaking changes that will help us modernize our code so that Stylelint remains free of security issues. |
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.
[Note] Provide some context to changes. Doesn't go into the details of:
- needing to migrate to ESM so we can keep as dependencies up to date
- we have limited resources and time to make that migration
We recommend: | ||
|
||
- using a pretty printer, like [Prettier](https://prettier.io/), alongside Stylelint | ||
- extending [our standard config](https://www.npmjs.com/package/stylelint-config-standard) in your configuration object |
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.
[Note] Opportunity to suggest our users adopt our standard config, if they haven't already.
} | ||
``` | ||
|
||
[Our standard config](https://www.npmjs.com/package/stylelint-config-standard) turns on many of the [other rules that enforce conventions](../user-guide/rules.md#enforce-conventions), e.g. most of the [`*-notation`](../user-guide/rules.md#notation), [`*-pattern`](../user-guide/rules.md#pattern) and [`*-quotes`](../user-guide/rules.md#quotes) rules. We recommend adding more of [the rules that enforce conventions](../user-guide/rules.md#enforce-conventions) to your config as many of them will be specific to your needs, e.g. what [units you allow](../../lib/rules/unit-allowed-list/README.md) in your code. |
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.
[Note] We originally positioned our standard config to be about formatting whitespace. It's changed significantly over time, especially now that we're deprecating the stylistic rules. This bit communicates that our standard config still offers plenty of value over our recommended config as it turns on a lot of rules that enforce conventions. Additionally, we recently regrouped how we list rules and this draws attention to that. All this is to inform our users that Stylelint is the best (and perhaps only) tool for enforcing non-stylistic conventions.
I suggest we mark the rules in our list that are included in our configs. This will help our users make use of the convention enforcing rules. Our current approach of listing rules in the config README isn't great as:
- the list has fallen out of date
- it's difficult to see the full picture of what rules are turned on and which aren't
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 suggest we mark the rules in our list that are included in our configs.
Sounds good. Do you already have an idea of how to realize it?
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.
Do you already have an idea of how to realize it?
I figured we could just whack an "R" and/or "S" on the end of the rule description and throw a key at the top. Something along the lines of:
(R & S) = In our recommended and standard configs
(S) = In our standard config
at-rule-no-unknown
: Disallow unknown at-rules (R).selector-attribute-quotes
: Require or disallow quotes for attribute values (Autofixable) (R & S).
What do you think?
(We can do it in a follow-up pull request.)
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 see. It's the simplest solution, but there is a way to use emojis and a table for more readability. This is an example of eslint-plugin-react
.
In addition, if we could add such information as R
and S
to each rule's metadata, it might be possible to check invalid documents or generate documents.
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.
Ⓡ and Ⓢ
} | ||
``` | ||
|
||
If you want to continue using Stylelint to enforce stylistic consistency, you can [migrate the deprecated rules you need to a plugin](../developer-guide/plugins.md). We will remove the rules from Stylelint in the next major release. |
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.
[Note] This is at the bottom as it's not the recommended route. The rules are problematic and a plugin would suffer the same issues:
- old code reliant on stylesearch
- not cleanly working with the AST
- introducing new lint problems
- a confusing number of configuration options
Pretty printing an AST based on the line length is a better approach.
@@ -29,18 +29,6 @@ npx stylelint "**/*.css" | |||
|
|||
_You should include quotation marks around file globs._ | |||
|
|||
If you use a pretty printer alongside Stylelint, you should turn off any conflicting rules. For example, you can use [Prettier's shared config](https://www.npmjs.com/package/stylelint-config-prettier) to do that: |
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.
[Note] We don't need to suggest using the config anymore as the configs won't conflict.
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.
@jeddy3 Thank you for writing up the documents. LGTM.
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.
LGTM too
I think we can merge this.
@@ -23,6 +23,7 @@ const messages = ruleMessages(ruleName, { | |||
const meta = { | |||
url: 'https://stylelint.io/user-guide/rules/block-closing-brace-newline-after', | |||
fixable: true, | |||
deprecated: true, |
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 wanted to check whether all the rules that were being deprecated were properly covered by prettier.
This one has options:
- "always"
- "always-single-line"
- "never-single-line"
- "always-multi-line"
- "never-multi-line"
Are all of these properly covered by prettier?
If not, we need to make a list of rules that are being deprecated but are only partially covered by the prettier replacement.
e.g.
name | support | note |
---|---|---|
rule A | full | |
rule B | partial | does not support option X and Y |
rule C | partial | only support option Z |
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 was please suggested list created? To see which deprecated rule can be covered by the prettier replacement? Thanks.
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.
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.
Ideally, we might make a list, but we need more resources. Also, it may not be precious since the rules will be removed in the next major update.
However, we welcome your contribution if you have time.
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.
Following on from #6657 (comment), I suggest the people working on the plugin pack draw up the list.
As @ybiquitous said, we've other things to focus on (that will benefit most of our users). I suspect most people already use a pretty printer alongside Stylelint (as we've been advocating that approach for over a year now in our docs), and most of those who don't will soon, as it's our recommended approach in our new migration guide.
Anyone wanting to continue using Stylelint for formatting can work together on a community plugin pack. As with custom syntaxes, the health of the plugin will be determined by the health of the community that maintains it.
Closes #6342
I've created a one-time script to rewrite a lot of rule files.
Usage: