facebook / flow

Adds static typing to JavaScript to improve developer productivity and code quality.
https://flow.org/
MIT License
22.07k stars 1.85k forks source link

Feature: Turn off lint feature "const_params" with inline comments just like other linter rules #5868

Open lll000111 opened 6 years ago

lll000111 commented 6 years ago

https://flow.org/en/docs/config/options/#toc-experimental-const-params-boolean

I can turn off lint rules using comments: https://flow.org/en/docs/linting/#toc-configuring-lints-with-comments

I cannot do that for const_params it seems. This should be a linter rule and not a global setting "on/off".

TrySound commented 6 years ago

@lll000111 Currently this is also a feature of strict mode instead of lint rule.

lll000111 commented 6 years ago

@TrySound As I wrote: "This should be a linter rule". So that I can turn it off where needed.

timruffles commented 5 years ago

@TrySound this means you can't seem to write functions like Lodash's _.once in strict? You'd want to drop the reference to the argument to free it up for GC:

function once(fn) {
  let called = false
  return function(...args) {
    if (!called) {
      called = true
      fn(...args)
      fn = undefined
    }
  }
}