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

Added require-const-for-all-caps option to variable-name #2936

Merged
merged 20 commits into from
Mar 12, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Merge branch 'master'
Josh Goldberg committed Nov 6, 2018
commit be9b08e49f4c1626889f2ee77595423a0422bce8
9 changes: 2 additions & 7 deletions src/configs/all.ts
Original file line number Diff line number Diff line change
@@ -251,13 +251,8 @@ export const rules = {
"space-within-parens": [true, 0],
"switch-final-break": true,
"type-literal-delimiter": true,
"variable-name": [
true,
"ban-keywords",
"check-format",
"const-only-for-caps",
],
"whitespace": [
"variable-name": [true, "ban-keywords", "check-format", "const-only-for-caps"],
whitespace: [
true,
"check-branch",
"check-decl",
14 changes: 7 additions & 7 deletions src/rules/variableNameRule.ts
Original file line number Diff line number Diff line change
@@ -32,7 +32,7 @@ const BANNED_KEYWORDS = [
"Boolean",
"boolean",
"Undefined",
"undefined"
"undefined",
];
const bannedKeywordsSet = new Set(BANNED_KEYWORDS);
const bannedKeywordsStr = BANNED_KEYWORDS.map(kw => `\`${kw}\``).join(", ");
@@ -70,15 +70,15 @@ export class Rule extends Lint.Rules.AbstractRule {
OPTION_TRAILING_UNDERSCORE,
OPTION_ALLOW_PASCAL_CASE,
OPTION_ALLOW_SNAKE_CASE,
OPTION_BAN_KEYWORDS
]
OPTION_BAN_KEYWORDS,
],
},
minLength: 0,
maxLength: 6
maxLength: 6,
},
optionExamples: [[true, "ban-keywords", "check-format", "allow-leading-underscore"]],
type: "style",
typescriptOnly: false
typescriptOnly: false,
};

public static KEYWORD_FAILURE = "variable name clashes with keyword/type";
@@ -109,7 +109,7 @@ function parseOptions(ruleArguments: string[]): Options {
trailingUnderscore: hasOption(OPTION_TRAILING_UNDERSCORE),
allCapsForConst: hasOption(OPTION_ALL_CAPS_FOR_CONST),
allowPascalCase: hasOption(OPTION_ALLOW_PASCAL_CASE),
allowSnakeCase: hasOption(OPTION_ALLOW_SNAKE_CASE)
allowSnakeCase: hasOption(OPTION_ALLOW_SNAKE_CASE),
};

function hasOption(name: string): boolean {
@@ -157,7 +157,7 @@ function walk(ctx: Lint.WalkContext<Options>): void {
});

function handleDeclaredVariable(
node: ts.ParameterDeclaration | ts.PropertyDeclaration | ts.VariableDeclaration
node: ts.ParameterDeclaration | ts.PropertyDeclaration | ts.VariableDeclaration,
): void {
const { name, initializer } = node;

You are viewing a condensed version of this merge commit. You can view the full changes here.