add option/flag to invoke eslint's --fix feature #107

Closed
Flet opened this Issue May 16, 2016 · 4 comments

Projects

None yet

3 participants

@Flet
Owner
Flet commented May 16, 2016 edited

Passing through a --fix flag/option to eslint might be a nice, lightweight alternative to using a full formatter like standard-format without adding any additional dependencies,

Looking at standard, about 25% of the rules are covered by --fix currently:

arrow-spacing: enforce consistent spacing before and after the arrow in arrow functions 
block-spacing: enforce consistent spacing inside single-line blocks 
comma-dangle: require or disallow trailing commas  
comma-spacing: enforce consistent spacing before and after commas 
eol-last: enforce at least one newline at the end of files 
generator-star-spacing: enforce consistent spacing around * operators in generator functions 
indent: enforce consistent indentation 
jsx-quotes: enforce the consistent use of either double or single quotes in JSX attributes 
keyword-spacing: enforce consistent spacing before and after keywords 
no-multi-spaces: disallow multiple spaces 
no-spaced-func: disallow spacing between function identifiers and their applications 
no-trailing-spaces: disallow trailing whitespace at the end of lines 
no-whitespace-before-property: disallow whitespace before properties 
quotes: enforce the consistent use of either backticks, double, or single quotes 
semi-spacing: enforce consistent spacing before and after semicolons 
semi: require or disallow semicolons instead of ASI 
space-before-blocks: enforce consistent spacing before blocks 
space-before-function-paren: enforce consistent spacing before function definition opening parenthesis 
space-in-parens: enforce consistent spacing inside parentheses 
space-infix-ops: require spacing around operators 
space-unary-ops: enforce consistent spacing before or after unary operators 
spaced-comment: enforce consistent spacing after the // or /* in a comment 
template-curly-spacing: require or disallow spacing around embedded expressions of template strings 
yield-star-spacing: require or disallow spacing around the * in yield* expressions

This is a lot more rules than last time I checked!

I'd like to see standard-engine expose a --fix flag via the CLI as well as opts.fix for programmatic usage.

Thoughts?

@feross
Collaborator
feross commented May 16, 2016

Sounds good to me!

@Flet Flet referenced this issue in feross/standard Jun 3, 2016
Closed

Bring --format back #540

@2color
2color commented Jun 20, 2016 edited

I'd love to see this!

@Flet I'd like to help out implementing this.
A quick glimpse revealed that the current implementation relies on opts.formatter to have transform function. What implementation did you have in mind?

@Flet
Owner
Flet commented Jun 21, 2016

@2color Sure, go for it :)

It should be just adding fix: true to the eslintConfig in parseOpts if opts.fix is passed in.
We should also update cmd.js to allow it to be passed via CLI.

@feross feross added a commit that referenced this issue Jul 12, 2016
@feross feross Add --fix option (uses eslint's --fix)
Fixes #107
6d2e0c1
@feross
Collaborator
feross commented Jul 12, 2016

Here's a PR to add support for --fix: #112

@feross feross closed this Jul 12, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment