eslint-plugin-change-detection-strategy
Advanced tools
Comparing version 0.1.3 to 0.1.4
11
index.js
@@ -18,2 +18,6 @@ /** | ||
const CHANGE_DETECTION_STRATEGY_ON_PUSH = CHANGE_DETECTION_STRATEGY + '.' + ON_PUSH; | ||
const SELECTOR_KEY = 'selector'; | ||
const SINGLE_SPACE = ' '; | ||
const FALLBACK_INDENT = 2; | ||
const NEWLINE = '\n'; | ||
@@ -54,2 +58,4 @@ const rules = { | ||
} else { | ||
const selectorToken = tokens.find((t) => t.value === SELECTOR_KEY); | ||
const indent = selectorToken ? selectorToken.loc.start.column : FALLBACK_INDENT; | ||
// We don't need two punctuator tokens `})` | ||
@@ -59,5 +65,4 @@ const lastPropertyPunctuatorToken = tokens[tokens.length - 2]; | ||
const hasComma = lastPropertyPunctuatorToken.value === COMMA; | ||
// Insert code block as multiline string | ||
return fixer.insertTextAfter(lastPropertyPunctuatorToken, `${hasComma ? EMPTY : COMMA} | ||
${CHANGE_DETECTION_KEY}: ${CHANGE_DETECTION_STRATEGY_ON_PUSH}`); | ||
// Insert code block as multiline string with indent | ||
return fixer.insertTextAfter(lastPropertyPunctuatorToken, `${hasComma ? EMPTY : COMMA}${NEWLINE}${SINGLE_SPACE.repeat(indent)}${CHANGE_DETECTION_KEY}: ${CHANGE_DETECTION_STRATEGY_ON_PUSH}`); | ||
} | ||
@@ -64,0 +69,0 @@ } |
{ | ||
"name": "eslint-plugin-change-detection-strategy", | ||
"description": "eslint plugin to check Angular ChangeDetectionStrategy", | ||
"version": "0.1.3", | ||
"version": "0.1.4", | ||
"main": "index.js", | ||
@@ -6,0 +6,0 @@ "scripts": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7654
71