This repository has been archived by the owner on Mar 25, 2021. It is now read-only.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
nchen63
suggested changes
May 14, 2017
src/configs/all.ts
Outdated
true, | ||
"double", | ||
"avoid-escape", | ||
"no-template", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rename to avoid-template
since some templates are allowed
src/rules/quotemarkRule.ts
Outdated
@@ -44,6 +47,7 @@ export class Rule extends Lint.Rules.AbstractRule { | |||
* \`"${OPTION_DOUBLE}"\` enforces double quotes. | |||
* \`"${OPTION_JSX_SINGLE}"\` enforces single quotes for JSX attributes. | |||
* \`"${OPTION_JSX_DOUBLE}"\` enforces double quotes for JSX attributes. | |||
* \`"${OPTION_NO_TEMPLATE}"\` forbids single-line template strings that do not contain string interpolations. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also "untagged"
ajafff
suggested changes
May 14, 2017
src/rules/quotemarkRule.ts
Outdated
}); | ||
} | ||
|
||
function isMultiLine(node: ts.Node, sourceFile: ts.SourceFile): boolean { | ||
return sourceFile.getLineAndCharacterOfPosition(node.getStart(sourceFile)).line !== |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can avoid that boilerplate code by using tsutils.isSameLine
return !isSameLine(sourceFile, node.getStart(sourceFile), node.end);
src/rules/quotemarkRule.ts
Outdated
const { sourceFile, options } = ctx; | ||
ts.forEachChild(sourceFile, function cb(node) { | ||
if (isStringLiteral(node) | ||
|| isNoSubstitutionTemplateLiteral(node) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
needs to check if the option is set
nchen63
approved these changes
May 14, 2017
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PR checklist
Overview of change:
Adds the
no-template
option, which forbids single-line template literals with no interpolation.Still allows tagged tempates and templates with interpolation.
Allows them if they contain both
"
and'
, otherwise corrects to some kind of quote.CHANGELOG.md entry:
[new-rule-option]
quotemark
: Addavoid-template
option