Skip to content

Commit 04dea84

Browse files
feat(eslint-plugin): deprecate formatting (meta.type: layout) rules (#8073)
* feat(eslint-plugin): deprecate formatting (meta.type: layout) rules * fix: whoops, forgot to commit all.ts changes * Add replacedBy * Update formatting admonition * Missed object-curly-spacing * areOptionsValid undo * Correct configs and tweak deprecation notice
1 parent b1c92bb commit 04dea84

23 files changed

+66
-47
lines changed

packages/eslint-plugin/src/configs/all.ts

-38
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,9 @@ export = {
1414
'@typescript-eslint/ban-ts-comment': 'error',
1515
'@typescript-eslint/ban-tslint-comment': 'error',
1616
'@typescript-eslint/ban-types': 'error',
17-
'block-spacing': 'off',
18-
'@typescript-eslint/block-spacing': 'error',
19-
'brace-style': 'off',
20-
'@typescript-eslint/brace-style': 'error',
2117
'@typescript-eslint/class-literal-property-style': 'error',
2218
'class-methods-use-this': 'off',
2319
'@typescript-eslint/class-methods-use-this': 'error',
24-
'comma-dangle': 'off',
25-
'@typescript-eslint/comma-dangle': 'error',
26-
'comma-spacing': 'off',
27-
'@typescript-eslint/comma-spacing': 'error',
2820
'@typescript-eslint/consistent-generic-constructors': 'error',
2921
'@typescript-eslint/consistent-indexed-object-style': 'error',
3022
'@typescript-eslint/consistent-type-assertions': 'error',
@@ -38,23 +30,10 @@ export = {
3830
'@typescript-eslint/explicit-function-return-type': 'error',
3931
'@typescript-eslint/explicit-member-accessibility': 'error',
4032
'@typescript-eslint/explicit-module-boundary-types': 'error',
41-
'func-call-spacing': 'off',
42-
'@typescript-eslint/func-call-spacing': 'error',
43-
indent: 'off',
44-
'@typescript-eslint/indent': 'error',
4533
'init-declarations': 'off',
4634
'@typescript-eslint/init-declarations': 'error',
47-
'key-spacing': 'off',
48-
'@typescript-eslint/key-spacing': 'error',
49-
'keyword-spacing': 'off',
50-
'@typescript-eslint/keyword-spacing': 'error',
51-
'lines-around-comment': 'off',
52-
'@typescript-eslint/lines-around-comment': 'error',
53-
'lines-between-class-members': 'off',
54-
'@typescript-eslint/lines-between-class-members': 'error',
5535
'max-params': 'off',
5636
'@typescript-eslint/max-params': 'error',
57-
'@typescript-eslint/member-delimiter-style': 'error',
5837
'@typescript-eslint/member-ordering': 'error',
5938
'@typescript-eslint/method-signature-style': 'error',
6039
'@typescript-eslint/naming-convention': 'error',
@@ -73,8 +52,6 @@ export = {
7352
'@typescript-eslint/no-empty-interface': 'error',
7453
'@typescript-eslint/no-explicit-any': 'error',
7554
'@typescript-eslint/no-extra-non-null-assertion': 'error',
76-
'no-extra-parens': 'off',
77-
'@typescript-eslint/no-extra-parens': 'error',
7855
'no-extra-semi': 'off',
7956
'@typescript-eslint/no-extra-semi': 'error',
8057
'@typescript-eslint/no-extraneous-class': 'error',
@@ -138,10 +115,6 @@ export = {
138115
'@typescript-eslint/no-useless-template-literals': 'error',
139116
'@typescript-eslint/no-var-requires': 'error',
140117
'@typescript-eslint/non-nullable-type-assertion-style': 'error',
141-
'object-curly-spacing': 'off',
142-
'@typescript-eslint/object-curly-spacing': 'error',
143-
'padding-line-between-statements': 'off',
144-
'@typescript-eslint/padding-line-between-statements': 'error',
145118
'@typescript-eslint/parameter-properties': 'error',
146119
'@typescript-eslint/prefer-as-const': 'error',
147120
'prefer-destructuring': 'off',
@@ -162,28 +135,17 @@ export = {
162135
'@typescript-eslint/prefer-string-starts-ends-with': 'error',
163136
'@typescript-eslint/prefer-ts-expect-error': 'error',
164137
'@typescript-eslint/promise-function-async': 'error',
165-
quotes: 'off',
166-
'@typescript-eslint/quotes': 'error',
167138
'@typescript-eslint/require-array-sort-compare': 'error',
168139
'require-await': 'off',
169140
'@typescript-eslint/require-await': 'error',
170141
'@typescript-eslint/restrict-plus-operands': 'error',
171142
'@typescript-eslint/restrict-template-expressions': 'error',
172143
'no-return-await': 'off',
173144
'@typescript-eslint/return-await': 'error',
174-
semi: 'off',
175-
'@typescript-eslint/semi': 'error',
176145
'@typescript-eslint/sort-type-constituents': 'error',
177-
'space-before-blocks': 'off',
178-
'@typescript-eslint/space-before-blocks': 'error',
179-
'space-before-function-paren': 'off',
180-
'@typescript-eslint/space-before-function-paren': 'error',
181-
'space-infix-ops': 'off',
182-
'@typescript-eslint/space-infix-ops': 'error',
183146
'@typescript-eslint/strict-boolean-expressions': 'error',
184147
'@typescript-eslint/switch-exhaustiveness-check': 'error',
185148
'@typescript-eslint/triple-slash-reference': 'error',
186-
'@typescript-eslint/type-annotation-spacing': 'error',
187149
'@typescript-eslint/typedef': 'error',
188150
'@typescript-eslint/unbound-method': 'error',
189151
'@typescript-eslint/unified-signatures': 'error',

packages/eslint-plugin/src/rules/block-spacing.ts

+2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ export type MessageIds = InferMessageIdsTypeFromRule<typeof baseRule>;
1717
export default createRule<Options, MessageIds>({
1818
name: 'block-spacing',
1919
meta: {
20+
deprecated: true,
21+
replacedBy: ['@stylistic/block-spacing'],
2022
type: 'layout',
2123
docs: {
2224
description:

packages/eslint-plugin/src/rules/brace-style.ts

+2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ export type MessageIds = InferMessageIdsTypeFromRule<typeof baseRule>;
1616
export default createRule<Options, MessageIds>({
1717
name: 'brace-style',
1818
meta: {
19+
deprecated: true,
20+
replacedBy: ['@stylistic/brace-style'],
1921
type: 'layout',
2022
docs: {
2123
description: 'Enforce consistent brace style for blocks',

packages/eslint-plugin/src/rules/comma-dangle.ts

+2
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ function normalizeOptions(options: Option): NormalizedOptions {
4646
export default createRule<Options, MessageIds>({
4747
name: 'comma-dangle',
4848
meta: {
49+
deprecated: true,
50+
replacedBy: ['@stylistic/comma-dangle'],
4951
type: 'layout',
5052
docs: {
5153
description: 'Require or disallow trailing commas',

packages/eslint-plugin/src/rules/comma-spacing.ts

+2
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ type MessageIds = 'missing' | 'unexpected';
2222
export default createRule<Options, MessageIds>({
2323
name: 'comma-spacing',
2424
meta: {
25+
deprecated: true,
26+
replacedBy: ['@stylistic/comma-spacing'],
2527
type: 'layout',
2628
docs: {
2729
description: 'Enforce consistent spacing before and after commas',

packages/eslint-plugin/src/rules/func-call-spacing.ts

+2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ export type MessageIds =
2323
export default createRule<Options, MessageIds>({
2424
name: 'func-call-spacing',
2525
meta: {
26+
deprecated: true,
27+
replacedBy: ['@stylistic/func-call-spacing'],
2628
type: 'layout',
2729
docs: {
2830
description:

packages/eslint-plugin/src/rules/indent.ts

+2
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ const KNOWN_NODES = new Set([
9292
export default createRule<Options, MessageIds>({
9393
name: 'indent',
9494
meta: {
95+
deprecated: true,
96+
replacedBy: ['@stylistic/indent'],
9597
type: 'layout',
9698
docs: {
9799
description: 'Enforce consistent indentation',

packages/eslint-plugin/src/rules/key-spacing.ts

+2
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ const baseSchema = Array.isArray(baseRule.meta.schema)
2727
export default createRule<Options, MessageIds>({
2828
name: 'key-spacing',
2929
meta: {
30+
deprecated: true,
31+
replacedBy: ['@stylistic/key-spacing'],
3032
type: 'layout',
3133
docs: {
3234
description:

packages/eslint-plugin/src/rules/keyword-spacing.ts

+2
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ const schema = deepMerge(
3737
export default createRule<Options, MessageIds>({
3838
name: 'keyword-spacing',
3939
meta: {
40+
deprecated: true,
41+
replacedBy: ['@stylistic/keyword-spacing'],
4042
type: 'layout',
4143
docs: {
4244
description: 'Enforce consistent spacing before and after keywords',

packages/eslint-plugin/src/rules/lines-around-comment.ts

+2
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ function getCommentLineNums(comments: TSESTree.Comment[]): number[] {
5050
export default createRule<Options, MessageIds>({
5151
name: 'lines-around-comment',
5252
meta: {
53+
deprecated: true,
54+
replacedBy: ['@stylistic/lines-around-comment'],
5355
type: 'layout',
5456
docs: {
5557
description: 'Require empty lines around comments',

packages/eslint-plugin/src/rules/lines-between-class-members.ts

+2
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ const schema = Object.values(
3333
export default createRule<Options, MessageIds>({
3434
name: 'lines-between-class-members',
3535
meta: {
36+
deprecated: true,
37+
replacedBy: ['@stylistic/line-between-class-members'],
3638
type: 'layout',
3739
docs: {
3840
description: 'Require or disallow an empty line between class members',

packages/eslint-plugin/src/rules/member-delimiter-style.ts

+2
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,8 @@ const BASE_SCHEMA: JSONSchema4 = {
136136
export default createRule<Options, MessageIds>({
137137
name: 'member-delimiter-style',
138138
meta: {
139+
deprecated: true,
140+
replacedBy: ['@stylistic/member-delimiter-style'],
139141
type: 'layout',
140142
docs: {
141143
description:

packages/eslint-plugin/src/rules/no-extra-parens.ts

+2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ type MessageIds = InferMessageIdsTypeFromRule<typeof baseRule>;
2020
export default createRule<Options, MessageIds>({
2121
name: 'no-extra-parens',
2222
meta: {
23+
deprecated: true,
24+
replacedBy: ['@stylistic/no-extra-parens'],
2325
type: 'layout',
2426
docs: {
2527
description: 'Disallow unnecessary parentheses',

packages/eslint-plugin/src/rules/object-curly-spacing.ts

+2
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,12 @@ export default createRule<Options, MessageIds>({
2424
// eslint-disable-next-line eslint-plugin/prefer-message-ids,eslint-plugin/require-meta-type,eslint-plugin/require-meta-schema,eslint-plugin/require-meta-fixable -- all in base rule - https://github.com/not-an-aardvark/eslint-plugin-eslint-plugin/issues/274
2525
meta: {
2626
...baseRule.meta,
27+
deprecated: true,
2728
docs: {
2829
description: 'Enforce consistent spacing inside braces',
2930
extendsBaseRule: true,
3031
},
32+
replacedBy: ['@stylistic/object-curly-spacing'],
3133
},
3234
defaultOptions: ['never'],
3335
create(context) {

packages/eslint-plugin/src/rules/padding-line-between-statements.ts

+2
Original file line numberDiff line numberDiff line change
@@ -590,6 +590,8 @@ const StatementTypes: Record<string, NodeTestObject> = {
590590
export default createRule<Options, MessageIds>({
591591
name: 'padding-line-between-statements',
592592
meta: {
593+
deprecated: true,
594+
replacedBy: ['@stylistic/padding-line-between-statements'],
593595
type: 'layout',
594596
docs: {
595597
description: 'Require or disallow padding lines between statements',

packages/eslint-plugin/src/rules/quotes.ts

+2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ export type MessageIds = InferMessageIdsTypeFromRule<typeof baseRule>;
1616
export default createRule<Options, MessageIds>({
1717
name: 'quotes',
1818
meta: {
19+
deprecated: true,
20+
replacedBy: ['@stylistic/quotes'],
1921
type: 'layout',
2022
docs: {
2123
description:

packages/eslint-plugin/src/rules/semi.ts

+2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ export type MessageIds = InferMessageIdsTypeFromRule<typeof baseRule>;
1616
export default createRule<Options, MessageIds>({
1717
name: 'semi',
1818
meta: {
19+
deprecated: true,
20+
replacedBy: ['@stylistic/semi'],
1921
type: 'layout',
2022
docs: {
2123
description: 'Require or disallow semicolons instead of ASI',

packages/eslint-plugin/src/rules/space-before-blocks.ts

+2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ export type MessageIds = InferMessageIdsTypeFromRule<typeof baseRule>;
1616
export default createRule<Options, MessageIds>({
1717
name: 'space-before-blocks',
1818
meta: {
19+
deprecated: true,
20+
replacedBy: ['@stylistic/space-before-blocks'],
1921
type: 'layout',
2022
docs: {
2123
description: 'Enforce consistent spacing before blocks',

packages/eslint-plugin/src/rules/space-before-function-paren.ts

+2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ export type MessageIds = 'missing' | 'unexpected';
2020
export default createRule<Options, MessageIds>({
2121
name: 'space-before-function-paren',
2222
meta: {
23+
deprecated: true,
24+
replacedBy: ['@stylistic/space-before-function-paren'],
2325
type: 'layout',
2426
docs: {
2527
description: 'Enforce consistent spacing before function parenthesis',

packages/eslint-plugin/src/rules/space-infix-ops.ts

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ const UNIONS = ['|', '&'];
1818
export default createRule<Options, MessageIds>({
1919
name: 'space-infix-ops',
2020
meta: {
21+
deprecated: true,
22+
replacedBy: ['@stylistic/space-infix-ops'],
2123
type: 'layout',
2224
docs: {
2325
description: 'Require spacing around infix operators',

packages/eslint-plugin/src/rules/type-annotation-spacing.ts

+2
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ function getRules(
102102
export default createRule<Options, MessageIds>({
103103
name: 'type-annotation-spacing',
104104
meta: {
105+
deprecated: true,
106+
replacedBy: ['@stylistic/type-annotation-spacing'],
105107
type: 'layout',
106108
docs: {
107109
description: 'Require consistent spacing around type annotations',

packages/eslint-plugin/tests/areOptionsValid.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { areOptionsValid } from './areOptionsValid';
44
const exampleRule = createRule<['value-a' | 'value-b'], never>({
55
name: 'my-example-rule',
66
meta: {
7-
type: 'layout',
7+
type: 'suggestion',
88
docs: {
99
description: 'Detects something or other',
1010
},

packages/website/plugins/generated-rule-docs/insertions/insertFormattingNotice.ts

+25-8
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,32 @@ import type * as unist from 'unist';
33
import type { RuleDocsPage } from '../RuleDocsPage';
44

55
export function insertFormattingNotice(page: RuleDocsPage): void {
6-
if (page.rule.meta.type === 'layout') {
7-
page.spliceChildren(0, 0, {
8-
value: `
9-
<admonition type="warning">
10-
This rule will soon be moved to <a href="https://eslint.style">eslint-stylistic</a>.
6+
if (page.rule.meta.type !== 'layout') {
7+
return;
8+
}
9+
10+
const replacement = page.rule.meta.replacedBy!.find(e =>
11+
e.startsWith('@stylistic/'),
12+
);
13+
const url =
14+
replacement &&
15+
`https://eslint.style/rules/default/${replacement.replace(
16+
'@stylistic/',
17+
'',
18+
)}`;
19+
20+
page.spliceChildren(0, 0, {
21+
value: `
22+
<admonition title="Deprecated" type="warning">
23+
Formatting rules now live in <a href="https://eslint.style">eslint-stylistic</a>. ${
24+
url
25+
? ` <a href="${url}">${replacement}</a> is the replacement for this rule. `
26+
: ''
27+
}
28+
<br />
1129
See <a href="/linting/troubleshooting/formatting">What About Formatting?</a> for more information.
1230
</admonition>
1331
`,
14-
type: 'jsx',
15-
} as unist.Node);
16-
}
32+
type: 'jsx',
33+
} as unist.Node);
1734
}

0 commit comments

Comments
 (0)