Skip to content
This repository has been archived by the owner on Oct 6, 2020. It is now read-only.

Add class name rule #6

Merged
merged 8 commits into from
Aug 23, 2017
Merged

Conversation

sushain97
Copy link
Contributor

@sushain97 sushain97 commented Aug 12, 2017

We error on usage of string literal Blueprint class names in order to minimize typos and ensure compile-time correctness of class references.

@adidahiya adidahiya self-assigned this Aug 12, 2017
@adidahiya
Copy link
Contributor

@sushain97 your build status isn't reporting -- have you enabled CircleCI on your fork?

@sushain97
Copy link
Contributor Author

return ts.forEachChild(ctx.sourceFile, callback);

function callback(node: ts.Node): void {
if (node.kind === ts.SyntaxKind.StringLiteral && (node as ts.StringLiteral).text.startsWith("pt-")) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some suggestions on the string test:

  • allow the exact literal "pt-" to go through without a lint failure. it's not a valid blueprint class name and would be a false positive if we linted for it
  • check for ".pt-" as well, so we can lint things like document.querySelector(".pt-button")

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(thanks for the suggestions, those cases didn't cross my mind)

@sushain97 sushain97 force-pushed the string-class-name-rule branch from 975c276 to 723be2c Compare August 18, 2017 06:48
@adidahiya adidahiya merged commit a50728a into palantir:master Aug 23, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants