dwyl / goodparts

:see_no_evil: An ESLint Style that only allows JavaScript the Good Parts (and "Better Parts") in your code.
GNU General Public License v2.0
78 stars 26 forks source link

Installed goodparts from npm and got .eslintrc.js which requires './rules ... #248

Closed nelsonic closed 7 years ago

nelsonic commented 7 years ago

Hi @eliascodes / @shouston3 / @SimonLab / @jrans Hope your evening is going well... I just tried to npm install goodparts and it creates an .eslintrc.js file in the root of my project: eslintrc-js-requires-rules Which attempts to require('./rules') ... is this the desired behaviour...?

eliasmalik commented 7 years ago

@nelsonic see #247 and https://github.com/dwyl/abase/pull/46

This is our SHORT TERM HACK so we can use goodparts with atom. The file you're seeing is just a symlink. The ./rules file it's requiring is relative to the goodparts directory in node_modules, not the project root.

The proper long term solution is to create an atom plugin #243.

nelsonic commented 7 years ago

@eliascodes so it's ok to include this file in my .gitignore ?

eliasmalik commented 7 years ago

@nelsonic yes I would recommend that you do.

jrans commented 7 years ago

@nelsonic @eliascodes symlinking isn't ideal. Just committed my .eslintrc.js symlink into my new repo and not too pleased. Obviously my bad but if I'm going to the effort of adding it to my .gitignore i'd rather just create an my own .eslintrc.js and extend the goodparts module saving having to use global eslint (in atom) which is again causing me problems working on other projects which have their own .eslintrc

eliasmalik commented 7 years ago

@jrans @nelsonic what do you think about this:

eliasmalik commented 7 years ago

@jrans @nelsonic there is a problem with the approach I outlined above: any shareable configs must have package names of the form "eslint-config-packageName". This is documented here, and you can see the code that I think corresponds to it here. I've tried it out locally and get an error thrown when eslint can't find the config. In my .eslintrc.json:

{
  "extends": "goodparts"
}

Then when I try to run the goodparts CLI, I get:

Error: Cannot find module 'eslint-config-goodparts'

So a npm package by the name of goodparts cannot be used as a shareable config.

I've pushed a branch where I've implemented steps 1 and 3 from my last comment. Let me know if you want me to PR it.

nelsonic commented 7 years ago

@eliascodes ideally we would not have an .eslintrc or .eslintrc.json in any of our projects and simply use the goodparts .bin script e.g: npm run goodparts ...

eliasmalik commented 7 years ago

@nelsonic well happily that's already possible 😄

I can see why it is handy to have a real-time linter running in your editor though. If we do want to make that happen, it might just be better to bite the bullet and actually write an atom plugin at some point.

Anyway, please let me know if you would like me to submit a PR. If so, I need to write a couple more tests because I introduced a couple branches into the bin/cmd.js that aren't covered by a simple require.

eliasmalik commented 7 years ago

Has this issue now been fully addressed (can it be closed)?

nelsonic commented 7 years ago

@eliascodes great question. we will know soon ... https://github.com/dwyl/hapi-auth-jwt2/issues/211 😉

nelsonic commented 7 years ago

hapi-auth-jwt2-no-eslintirc-file

#Succcess ✅ Thanks @eliascodes ❤️