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.
Sounds good to me!
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?
@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.
Add --fix option (uses eslint's --fix)
Here's a PR to add support for --fix: #112