Skip to content
This repository has been archived by the owner on Mar 25, 2021. It is now read-only.

Commit

Permalink
Option name; test casing
Browse files Browse the repository at this point in the history
  • Loading branch information
Joshua Goldberg committed Aug 1, 2018
1 parent e5c7b1e commit 15973d5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/rules/variableNameRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand All @@ -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.
Expand Down Expand Up @@ -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)
};
Expand Down
6 changes: 3 additions & 3 deletions test/rules/variable-name/const-only-for-caps/test.ts.lint
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ var PascalCaseVar;
~~~~~~~~~~~~~ [regular-case]

var UPPER_CASE_VAR;
~~~~~~~~~~~~~~ [err]
~~~~~~~~~~~~~~ [const]

let snake_case_let;
~~~~~~~~~~~~~~ [regular-case]
Expand All @@ -18,7 +18,7 @@ let PascalCaseLet;
~~~~~~~~~~~~~ [regular-case]

let UPPER_CASE_LET;
~~~~~~~~~~~~~~ [err]
~~~~~~~~~~~~~~ [const]

const snake_case_const;
~~~~~~~~~~~~~~~~ [regular-case]
Expand All @@ -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.

0 comments on commit 15973d5

Please sign in to comment.