Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update custom fork of indent rule to the new v5 rule #30

Merged
merged 6 commits into from Dec 17, 2018

Conversation

jimjenkins5
Copy link
Contributor

ESLint fixed some bugs in the indent rule. Since we have a custom fork to support 3 space indentation and lining up variable declarations, we needed to update the rule.

I "re-forked" the rule to update everything, then brought it up to our coding standards.

@coveralls
Copy link

Coverage Status

Coverage decreased (-7.8%) to 75.689% when pulling bccf529 on jimjenkins5:fix_indent into 4a5310c on silvermine:master.

@coveralls
Copy link

coveralls commented Dec 14, 2018

Coverage Status

Coverage decreased (-1.4%) to 82.01% when pulling d055f45 on jimjenkins5:fix_indent into 4a5310c on silvermine:master.

"prefer-template": "off",
"padding-line-between-statements": [
"error",
{ "blankLine": "any", "prev": [ "*" ], "next": "return" }
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this turning the "blank line before return" rule on? I thought we just agreed to turn that off: silvermine/eslint-config-silvermine@7645529#diff-168726dbe96b3ce427e7fedce31bb0bcL170

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is actually turning it off. I should have marked this "BlankLine": "any" means "leave a blank line or not".

For clarity, I added this and prefer-template because of the weird loop we get into with the plugin and config. We're not pushing the config version bump until this is there, but I need to update the config now to make linting on the new indent rule work.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok, thanks. I misread it. I see it now

minimum: 0,
},
'let': {
type: 'integer',
let: {
Copy link
Contributor

Choose a reason for hiding this comment

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

It's weird that our coding standards require quotes around const and var but not let. It seems like quotes around let should be required for the same reason as const and var.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah. I'm not sure why this is "fixed" this way by the ESLing rule. I can put the quotes back though.

Copy link
Contributor

Choose a reason for hiding this comment

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

I looked into why. The list of keywords that the quote-props rule uses are reserved words in ES3: https://github.com/eslint/eslint/blob/master/lib/util/keywords.js and "let" is not among them because it wasn't a reserved word in ES3.

The rule only uses ES3 reserved words because only browsers that do not support ES5 (notably IE <= 8) throw an error if you try to use a reserved word as an unquoted prop name.

I'm not certain we even need this rule anymore, unless it's just a stylistic preference 🤷‍♂️

@jimjenkins5
Copy link
Contributor Author

@yokuze back to you with the one change for quoting the let properties.

yokuze
yokuze previously approved these changes Dec 17, 2018
Copy link
Contributor

@yokuze yokuze left a comment

Choose a reason for hiding this comment

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

Looks good.

@@ -34,11 +34,67 @@ validExample = formatCode(
' var arr = [ 1, 2, 3 ],',
' noInit, andAgain;',
'',
' //This comment should be indented with the if statement',
Copy link
Member

Choose a reason for hiding this comment

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

space between //This

'',
'class MyClass {',
' /**',
' * This should be indented with the function.',
Copy link
Member

Choose a reason for hiding this comment

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

This is supposed to be a valid example, but I think it's wrong ... isn't it supposed to be like this?

class MyClass {
   /**
    * This is how it should be indented
    */
   constructor(num: number) {
      // ...
   }
}

Copy link
Member

Choose a reason for hiding this comment

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

Note that the non-first lines of the block comment are indented an extra space so that the asterisks align.

'',
'const myClass = new MyClass();',
'',
'for(let i = 1; i < 10; i++) {',
Copy link
Member

Choose a reason for hiding this comment

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

space between for(

@jthomerson
Copy link
Member

@jimjenkins5 back to you

@jimjenkins5
Copy link
Contributor Author

See all the stuff linting helps with. Unfortunately these are all linted by rules not being tested here...
Back to you @jthomerson

@jthomerson jthomerson merged commit 6aeed20 into silvermine:master Dec 17, 2018
@jimjenkins5 jimjenkins5 deleted the fix_indent branch December 28, 2018 20:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants