From 9647f56e1bd82933d9fd33ddef4061ad6e62dff2 Mon Sep 17 00:00:00 2001 From: Gareth Jones Date: Mon, 23 Mar 2020 17:37:38 +1300 Subject: [PATCH] chore(eslint-plugin): rename rule to `class-literal-property-style` --- packages/eslint-plugin/README.md | 2 +- ...terals-style.md => class-literal-property-style.md} | 10 +++++----- packages/eslint-plugin/src/configs/all.json | 2 +- ...terals-style.ts => class-literal-property-style.ts} | 2 +- packages/eslint-plugin/src/rules/index.ts | 4 ++-- ...le.test.ts => class-literal-property-style.test.ts} | 4 ++-- 6 files changed, 12 insertions(+), 12 deletions(-) rename packages/eslint-plugin/docs/rules/{class-literals-style.md => class-literal-property-style.md} (88%) rename packages/eslint-plugin/src/rules/{class-literals-style.ts => class-literal-property-style.ts} (98%) rename packages/eslint-plugin/tests/rules/{class-literals-style.test.ts => class-literal-property-style.test.ts} (98%) diff --git a/packages/eslint-plugin/README.md b/packages/eslint-plugin/README.md index 1cf5ed66032..fa049b2cfb2 100644 --- a/packages/eslint-plugin/README.md +++ b/packages/eslint-plugin/README.md @@ -99,7 +99,7 @@ Pro Tip: For larger codebases you may want to consider splitting our linting int | [`@typescript-eslint/await-thenable`](./docs/rules/await-thenable.md) | Disallows awaiting a value that is not a Thenable | :heavy_check_mark: | | :thought_balloon: | | [`@typescript-eslint/ban-ts-comment`](./docs/rules/ban-ts-comment.md) | Bans `// @ts-` comments from being used | | | | | [`@typescript-eslint/ban-types`](./docs/rules/ban-types.md) | Bans specific types from being used | :heavy_check_mark: | :wrench: | | -| [`@typescript-eslint/class-literals-style`](./docs/rules/class-literals-style.md) | Ensures that literals on classes are exposed in a consistent style | | :wrench: | | +| [`@typescript-eslint/class-literal-property-style`](./docs/rules/class-literal-property-style.md) | Ensures that literals on classes are exposed in a consistent style | | :wrench: | | | [`@typescript-eslint/consistent-type-assertions`](./docs/rules/consistent-type-assertions.md) | Enforces consistent usage of type assertions | :heavy_check_mark: | | | | [`@typescript-eslint/consistent-type-definitions`](./docs/rules/consistent-type-definitions.md) | Consistent with type definition either `interface` or `type` | | :wrench: | | | [`@typescript-eslint/explicit-function-return-type`](./docs/rules/explicit-function-return-type.md) | Require explicit return types on functions and class methods | :heavy_check_mark: | | | diff --git a/packages/eslint-plugin/docs/rules/class-literals-style.md b/packages/eslint-plugin/docs/rules/class-literal-property-style.md similarity index 88% rename from packages/eslint-plugin/docs/rules/class-literals-style.md rename to packages/eslint-plugin/docs/rules/class-literal-property-style.md index 921de8eb135..903a695dd76 100644 --- a/packages/eslint-plugin/docs/rules/class-literals-style.md +++ b/packages/eslint-plugin/docs/rules/class-literal-property-style.md @@ -1,4 +1,4 @@ -# Ensures that literals on classes are exposed in a consistent style (`class-literals-style`) +# Ensures that literals on classes are exposed in a consistent style (`class-literal-property-style`) When writing TypeScript applications, it's typically safe to store literal values on classes using fields with the `readonly` modifier to prevent them from being reassigned. When writing TypeScript libraries that could be used by Javascript users however, it's typically safer to expose these literals using `getter`s, since the `readonly` modifier is enforced at compile type. @@ -18,7 +18,7 @@ This style checks for any getter methods that return literal values, and require Examples of **correct** code with the `fields` style: ```ts -/* eslint @typescript-eslint/class-literals-style: ["error", "fields"] */ +/* eslint @typescript-eslint/class-literal-property-style: ["error", "fields"] */ class Mx { public readonly myField1 = 1; @@ -37,7 +37,7 @@ class Mx { Examples of **incorrect** code with the `fields` style: ```ts -/* eslint @typescript-eslint/class-literals-style: ["error", "fields"] */ +/* eslint @typescript-eslint/class-literal-property-style: ["error", "fields"] */ class Mx { public static get myField1() { @@ -59,7 +59,7 @@ as it will identify fields that can be `readonly`, and thus should be made into Examples of **correct** code with the `getters` style: ```ts -/* eslint @typescript-eslint/class-literals-style: ["error", "getters"] */ +/* eslint @typescript-eslint/class-literal-property-style: ["error", "getters"] */ class Mx { // no readonly modifier @@ -81,7 +81,7 @@ class Mx { Examples of **incorrect** code with the `getters` style: ```ts -/* eslint @typescript-eslint/class-literals-style: ["error", "getters"] */ +/* eslint @typescript-eslint/class-literal-property-style: ["error", "getters"] */ class Mx { readonly myField1 = 1; diff --git a/packages/eslint-plugin/src/configs/all.json b/packages/eslint-plugin/src/configs/all.json index 903e1b946ef..c5575d4970d 100644 --- a/packages/eslint-plugin/src/configs/all.json +++ b/packages/eslint-plugin/src/configs/all.json @@ -8,7 +8,7 @@ "@typescript-eslint/ban-types": "error", "brace-style": "off", "@typescript-eslint/brace-style": "error", - "@typescript-eslint/class-literals-style": "error", + "@typescript-eslint/class-literal-property-style": "error", "comma-spacing": "off", "@typescript-eslint/comma-spacing": "error", "@typescript-eslint/consistent-type-assertions": "error", diff --git a/packages/eslint-plugin/src/rules/class-literals-style.ts b/packages/eslint-plugin/src/rules/class-literal-property-style.ts similarity index 98% rename from packages/eslint-plugin/src/rules/class-literals-style.ts rename to packages/eslint-plugin/src/rules/class-literal-property-style.ts index 4b506e36443..a4500cdfdbf 100644 --- a/packages/eslint-plugin/src/rules/class-literals-style.ts +++ b/packages/eslint-plugin/src/rules/class-literal-property-style.ts @@ -41,7 +41,7 @@ const isSupportedLiteral = ( }; export default util.createRule({ - name: 'class-literals-style', + name: 'class-literal-property-style', meta: { type: 'problem', docs: { diff --git a/packages/eslint-plugin/src/rules/index.ts b/packages/eslint-plugin/src/rules/index.ts index 0e120d419e4..29db58b681a 100644 --- a/packages/eslint-plugin/src/rules/index.ts +++ b/packages/eslint-plugin/src/rules/index.ts @@ -7,7 +7,7 @@ import banTypes from './ban-types'; import braceStyle from './brace-style'; import camelcase from './camelcase'; import classNameCasing from './class-name-casing'; -import classLiteralsStyle from './class-literals-style'; +import classLiteralPropertyStyle from './class-literal-property-style'; import commaSpacing from './comma-spacing'; import consistentTypeAssertions from './consistent-type-assertions'; import consistentTypeDefinitions from './consistent-type-definitions'; @@ -103,7 +103,7 @@ export default { 'brace-style': braceStyle, camelcase: camelcase, 'class-name-casing': classNameCasing, - 'class-literals-style': classLiteralsStyle, + 'class-literal-property-style': classLiteralPropertyStyle, 'comma-spacing': commaSpacing, 'consistent-type-assertions': consistentTypeAssertions, 'consistent-type-definitions': consistentTypeDefinitions, diff --git a/packages/eslint-plugin/tests/rules/class-literals-style.test.ts b/packages/eslint-plugin/tests/rules/class-literal-property-style.test.ts similarity index 98% rename from packages/eslint-plugin/tests/rules/class-literals-style.test.ts rename to packages/eslint-plugin/tests/rules/class-literal-property-style.test.ts index f4c47bf4f43..f0c5f2afc05 100644 --- a/packages/eslint-plugin/tests/rules/class-literals-style.test.ts +++ b/packages/eslint-plugin/tests/rules/class-literal-property-style.test.ts @@ -1,11 +1,11 @@ -import rule from '../../src/rules/class-literals-style'; +import rule from '../../src/rules/class-literal-property-style'; import { RuleTester } from '../RuleTester'; const ruleTester = new RuleTester({ parser: '@typescript-eslint/parser', }); -ruleTester.run('class-literals-style', rule, { +ruleTester.run('class-literal-property-style', rule, { valid: [ 'class Mx { declare readonly p1 = 1; }', 'class Mx { readonly p1 = "hello world"; }',