From 15973d5e6547dfc33a5cad1651eaf574fee682a3 Mon Sep 17 00:00:00 2001 From: Joshua Goldberg Date: Tue, 31 Jul 2018 21:58:56 -0700 Subject: [PATCH] Option name; test casing --- src/rules/variableNameRule.ts | 6 +++--- test/rules/variable-name/const-only-for-caps/test.ts.lint | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/rules/variableNameRule.ts b/src/rules/variableNameRule.ts index 61c00f98613..fae269ffbf8 100644 --- a/src/rules/variableNameRule.ts +++ b/src/rules/variableNameRule.ts @@ -41,7 +41,7 @@ const OPTION_LEADING_UNDERSCORE = "allow-leading-underscore"; const OPTION_TRAILING_UNDERSCORE = "allow-trailing-underscore"; const OPTION_BAN_KEYWORDS = "ban-keywords"; const OPTION_CHECK_FORMAT = "check-format"; -const OPTION_CONST_ONLY_FOR_CAPS = "const-only-for-caps"; +const OPTION_ALL_CAPS_FOR_CONST = "const-only-for-caps"; const OPTION_ALLOW_PASCAL_CASE = "allow-pascal-case"; const OPTION_ALLOW_SNAKE_CASE = "allow-snake-case"; @@ -55,7 +55,7 @@ export class Rule extends Lint.Rules.AbstractRule { * \`"${OPTION_CHECK_FORMAT}"\`: allows only lowerCamelCased or UPPER_CASED variable names * \`"${OPTION_LEADING_UNDERSCORE}"\` allows underscores at the beginning (only has an effect if "check-format" specified) * \`"${OPTION_TRAILING_UNDERSCORE}"\` allows underscores at the end. (only has an effect if "check-format" specified) - * \`"${OPTION_CONST_ONLY_FOR_CAPS}"\`: enforces that all variables with UPPER_CASED names should be \`const\`. + * \`"${OPTION_ALL_CAPS_FOR_CONST}"\`: enforces that all variables with UPPER_CASED names should be \`const\`. * \`"${OPTION_ALLOW_PASCAL_CASE}"\` allows PascalCase in addition to lowerCamelCase. * \`"${OPTION_ALLOW_SNAKE_CASE}"\` allows snake_case in addition to lowerCamelCase. * \`"${OPTION_BAN_KEYWORDS}"\`: disallows the use of certain TypeScript keywords as variable or parameter names. @@ -107,7 +107,7 @@ function parseOptions(ruleArguments: string[]): Options { checkFormat: !banKeywords || hasOption(OPTION_CHECK_FORMAT), leadingUnderscore: hasOption(OPTION_LEADING_UNDERSCORE), trailingUnderscore: hasOption(OPTION_TRAILING_UNDERSCORE), - allCapsForConst: hasOption(OPTION_CONST_ONLY_FOR_CAPS), + allCapsForConst: hasOption(OPTION_ALL_CAPS_FOR_CONST), allowPascalCase: hasOption(OPTION_ALLOW_PASCAL_CASE), allowSnakeCase: hasOption(OPTION_ALLOW_SNAKE_CASE) }; diff --git a/test/rules/variable-name/const-only-for-caps/test.ts.lint b/test/rules/variable-name/const-only-for-caps/test.ts.lint index e67ae1295e1..8a092a64932 100644 --- a/test/rules/variable-name/const-only-for-caps/test.ts.lint +++ b/test/rules/variable-name/const-only-for-caps/test.ts.lint @@ -7,7 +7,7 @@ var PascalCaseVar; ~~~~~~~~~~~~~ [regular-case] var UPPER_CASE_VAR; - ~~~~~~~~~~~~~~ [err] + ~~~~~~~~~~~~~~ [const] let snake_case_let; ~~~~~~~~~~~~~~ [regular-case] @@ -18,7 +18,7 @@ let PascalCaseLet; ~~~~~~~~~~~~~ [regular-case] let UPPER_CASE_LET; - ~~~~~~~~~~~~~~ [err] + ~~~~~~~~~~~~~~ [const] const snake_case_const; ~~~~~~~~~~~~~~~~ [regular-case] @@ -34,5 +34,5 @@ class Test { public static readonly MY_FIELD = 10; } +[const]: Only `const` variables may be UPPER_CASE. [regular-case]: variable name must be in lowerCamelCase or UPPER_CASE -[err]: Only `const` variables may be UPPER_CASE.