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
Checked for binding patterns in variableNameRule
Josh Goldberg committed Dec 18, 2017
commit 103aa5271e31a774be207c34ee36e7473abad950
6 changes: 3 additions & 3 deletions src/rules/variableNameRule.ts
Original file line number Diff line number Diff line change
@@ -179,12 +179,12 @@ function walk(ctx: Lint.WalkContext<Options>): void {
function handleVariableDeclaration(node: ts.VariableDeclaration): void {
handleDeclaredVariable(node);

if (!ctx.options.allCapsForConst) {
if (!ctx.options.allCapsForConst || utils.isBindingPattern(node.name)) {
return;
}

const declarationList = node.parent as ts.VariableDeclarationList;
const text = node.name.getText();
const declarationList = node.parent!;
const text = node.name.text;

if (isUpperCase(text) && !utils.isNodeFlagSet(declarationList, ts.NodeFlags.Const)) {
ctx.addFailureAtNode(node, Rule.FAILURE_STRING_CONST);