Skip to content

docs: mark rules that are frozen on rules index page #11467

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

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions packages/eslint-plugin/docs/rules/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,16 @@ module.exports = {
```

[Search for `🧱 extension rule`s](?=extension#rules) in this page to see all extension rules.

## Frozen Rules

When rules are feature complete, they are marked as frozen (indicated with ❄️ in the documentation). This applies to standalone rules that are complete, as well as [extension rules](#extension-rules) whose underlying core ESLint rules are frozen. After that point, we expect users to use [disable comments](https://eslint.org/docs/latest/use/configure/rules#using-configuration-comments-1) when they find an edge case that isn’t covered.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is slightly different from the ESLint's.
I don't quite understand the 80% policy, so I added a line that says the dependent ESLint rule is frozen.
However, my English isn't very good, so I'm not sure if the meaning is natural.


When a rule is frozen, it means:

- **Bug fixes**: We will still fix confirmed bugs.
- **New ECMAScript features**: We will ensure compatibility with new ECMAScript features, meaning the rule will not break on new syntax.
- **TypeScript support**: We will ensure compatibility with TypeScript syntax, meaning the rule will not break on TypeScript syntax and violations are appropriate for TypeScript.
- **New options**: We will not add any new options unless an option is the only way to fix a bug or support a newly-added ECMAScript feature.

If you find that a frozen rule would work better for you with a change, we recommend copying the rule source code and modifying it to fit your needs.
1 change: 1 addition & 0 deletions packages/eslint-plugin/src/rules/default-param-last.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export default createRule({
docs: {
description: 'Enforce default parameters to be last',
extendsBaseRule: true,
frozen: true,
},
messages: {
shouldBeLast: 'Default parameters should be last.',
Expand Down
1 change: 1 addition & 0 deletions packages/eslint-plugin/src/rules/dot-notation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export default createRule<Options, MessageIds>({
docs: {
description: 'Enforce dot notation whenever possible',
extendsBaseRule: true,
frozen: true,
recommended: 'stylistic',
requiresTypeChecking: true,
},
Expand Down
1 change: 1 addition & 0 deletions packages/eslint-plugin/src/rules/init-declarations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export default createRule<Options, MessageIds>({
description:
'Require or disallow initialization in variable declarations',
extendsBaseRule: true,
frozen: true,
},
hasSuggestions: baseRule.meta.hasSuggestions,
messages: baseRule.meta.messages,
Expand Down
1 change: 1 addition & 0 deletions packages/eslint-plugin/src/rules/member-ordering.ts
Original file line number Diff line number Diff line change
Expand Up @@ -728,6 +728,7 @@ export default createRule<Options, MessageIds>({
type: 'suggestion',
docs: {
description: 'Require a consistent member declaration order',
frozen: true,
},
messages: {
incorrectGroupOrder:
Expand Down
1 change: 1 addition & 0 deletions packages/eslint-plugin/src/rules/naming-convention.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ export default createRule<Options, MessageIds>({
description:
'Enforce naming conventions for everything across a codebase',
// technically only requires type checking if the user uses "type" modifiers
frozen: true,
requiresTypeChecking: true,
},
messages: {
Expand Down
1 change: 1 addition & 0 deletions packages/eslint-plugin/src/rules/no-magic-numbers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export default createRule<Options, MessageIds>({
docs: {
description: 'Disallow magic numbers',
extendsBaseRule: true,
frozen: true,
},
messages: baseRule.meta.messages,
schema: [schema],
Expand Down
1 change: 1 addition & 0 deletions packages/eslint-plugin/src/rules/prefer-destructuring.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ export default createRule<Options, MessageIds>({
docs: {
description: 'Require destructuring from arrays and/or objects',
extendsBaseRule: true,
frozen: true,
requiresTypeChecking: true,
},
fixable: baseRule.meta.fixable,
Expand Down
5 changes: 5 additions & 0 deletions packages/utils/src/ts-eslint/Rule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ export interface RuleMetaDataDocs {
* The URL of the rule's docs.
*/
url?: string;

/**
* Mark this rule as frozen.
*/
frozen?: boolean;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we decide where to put the description of frozen, can link it here too.

}

export interface ExternalSpecifier {
Expand Down
9 changes: 6 additions & 3 deletions packages/website/src/components/RulesTable/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,12 @@ function RuleRow({
return (
<tr>
<td>
<Link to={new URL(rule.docs.url).pathname}>
<code>@typescript-eslint/{rule.name}</code>
</Link>
<div className={styles.ruleNameWrapper}>
<Link to={new URL(rule.docs.url).pathname}>
<code>@typescript-eslint/{rule.name}</code>
</Link>
{rule.docs.frozen && <span>❄️</span>}
</div>
<br />
{interpolateCode(rule.docs.description)}
</td>
Expand Down
6 changes: 6 additions & 0 deletions packages/website/src/components/RulesTable/styles.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -145,3 +145,9 @@
text-align: center;
cursor: default;
}

.ruleNameWrapper {
display: flex;
align-items: center;
gap: 0.5rem;
}
12 changes: 12 additions & 0 deletions packages/website/src/theme/MDXComponents/RuleAttributes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,18 @@ export function RuleAttributes({ name }: { name: string }): React.ReactNode {
});
}

if (rule.docs.frozen) {
features.push({
children: (
<>
This rule is currently <Link href="/rules#frozen-rules">frozen</Link>{' '}
and is not accepting feature requests.
</>
),
emoji: '❄️',
});
}

return (
<div className={styles.features}>
{features.map(feature => (
Expand Down
Loading