dangreenisrael / eslint-plugin-jest-formatting

ESLint rules for formatting test suites written for jest.
MIT License
156 stars 13 forks source link

[BUG] TypeError when extend recommended config #63

Closed dimadk24 closed 5 years ago

dimadk24 commented 5 years ago

Describe the bug eslint throws TypeError: Cannot read property 'recommended' of undefined when extend recommended config

TypeError: Cannot read property 'recommended' of undefined
Referenced from: /Users/dmitrijk/Projects/orders-manager-frontend/.eslintrc.json
    at loadConfigFile (/Users/dmitrijk/Projects/orders-manager-frontend/node_modules/eslint/lib/config/config-file.js:216:40)
    at loadFromDisk (/Users/dmitrijk/Projects/orders-manager-frontend/node_modules/eslint/lib/config/config-file.js:523:18)
    at load (/Users/dmitrijk/Projects/orders-manager-frontend/node_modules/eslint/lib/config/config-file.js:587:20)
    at configExtends.reduceRight (/Users/dmitrijk/Projects/orders-manager-frontend/node_modules/eslint/lib/config/config-file.js:453:36)
    at Array.reduceRight (<anonymous>)
    at applyExtends (/Users/dmitrijk/Projects/orders-manager-frontend/node_modules/eslint/lib/config/config-file.js:431:26)
    at loadFromDisk (/Users/dmitrijk/Projects/orders-manager-frontend/node_modules/eslint/lib/config/config-file.js:551:22)
    at Object.load (/Users/dmitrijk/Projects/orders-manager-frontend/node_modules/eslint/lib/config/config-file.js:587:20)
    at Config.getLocalConfigHierarchy (/Users/dmitrijk/Projects/orders-manager-frontend/node_modules/eslint/lib/config.js:240:44)
    at Config.getConfigHierarchy (/Users/dmitrijk/Projects/orders-manager-frontend/node_modules/eslint/lib/config.js:192:43)

To Reproduce have following devDependencies in package.json:

{
    "eslint": "~5.16.0",
    "eslint-config-airbnb": "^17.1.1",
    "eslint-plugin-import": "^2.18.2",
    "eslint-plugin-jest-formatting": "^0.1.0",
   ...
}

have following .eslintrc.json:

{
  "env": {
    "browser": true,
    "es6": true
  },
  "extends": [
    "eslint:recommended",
    "airbnb",
    "plugin:jest-formatting/recommended"
  ],
  "globals": {
    "Atomics": "readonly",
    "SharedArrayBuffer": "readonly"
  },
  "parserOptions": {
    "ecmaFeatures": {
      "jsx": true
    },
    "ecmaVersion": 2018,
    "sourceType": "module"
  },
  "plugins": ["jest-formatting"],
  "rules":
  ...
  }
}

Of course I have installed plugin via yarn add eslint-plugin-jest-formatting --dev. I have node_modules/eslint-plugin-jest-formatting/lib/index.js file. Exactly this file causes this issue.

Expected behavior No error happens

Desktop (please complete the following information):

benkimpel commented 5 years ago

Hey @DimaDK24. Thanks for the report.

@dangreenisrael I suspect that we'll either need to 1) export a single object as the default export or 2) export a single object with module.exports. I've seen other eslint plugins that use module.exports with an object while the rest of the file ES6 uses import/export. It comes down to how ESLint attempts to import our code and I'm not sure on the specifics. lmk your thoughts.

benkimpel commented 5 years ago

@DimaDK24 if you'd like a workaround while the issue is investigated you can remove the line from extends and then list each of the rules individually under rules.

dimadk24 commented 5 years ago

@benkimpel, thanks for the quick response! Will do so

dangreenisrael commented 5 years ago

I'm pretty sure that this is because the master version isn't deployed to NPM. I will put a note in the readme. So sorry @DimaDK24

benkimpel commented 5 years ago

Ooh! Easier fix. Great, @dangreenisrael.

dangreenisrael commented 5 years ago

Also, @DimaDK24, thanks so much for taking the time to report this bug. It is appreciated.

dimadk24 commented 5 years ago

Thanks for such a fast resolution!

dangreenisrael commented 5 years ago

😄

dangreenisrael commented 5 years ago

@DimaDK24 v1.0.0 has been released

dimadk24 commented 5 years ago

@dangreenisrael, thanks for notifying! Updated to this version

dangreenisrael commented 5 years ago

😄