outmoded / hapi-contrib

Discussion forum for project contributors
Other
78 stars 25 forks source link

New lint rule for case sensitive module loading #86

Closed geek closed 5 years ago

geek commented 8 years ago

@hapijs/owners any objections to me adding a couple of lint rules to our hapi style:

1 - Enforce that module loading is case sensitive

// Right
const Hoek = require('hoek');

// Wrong
const Hoek = require('Hoek');

2 - Require .json when loading a json file:

// Right
const Package = require('./package.json');

// Wrong
const Package = require('./package');
nlf commented 8 years ago

definite +1 to the first (case sensitivity has bitten us several times developing in OSX and deploying to Linux), the second i'm completely neutral on

devinivy commented 8 years ago

@geek is this for hapijs/owners or the broader hapijs/core-project-maintainers?

In any case, I like both those rules.

geek commented 8 years ago

@devinivy really, anyone :) I didn't want to spam everyone.

johnbrett commented 8 years ago

I'm totally on board with both - first one has bitten me too, just like @nlf.

Curious how the first one works though. Does it compare the name vs that in the package.json or something?

Marsup commented 8 years ago

Modules can only be lowercase.

kanongil commented 8 years ago

Actually, modules can have any case. In practice this is restricted by the npm repository which only allows lowercase names for new modules.

Note that there exists legacy non-lowercase modules on npm. Eg. AMD vs. amd.

Marsup commented 8 years ago

My bad, thought they cleaned it up when they set up the new rules.

johnbrett commented 8 years ago

@kanongil, that's exactly why I'm curious how it's implemented, there's still stuff like: https://www.npmjs.com/package/JSONStream on npm!

nlf commented 8 years ago

Also local requires are occasionally mixed case for us