SamVerschueren / clinton

Project style linter
MIT License
122 stars 9 forks source link

Throws when run in a project without a package.json #45

Closed sindresorhus closed 7 years ago

sindresorhus commented 8 years ago
SublimeLinter-contrib-xo
TypeError: Cannot read property 'clinton' of undefined
    at /usr/local/lib/node_modules/clinton/lib/config.js:21:59
SamVerschueren commented 8 years ago

Good point, never ran in on such projects.

beatfreaker commented 8 years ago

can i help with this?

SamVerschueren commented 8 years ago

can i help with this?

You can, but I think quite some things have to be changed for this. I'm always open for a good PR.

beatfreaker commented 8 years ago

I have not dig deep into it but i think we should throw err from here https://github.com/SamVerschueren/clinton/blob/master/lib/config.js#L21 if no package.json found

am i right?

SamVerschueren commented 8 years ago

The question is, should we still lint if no package.json is present?

beatfreaker commented 8 years ago

i think we should, it will then lint only on the basis of opts

SamVerschueren commented 8 years ago

I believe clinton will still fail on rules depending on package.json like this one. Might have to check if package.json exists, like I did in the travis rule.

Should we add something like metadata to every rule? Little bit like ESLint which will define some dependencies or something. So you can specify which files should be present in order to execute the rule.

Just brainstorming here. Would like some more opinions on how we can solve this elegantly.

SamVerschueren commented 7 years ago

I'm ignoring projects without package.json for now. I'm open for suggestions on how to improve for projects with package.json. But my main focus is JavaScript projects.