Skip to content
This repository has been archived by the owner on Mar 23, 2024. It is now read-only.

Preset: Idiomatic #1069

Closed
wants to merge 1 commit into from
Closed

Preset: Idiomatic #1069

wants to merge 1 commit into from

Conversation

hzoo
Copy link
Member

@hzoo hzoo commented Feb 16, 2015

#1065. WIP

Idiomatic JSCS
indentation no preference but be consistent!
quotes? use jquery preset: "validateQuoteMarks": { "mark": "\"", "escape": true },
foo("bar") new rule option: requireSpacesInsideParentheses: Single argument string literal, no space
if ( !("foo" in obj) ) { new rule option: requireSpacesInsideParentheses: Inner grouping parens, no space
foo([ "alpha", "beta" ]); "requireSpacesInsideParentheses": { "except": [ "[", "]" ] }
(function( global ) {})() "requireSpacesInsideParentheses": { "except": ["function"] }
foo({ a: "alpha" }); "requireSpacesInsideParentheses": { "except": [ "{", "}" ] }
square( 10 ); "disallowSpacesInCallExpression": true
// statements "requireSpaceAfterLineComment": { "allExcept": ["#", "="] }
"disallowMultipleLineBreaks": null
var, const, let statements should always be in the beginning of their respective scope #99 new rule requireVarDeclFirst
name of regex: rDesc new rule?
End of line comments are prohibited! new rule validateCommentPosition
var factorial = function factorial( number ) { similar to #850
avoid switch if possible disallowNodeTypes: ["SwitchStatement"]
early returns new rule #1223 requireEarlyReturn

@hzoo hzoo force-pushed the add-idiomatic-preset branch from f7eabe3 to b3544b2 Compare February 16, 2015 01:00
@coveralls
Copy link

Coverage Status

Coverage increased (+0.0%) to 98.82% when pulling b3544b2 on hzoo:add-idiomatic-preset into d567f91 on jscs-dev:master.

@mdevils
Copy link
Member

mdevils commented Feb 17, 2015

"preset": "jquery",
"requireSpacesInsideParentheses": {
"all": true,
"except": [ "{", "}" ]
Copy link
Member

Choose a reason for hiding this comment

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

Correct one is:

"except": [ "{", "}", "[", "]", "function" ]

And as a said feature, requireSpacesInsideParentheses should understand quotes, so case like this:

foo("bar")

would be acceptable.

@markelog
Copy link
Member

@rwaldron you might like this :-)

@hzoo hzoo force-pushed the add-idiomatic-preset branch 2 times, most recently from d4a7f0b to b018dee Compare February 17, 2015 21:40
@coveralls
Copy link

Coverage Status

Coverage increased (+0.0%) to 98.88% when pulling b018dee on hzoo:add-idiomatic-preset into 9a99950 on jscs-dev:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.0%) to 98.88% when pulling b018dee on hzoo:add-idiomatic-preset into 9a99950 on jscs-dev:master.

@hzoo hzoo force-pushed the add-idiomatic-preset branch from b018dee to 437f9b6 Compare March 9, 2015 22:59
@hzoo
Copy link
Member Author

hzoo commented Mar 9, 2015

Oh failing because of requirePaddingNewLinesBeforeLineComments in jQuery

@hzoo hzoo force-pushed the add-idiomatic-preset branch 2 times, most recently from 5c41f20 to 061ce97 Compare March 10, 2015 00:01
@markelog
Copy link
Member

We can't land this, until #1069 (comment) is all done, specifically until

foo("bar")

case is handled, would like to take a hit on this one? #836

@hzoo
Copy link
Member Author

hzoo commented Mar 10, 2015

Yeah I was just updating the PRs since I forgot to update 2 files

@hzoo
Copy link
Member Author

hzoo commented Mar 10, 2015

Yeah I'l take a look

@mrjoelkemp
Copy link
Member

What's the status on this PR? Still held up?

@hzoo
Copy link
Member Author

hzoo commented Mar 17, 2015

Yeah on #836. Need an exception for foo("bar") - requireSpacesInsideParentheses but except string literals so I guess for

", ', `

markelog added a commit to markelog/node-jscs that referenced this pull request Sep 11, 2015
markelog added a commit to markelog/node-jscs that referenced this pull request Sep 11, 2015
markelog added a commit to markelog/node-jscs that referenced this pull request Sep 11, 2015
@hzoo
Copy link
Member Author

hzoo commented Sep 11, 2015

Ok I can add requireVarDeclFirst.

JSDoc style is good, but requires a significant time investment - don't think we need to make a rule to prevent jsdoc style unless the rule would be disallowBlockComments.

End of line comments are prohibited!

That would be #651 - validateCommentPosition: { position: "above" }

@hzoo
Copy link
Member Author

hzoo commented Sep 11, 2015

Getting an error with requireVarDeclFirst on

// Good
function foo() {
  let foo;
  if ( condition ) {
    let bar = "";

  }
}

@markelog
Copy link
Member

JSDoc style is good, but requires a significant time investment - don't think we need to make a rule to prevent jsdoc style unless the rule would be disallowBlockComments.

I was thinking we should include jsdoc rules

Getting an error with requireVarDeclFirst on

#1783

@hzoo
Copy link
Member Author

hzoo commented Sep 14, 2015

Ok updating with

   "requireSpacesInsideParentheses": {
        "all": true,
        "ignoreParenthesizedExpression": true,
        "except": [ "\"" ]
    },

@hzoo hzoo force-pushed the add-idiomatic-preset branch from ce6a71a to 5892786 Compare September 14, 2015 02:04
@markelog
Copy link
Member

What about disallowSpacesInsideParenthesizedExpression: true and validateCommentPosition?

@hzoo
Copy link
Member Author

hzoo commented Sep 14, 2015

Getting

Illegal space after opening grouping parenthesis at 1.js :
   208 |
   209 |  Ctor.prototype.setFoo = function( val ) {
   210 |    return ( this.foo = val );
--------------------^
   211 |  };
   212 |

Illegal space before closing grouping parenthesis at 1.js :
   208 |
   209 |  Ctor.prototype.setFoo = function( val ) {
   210 |    return ( this.foo = val );
-----------------------------------^
   211 |  };
   212 |

for disallowSpacesInsideParenthesizedExpression - adding validatecomment

@hzoo hzoo force-pushed the add-idiomatic-preset branch from 5892786 to 7238289 Compare September 14, 2015 02:14
@markelog
Copy link
Member

:-(

@ghost ghost mentioned this pull request Sep 14, 2015
@markelog markelog removed the WIP label Sep 14, 2015
@markelog
Copy link
Member

It seems we all good here?

@hzoo
Copy link
Member Author

hzoo commented Sep 14, 2015

Yeah only requireVarDeclFirst is left? (and we have an issue for that already)

@hzoo
Copy link
Member Author

hzoo commented Sep 14, 2015

It was kind of annoying to depend on a preset (jquery) though - since if you update the jquery preset, then the tests will fail (validateIdentation errors in that case) so I just removed that?

@markelog
Copy link
Member

since if you update the jquery preset, then the tests will fail (validateIdentation errors in that case) so I just removed that?

Do what you think is right :-).

@markelog
Copy link
Member

How we doing here?

@hzoo
Copy link
Member Author

hzoo commented Sep 16, 2015

Can merge - there's only some rules we haven't implemented yet.

@markelog
Copy link
Member

I guess we did catch the spirit of this preset, we can take care the details afterwards

@hzoo
Copy link
Member Author

hzoo commented Sep 19, 2015

So 👍 for this?

@markelog
Copy link
Member

LGTM

@hzoo hzoo closed this in ae8c571 Sep 21, 2015
@hzoo
Copy link
Member Author

hzoo commented Sep 21, 2015

Ok finally merged - my longest lasting PR! 🎉

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants