gaearon / react-proxy

Proxies React components without unmounting or losing their state
459 stars 50 forks source link

Do you want to use ESLint? #75

Open btmills opened 7 years ago

btmills commented 7 years ago

I cloned the repository because I've been meaning to see what's going with class instance properties. (Foolish? Maybe 😐 But in the worst case, I learn something about React internals, Babel plugins, or hot reloading :neckbeard: I call that a win πŸ₯‡ ) However, when I opened Atom, it wasn't happy about ESLint not being installed. Since it's a weekend and I'm free to yak shave, I'd like to fix that.

I'm opening this issue to ask what approach the maintainers prefer. I can do any combination of the following, ordered according to increasing magnitude of change:

  1. Delete the .eslintrc file. All done, problem solved.

  2. Add eslint@^0.24.1 and babel-eslint@^4.1.8 to devDependencies.

    Based on the contents of the .eslintrc, I can tell that it was originally used with a v0.x release of ESLint because it overrides some rules that were enabled by default in the v0.x releases - when we shipped v1.0, we disabled all rules by default.

    https://github.com/gaearon/react-proxy/pull/54 already addressed the editor complaints in the 1.x branch by adding the missing devDependencies, but it installed ESLint v2, which means quotes is now the only rule enabled in the 1.x branch in this repository.

  3. Fix 15 existing lint errors in `src/`. ```sh $ node_modules/.bin/eslint src src/createClassProxy.js 74:8 error Missing semicolon semi 81:21 error The Function constructor is eval no-new-func 119:8 error existingProxy is already declared in the upper scope no-shadow 121:6 error Expected no return value consistent-return 138:4 error The '__proto__' property is deprecated no-proto 138:31 error The '__proto__' property is deprecated no-proto 226:3 error Unnecessary semicolon no-extra-semi 265:9 error The '__proto__' property is deprecated no-proto src/createPrototypeProxy.js 111:4 error Expected no return value consistent-return 174:4 error The '__proto__' property is deprecated no-proto 190:1 error Unnecessary semicolon no-extra-semi src/deleteUnknownAutoBindMethods.js 50:4 error Expected no return value consistent-return 53:4 error Expected no return value consistent-return src/supportsProtoAssignment.js 4:2 error The '__proto__' property is deprecated no-proto 9:1 error Unnecessary semicolon no-extra-semi βœ– 15 problems (15 errors, 0 warnings) ```
  4. In `tests/`, enable the `mocha` environment, disable `no-unused-vars`, and fix 19 remaining errors. ```sh test/consistency.js 299:6 error Missing semicolon semi test/helpers/createShallowRenderer.js 12:38 error Strings must use singlequote quotes 13:35 error Strings must use singlequote quotes 14:31 error Strings must use singlequote quotes 15:34 error Strings must use singlequote quotes 16:27 error Strings must use singlequote quotes 17:41 error Strings must use singlequote quotes 18:21 error Strings must use singlequote quotes 25:3 error "options" is not defined no-undef 119:42 error Missing semicolon semi test/instance-method-autobinding.js 228:4 error Missing semicolon semi test/instance-method.js 148:1 error Unnecessary semicolon no-extra-semi test/legacy-support.js 2:54 error Missing semicolon semi test/pure-component.js 25:3 error Missing semicolon semi test/static-descriptor.js 98:17 error Unexpected trailing comma comma-dangle 102:17 error Unexpected trailing comma comma-dangle test/static-method.js 10:5 error Unnecessary semicolon no-extra-semi 22:5 error Unnecessary semicolon no-extra-semi 114:27 error Unexpected trailing comma comma-dangle βœ– 19 problems (19 errors, 0 warnings) ```
  5. Upgrade to a newer version of ESLint, extend eslint:recommended, and fix any lint errors.

    When we stopped enabling default rules in v1.0, we created eslint:recommended, which omits stylistic rules and enables "you probably didn't mean to do this" rules. Extending eslint:recommended would be most similar to the current behavior of using the default rules and disabling a few.

  6. Add a lint step to the test script in package.json.