I like the practice of assigning imports to variables that are camel-cased versions of the package name:
var objectAssign = require('object-assign');
var mapObj = require('map-obj');
We've been pretty consistent about using it in AVA, and I like knowing which package to lookup on npm
without scrolling to the top (and I am disappointed when that doesn't work out).
There are exceptions though (perhaps so many it makes an enforcement rule impossible):
// shortening really long name
var throwsHelper = require('babel-plugin-throws-helper');
// reordering? maybe this only makes sense for packages with enforced prefixes.
var throwsHelperPlugin = require('babel-plugin-throws-helper');
// widely understood conventions
var _ = require('lodash');
Maybe the default should just be a warning?
Maybe there are just too many valid exceptions to make this worth it?
Maybe we could encourage a preferredVariableName
section to package.json
?
{
"name": "lodash",
"version": "x.x.x",
"preferredVariableName": ["_", "lodash"]
}
As for handling ES2015 module imports: only apply to default imports.
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too