Skip to content

Commit

Permalink
feat(eslint-plugin): deprecate formatting (meta.type: layout) rules (#…
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
JoshuaKGoldberg committed Dec 24, 2023
1 parent b1c92bb commit 04dea84
Show file tree
Hide file tree
Showing 23 changed files with 66 additions and 47 deletions.
38 changes: 0 additions & 38 deletions packages/eslint-plugin/src/configs/all.ts
Expand Up @@ -14,17 +14,9 @@ export = {
'@typescript-eslint/ban-ts-comment': 'error',
'@typescript-eslint/ban-tslint-comment': 'error',
'@typescript-eslint/ban-types': 'error',
'block-spacing': 'off',
'@typescript-eslint/block-spacing': 'error',
'brace-style': 'off',
'@typescript-eslint/brace-style': 'error',
'@typescript-eslint/class-literal-property-style': 'error',
'class-methods-use-this': 'off',
'@typescript-eslint/class-methods-use-this': 'error',
'comma-dangle': 'off',
'@typescript-eslint/comma-dangle': 'error',
'comma-spacing': 'off',
'@typescript-eslint/comma-spacing': 'error',
'@typescript-eslint/consistent-generic-constructors': 'error',
'@typescript-eslint/consistent-indexed-object-style': 'error',
'@typescript-eslint/consistent-type-assertions': 'error',
Expand All @@ -38,23 +30,10 @@ export = {
'@typescript-eslint/explicit-function-return-type': 'error',
'@typescript-eslint/explicit-member-accessibility': 'error',
'@typescript-eslint/explicit-module-boundary-types': 'error',
'func-call-spacing': 'off',
'@typescript-eslint/func-call-spacing': 'error',
indent: 'off',
'@typescript-eslint/indent': 'error',
'init-declarations': 'off',
'@typescript-eslint/init-declarations': 'error',
'key-spacing': 'off',
'@typescript-eslint/key-spacing': 'error',
'keyword-spacing': 'off',
'@typescript-eslint/keyword-spacing': 'error',
'lines-around-comment': 'off',
'@typescript-eslint/lines-around-comment': 'error',
'lines-between-class-members': 'off',
'@typescript-eslint/lines-between-class-members': 'error',
'max-params': 'off',
'@typescript-eslint/max-params': 'error',
'@typescript-eslint/member-delimiter-style': 'error',
'@typescript-eslint/member-ordering': 'error',
'@typescript-eslint/method-signature-style': 'error',
'@typescript-eslint/naming-convention': 'error',
Expand All @@ -73,8 +52,6 @@ export = {
'@typescript-eslint/no-empty-interface': 'error',
'@typescript-eslint/no-explicit-any': 'error',
'@typescript-eslint/no-extra-non-null-assertion': 'error',
'no-extra-parens': 'off',
'@typescript-eslint/no-extra-parens': 'error',
'no-extra-semi': 'off',
'@typescript-eslint/no-extra-semi': 'error',
'@typescript-eslint/no-extraneous-class': 'error',
Expand Down Expand Up @@ -138,10 +115,6 @@ export = {
'@typescript-eslint/no-useless-template-literals': 'error',
'@typescript-eslint/no-var-requires': 'error',
'@typescript-eslint/non-nullable-type-assertion-style': 'error',
'object-curly-spacing': 'off',
'@typescript-eslint/object-curly-spacing': 'error',
'padding-line-between-statements': 'off',
'@typescript-eslint/padding-line-between-statements': 'error',
'@typescript-eslint/parameter-properties': 'error',
'@typescript-eslint/prefer-as-const': 'error',
'prefer-destructuring': 'off',
Expand All @@ -162,28 +135,17 @@ export = {
'@typescript-eslint/prefer-string-starts-ends-with': 'error',
'@typescript-eslint/prefer-ts-expect-error': 'error',
'@typescript-eslint/promise-function-async': 'error',
quotes: 'off',
'@typescript-eslint/quotes': 'error',
'@typescript-eslint/require-array-sort-compare': 'error',
'require-await': 'off',
'@typescript-eslint/require-await': 'error',
'@typescript-eslint/restrict-plus-operands': 'error',
'@typescript-eslint/restrict-template-expressions': 'error',
'no-return-await': 'off',
'@typescript-eslint/return-await': 'error',
semi: 'off',
'@typescript-eslint/semi': 'error',
'@typescript-eslint/sort-type-constituents': 'error',
'space-before-blocks': 'off',
'@typescript-eslint/space-before-blocks': 'error',
'space-before-function-paren': 'off',
'@typescript-eslint/space-before-function-paren': 'error',
'space-infix-ops': 'off',
'@typescript-eslint/space-infix-ops': 'error',
'@typescript-eslint/strict-boolean-expressions': 'error',
'@typescript-eslint/switch-exhaustiveness-check': 'error',
'@typescript-eslint/triple-slash-reference': 'error',
'@typescript-eslint/type-annotation-spacing': 'error',
'@typescript-eslint/typedef': 'error',
'@typescript-eslint/unbound-method': 'error',
'@typescript-eslint/unified-signatures': 'error',
Expand Down
2 changes: 2 additions & 0 deletions packages/eslint-plugin/src/rules/block-spacing.ts
Expand Up @@ -17,6 +17,8 @@ export type MessageIds = InferMessageIdsTypeFromRule<typeof baseRule>;
export default createRule<Options, MessageIds>({
name: 'block-spacing',
meta: {
deprecated: true,
replacedBy: ['@stylistic/block-spacing'],
type: 'layout',
docs: {
description:
Expand Down
2 changes: 2 additions & 0 deletions packages/eslint-plugin/src/rules/brace-style.ts
Expand Up @@ -16,6 +16,8 @@ export type MessageIds = InferMessageIdsTypeFromRule<typeof baseRule>;
export default createRule<Options, MessageIds>({
name: 'brace-style',
meta: {
deprecated: true,
replacedBy: ['@stylistic/brace-style'],
type: 'layout',
docs: {
description: 'Enforce consistent brace style for blocks',
Expand Down
2 changes: 2 additions & 0 deletions packages/eslint-plugin/src/rules/comma-dangle.ts
Expand Up @@ -46,6 +46,8 @@ function normalizeOptions(options: Option): NormalizedOptions {
export default createRule<Options, MessageIds>({
name: 'comma-dangle',
meta: {
deprecated: true,
replacedBy: ['@stylistic/comma-dangle'],
type: 'layout',
docs: {
description: 'Require or disallow trailing commas',
Expand Down
2 changes: 2 additions & 0 deletions packages/eslint-plugin/src/rules/comma-spacing.ts
Expand Up @@ -22,6 +22,8 @@ type MessageIds = 'missing' | 'unexpected';
export default createRule<Options, MessageIds>({
name: 'comma-spacing',
meta: {
deprecated: true,
replacedBy: ['@stylistic/comma-spacing'],
type: 'layout',
docs: {
description: 'Enforce consistent spacing before and after commas',
Expand Down
2 changes: 2 additions & 0 deletions packages/eslint-plugin/src/rules/func-call-spacing.ts
Expand Up @@ -23,6 +23,8 @@ export type MessageIds =
export default createRule<Options, MessageIds>({
name: 'func-call-spacing',
meta: {
deprecated: true,
replacedBy: ['@stylistic/func-call-spacing'],
type: 'layout',
docs: {
description:
Expand Down
2 changes: 2 additions & 0 deletions packages/eslint-plugin/src/rules/indent.ts
Expand Up @@ -92,6 +92,8 @@ const KNOWN_NODES = new Set([
export default createRule<Options, MessageIds>({
name: 'indent',
meta: {
deprecated: true,
replacedBy: ['@stylistic/indent'],
type: 'layout',
docs: {
description: 'Enforce consistent indentation',
Expand Down
2 changes: 2 additions & 0 deletions packages/eslint-plugin/src/rules/key-spacing.ts
Expand Up @@ -27,6 +27,8 @@ const baseSchema = Array.isArray(baseRule.meta.schema)
export default createRule<Options, MessageIds>({
name: 'key-spacing',
meta: {
deprecated: true,
replacedBy: ['@stylistic/key-spacing'],
type: 'layout',
docs: {
description:
Expand Down
2 changes: 2 additions & 0 deletions packages/eslint-plugin/src/rules/keyword-spacing.ts
Expand Up @@ -37,6 +37,8 @@ const schema = deepMerge(
export default createRule<Options, MessageIds>({
name: 'keyword-spacing',
meta: {
deprecated: true,
replacedBy: ['@stylistic/keyword-spacing'],
type: 'layout',
docs: {
description: 'Enforce consistent spacing before and after keywords',
Expand Down
2 changes: 2 additions & 0 deletions packages/eslint-plugin/src/rules/lines-around-comment.ts
Expand Up @@ -50,6 +50,8 @@ function getCommentLineNums(comments: TSESTree.Comment[]): number[] {
export default createRule<Options, MessageIds>({
name: 'lines-around-comment',
meta: {
deprecated: true,
replacedBy: ['@stylistic/lines-around-comment'],
type: 'layout',
docs: {
description: 'Require empty lines around comments',
Expand Down
Expand Up @@ -33,6 +33,8 @@ const schema = Object.values(
export default createRule<Options, MessageIds>({
name: 'lines-between-class-members',
meta: {
deprecated: true,
replacedBy: ['@stylistic/line-between-class-members'],
type: 'layout',
docs: {
description: 'Require or disallow an empty line between class members',
Expand Down
2 changes: 2 additions & 0 deletions packages/eslint-plugin/src/rules/member-delimiter-style.ts
Expand Up @@ -136,6 +136,8 @@ const BASE_SCHEMA: JSONSchema4 = {
export default createRule<Options, MessageIds>({
name: 'member-delimiter-style',
meta: {
deprecated: true,
replacedBy: ['@stylistic/member-delimiter-style'],
type: 'layout',
docs: {
description:
Expand Down
2 changes: 2 additions & 0 deletions packages/eslint-plugin/src/rules/no-extra-parens.ts
Expand Up @@ -20,6 +20,8 @@ type MessageIds = InferMessageIdsTypeFromRule<typeof baseRule>;
export default createRule<Options, MessageIds>({
name: 'no-extra-parens',
meta: {
deprecated: true,
replacedBy: ['@stylistic/no-extra-parens'],
type: 'layout',
docs: {
description: 'Disallow unnecessary parentheses',
Expand Down
2 changes: 2 additions & 0 deletions packages/eslint-plugin/src/rules/object-curly-spacing.ts
Expand Up @@ -24,10 +24,12 @@ export default createRule<Options, MessageIds>({
// 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
meta: {
...baseRule.meta,
deprecated: true,
docs: {
description: 'Enforce consistent spacing inside braces',
extendsBaseRule: true,
},
replacedBy: ['@stylistic/object-curly-spacing'],
},
defaultOptions: ['never'],
create(context) {
Expand Down
Expand Up @@ -590,6 +590,8 @@ const StatementTypes: Record<string, NodeTestObject> = {
export default createRule<Options, MessageIds>({
name: 'padding-line-between-statements',
meta: {
deprecated: true,
replacedBy: ['@stylistic/padding-line-between-statements'],
type: 'layout',
docs: {
description: 'Require or disallow padding lines between statements',
Expand Down
2 changes: 2 additions & 0 deletions packages/eslint-plugin/src/rules/quotes.ts
Expand Up @@ -16,6 +16,8 @@ export type MessageIds = InferMessageIdsTypeFromRule<typeof baseRule>;
export default createRule<Options, MessageIds>({
name: 'quotes',
meta: {
deprecated: true,
replacedBy: ['@stylistic/quotes'],
type: 'layout',
docs: {
description:
Expand Down
2 changes: 2 additions & 0 deletions packages/eslint-plugin/src/rules/semi.ts
Expand Up @@ -16,6 +16,8 @@ export type MessageIds = InferMessageIdsTypeFromRule<typeof baseRule>;
export default createRule<Options, MessageIds>({
name: 'semi',
meta: {
deprecated: true,
replacedBy: ['@stylistic/semi'],
type: 'layout',
docs: {
description: 'Require or disallow semicolons instead of ASI',
Expand Down
2 changes: 2 additions & 0 deletions packages/eslint-plugin/src/rules/space-before-blocks.ts
Expand Up @@ -16,6 +16,8 @@ export type MessageIds = InferMessageIdsTypeFromRule<typeof baseRule>;
export default createRule<Options, MessageIds>({
name: 'space-before-blocks',
meta: {
deprecated: true,
replacedBy: ['@stylistic/space-before-blocks'],
type: 'layout',
docs: {
description: 'Enforce consistent spacing before blocks',
Expand Down
Expand Up @@ -20,6 +20,8 @@ export type MessageIds = 'missing' | 'unexpected';
export default createRule<Options, MessageIds>({
name: 'space-before-function-paren',
meta: {
deprecated: true,
replacedBy: ['@stylistic/space-before-function-paren'],
type: 'layout',
docs: {
description: 'Enforce consistent spacing before function parenthesis',
Expand Down
2 changes: 2 additions & 0 deletions packages/eslint-plugin/src/rules/space-infix-ops.ts
Expand Up @@ -18,6 +18,8 @@ const UNIONS = ['|', '&'];
export default createRule<Options, MessageIds>({
name: 'space-infix-ops',
meta: {
deprecated: true,
replacedBy: ['@stylistic/space-infix-ops'],
type: 'layout',
docs: {
description: 'Require spacing around infix operators',
Expand Down
2 changes: 2 additions & 0 deletions packages/eslint-plugin/src/rules/type-annotation-spacing.ts
Expand Up @@ -102,6 +102,8 @@ function getRules(
export default createRule<Options, MessageIds>({
name: 'type-annotation-spacing',
meta: {
deprecated: true,
replacedBy: ['@stylistic/type-annotation-spacing'],
type: 'layout',
docs: {
description: 'Require consistent spacing around type annotations',
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-plugin/tests/areOptionsValid.test.ts
Expand Up @@ -4,7 +4,7 @@ import { areOptionsValid } from './areOptionsValid';
const exampleRule = createRule<['value-a' | 'value-b'], never>({
name: 'my-example-rule',
meta: {
type: 'layout',
type: 'suggestion',
docs: {
description: 'Detects something or other',
},
Expand Down
Expand Up @@ -3,15 +3,32 @@ import type * as unist from 'unist';
import type { RuleDocsPage } from '../RuleDocsPage';

export function insertFormattingNotice(page: RuleDocsPage): void {
if (page.rule.meta.type === 'layout') {
page.spliceChildren(0, 0, {
value: `
<admonition type="warning">
This rule will soon be moved to <a href="https://eslint.style">eslint-stylistic</a>.
if (page.rule.meta.type !== 'layout') {
return;
}

const replacement = page.rule.meta.replacedBy!.find(e =>
e.startsWith('@stylistic/'),
);
const url =
replacement &&
`https://eslint.style/rules/default/${replacement.replace(
'@stylistic/',
'',
)}`;

page.spliceChildren(0, 0, {
value: `
<admonition title="Deprecated" type="warning">
Formatting rules now live in <a href="https://eslint.style">eslint-stylistic</a>. ${
url
? ` <a href="${url}">${replacement}</a> is the replacement for this rule. `
: ''
}
<br />
See <a href="/linting/troubleshooting/formatting">What About Formatting?</a> for more information.
</admonition>
`,
type: 'jsx',
} as unist.Node);
}
type: 'jsx',
} as unist.Node);
}

0 comments on commit 04dea84

Please sign in to comment.