aladdin-add / eslint-plugin

autofix some errors reported by eslint rules.
106 stars 10 forks source link

let is still replaced by const when it should not be #53

Closed chrishiestand closed 5 years ago

chrishiestand commented 5 years ago

Just tried the plugin and can't get it working. Here's my .eslintrc.yml:

extends:
- react-app
- airbnb
- prettier

plugins:
- prettier
- no-autofix

env:
  es6: true
  node: true

parserOptions:
  ecmaVersion: 2017
  sourceType: module

rules:
  strict:
  - "error"
  - "global"
  no-unused-vars:
  - error
  - argsIgnorePattern: "^_"
    varsIgnorePattern: "^_"
  react/jsx-filename-extension:
  - error,
  - extensions:
    - .js
    - .jsx
  react/jsx-one-expression-per-line:
  - error,
  - allow: "single-child"
  prettier/prettier:
    - error
    -
      trailingComma: all
      bracketSpacing: false
  no-autofix/prefer-const: error

When I type

let a = "foo";

it is "fixed" to:

const a = "foo";

I expect to still have let but with a linter error.

aladdin-add commented 5 years ago

seems it was fixed by the bulitin rule, you can disable it:

prefer-const: 0
chrishiestand commented 5 years ago

Strange, that is not the behavior I expected from the README. I thought that this plugin disabled the builtin fix behavior, but instead it is meant to replace the builtin? Should the README be updated to reflect this? Or is there something particular to my environment?

And to be clear: your suggestion worked, thanks!

aladdin-add commented 5 years ago

agreed, seems the docs is a bit misleading, I'll update it later.

thanks for the feedback! :)