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

tools: some eslint rules proposals #14253

Closed
vsemozhetbyt opened this issue Jul 15, 2017 · 9 comments
Closed

tools: some eslint rules proposals #14253

vsemozhetbyt opened this issue Jul 15, 2017 · 9 comments
Labels
discuss Issues opened for discussions and feedbacks. meta Issues and PRs related to the general management of the project. tools Issues and PRs related to the tools directory.

Comments

@vsemozhetbyt
Copy link
Contributor

vsemozhetbyt commented Jul 15, 2017

Recently some big PRs with churn was mostly rejected or gave sporadic -1, so these are some preliminarily proposals to check the opinions before investing time.

  1. Rule: http://eslint.org/docs/rules/no-unused-vars

    Proposal:

    no-unused-vars: ['error', {args: 'after-used'}]
    

    Hits:

    *.md:          190 (soundly disabled in doc/.eslintrc.yaml)
    
    *.js benchmark: 33
    *.js lib:       45
    *.js test:     300
    *.js tools:      1 (will be fixed in #14251)
    

    Refs: tools: delete an unused argument #14251

  2. Rule: http://eslint.org/docs/rules/prefer-arrow-callback

    Proposal:

    `prefer-arrow-callback: ['error', {allowNamedFunctions: false, allowUnboundThis: true}]`
    

    Hits:

    *.md:            15
    
    *.js benchmark: 108
    *.js lib:       114
    *.js test:     4002 (wow...)
    *.js tools:      51
    
  3. Rule: http://eslint.org/docs/rules/prefer-destructuring

    Proposal:

    prefer-destructuring: ['error',
                           {array: true, object: true},
                           {enforceForRenamedProperties: false}]
    

    Hits:

    array: *.md:           3
    
    array: *.js benchmark: 7
    array: *.js lib:      59
    array: *.js test:    124
    array: *.js tools:     9
    
    
    object: *.md:             1
    
    object: *.js benchmark: 141
    object: *.js lib:       268
    object: *.js test:      562
    object: *.js tools:      22
    

If there is some consensus for any proposal, it can be used as a starting point for code-and-learn or similar events.

If some or all approved proposals are not appropriate for code-and-learn, I can do any or all if there are volunteers to review.

@vsemozhetbyt vsemozhetbyt added meta Issues and PRs related to the general management of the project. refactor to ES6+ tools Issues and PRs related to the tools directory. labels Jul 15, 2017
@Trott
Copy link
Member

Trott commented Jul 15, 2017

Ref: #10129

@Trott
Copy link
Member

Trott commented Jul 15, 2017

no-unused-vars: ['error', {args: 'after-used'}]

FWIW, {args: 'after-used'} is the default, so it can just be: no-unused-vars: error.

@vsemozhetbyt
Copy link
Contributor Author

@Trott Yes, I've used some defaults to be more explicit. Some rules can be shortened.

@Trott Trott added the discuss Issues opened for discussions and feedbacks. label Jul 15, 2017
@silverwind
Copy link
Contributor

silverwind commented Jul 17, 2017

+1 to no-unused-vars, but I'd suggest these options:

{args: all, argsIgnorePattern: ^_, varsIgnorePattern: ^_}

This way, one can just underscore-prefix unused variabled in function arguments or during destructuring:

doSomething((_unused, used) => {});
const [_unused, used] = doSomething();

@vsemozhetbyt
Copy link
Contributor Author

@silverwind With varsIgnorePattern we can miss some unused "internal" variables outside of destructuring, while in destructuring we can simply omit the unused variables:

const [, , file] = process.argv;

But I am OK with this decision if there are some +1.

@sebdeckers
Copy link
Contributor

Any chance of adopting StandardJS? Avoids lots of stylistic bikeshedding. Many projects use it nowadays. As one example, migration was relatively painless for NPM (npm/npm#9954). The auto-formatter has improved since then, though it may not be perfect.

@vsemozhetbyt
Copy link
Contributor Author

vsemozhetbyt commented Jul 21, 2017

@sebdeckers I doubt we will have consensus about "no semicolons" or "space after function name" :) The churn will be tremendous :)

@vsemozhetbyt
Copy link
Contributor Author

It seems this has not got enough approvement and can be closed for now. Feel free to reopen if something changes.

@refack
Copy link
Contributor

refack commented Jul 23, 2017

+1 to no-unused-vars, but I'd suggest these options:

{args: all, argsIgnorePattern: ^, varsIgnorePattern: ^}

@vsemozhetbyt I think no-unused-vars on it's own will get wider support (personally I like all with an ^_+$ ignore pattern)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discuss Issues opened for discussions and feedbacks. meta Issues and PRs related to the general management of the project. tools Issues and PRs related to the tools directory.
Projects
None yet
Development

No branches or pull requests

5 participants