eslint-import-resolver-webpack
Advanced tools
Comparing version
39
index.js
@@ -87,3 +87,3 @@ 'use strict'; | ||
webpackConfig = require(configPath); | ||
} catch(e) { | ||
} catch (e) { | ||
console.log('Error resolving webpackConfig', e); | ||
@@ -122,4 +122,3 @@ throw e; | ||
webpackConfig = webpackConfig[configIndex]; | ||
} | ||
else { | ||
} else { | ||
webpackConfig = find(webpackConfig, function findFirstWithResolve(config) { | ||
@@ -169,3 +168,3 @@ return !!config.resolve; | ||
function getResolveSync(configPath, webpackConfig, cwd) { | ||
const cacheKey = { configPath: configPath, webpackConfig: webpackConfig }; | ||
const cacheKey = { configPath, webpackConfig }; | ||
let cached = find(_cache, function (entry) { return isEqual(entry.key, cacheKey); }); | ||
@@ -272,3 +271,3 @@ if (!cached) { | ||
? new DirectoryDescriptionFileFieldAliasPlugin('package.json', resolveConfig.packageAlias) | ||
: function() {}, | ||
: function () {}, | ||
new ModuleAliasPlugin(resolveConfig.alias || {}), | ||
@@ -278,3 +277,3 @@ makeRootPlugin(ModulesInRootPlugin, 'module', resolveConfig.root), | ||
'module', | ||
resolveConfig.modulesDirectories || resolveConfig.modules || ['web_modules', 'node_modules'] | ||
resolveConfig.modulesDirectories || resolveConfig.modules || ['web_modules', 'node_modules'], | ||
), | ||
@@ -286,7 +285,7 @@ makeRootPlugin(ModulesInRootPlugin, 'module', resolveConfig.fallback), | ||
'package.json', | ||
['module', 'jsnext:main'].concat(resolveConfig.packageMains || webpack1DefaultMains) | ||
['module', 'jsnext:main'].concat(resolveConfig.packageMains || webpack1DefaultMains), | ||
), | ||
new DirectoryDefaultFilePlugin(['index']), | ||
new FileAppendPlugin(resolveConfig.extensions || ['', '.webpack.js', '.web.js', '.js']), | ||
new ResultSymlinkPlugin() | ||
new ResultSymlinkPlugin(), | ||
); | ||
@@ -312,3 +311,3 @@ | ||
return function() { | ||
return function () { | ||
return resolver.resolveSync.apply(resolver, arguments); | ||
@@ -321,7 +320,7 @@ }; | ||
function makeRootPlugin(ModulesInRootPlugin, name, root) { | ||
if(typeof root === "string") | ||
if (typeof root === 'string') { | ||
return new ModulesInRootPlugin(name, root); | ||
else if(Array.isArray(root)) { | ||
} else if (Array.isArray(root)) { | ||
return function() { | ||
root.forEach(function(root) { | ||
root.forEach(function (root) { | ||
this.apply(new ModulesInRootPlugin(name, root)); | ||
@@ -331,3 +330,3 @@ }, this); | ||
} | ||
return function() {}; | ||
return function () {}; | ||
} | ||
@@ -404,3 +403,3 @@ /* eslint-enable */ | ||
function findConfigPath(configPath, packageDir) { | ||
const extensions = Object.keys(interpret.extensions).sort(function(a, b) { | ||
const extensions = Object.keys(interpret.extensions).sort(function (a, b) { | ||
return a === '.js' ? -1 : b === '.js' ? 1 : a.length - b.length; | ||
@@ -435,3 +434,3 @@ }); | ||
const maybePath = path.resolve( | ||
path.join(packageDir, 'webpack.config' + maybeExtension) | ||
path.join(packageDir, 'webpack.config' + maybeExtension), | ||
); | ||
@@ -450,13 +449,13 @@ if (fs.existsSync(maybePath)) { | ||
function registerCompiler(moduleDescriptor) { | ||
if(moduleDescriptor) { | ||
if(typeof moduleDescriptor === 'string') { | ||
if (moduleDescriptor) { | ||
if (typeof moduleDescriptor === 'string') { | ||
require(moduleDescriptor); | ||
} else if(!Array.isArray(moduleDescriptor)) { | ||
} else if (!Array.isArray(moduleDescriptor)) { | ||
moduleDescriptor.register(require(moduleDescriptor.module)); | ||
} else { | ||
for(let i = 0; i < moduleDescriptor.length; i++) { | ||
for (let i = 0; i < moduleDescriptor.length; i++) { | ||
try { | ||
registerCompiler(moduleDescriptor[i]); | ||
break; | ||
} catch(e) { | ||
} catch (e) { | ||
log('Failed to register compiler for moduleDescriptor[]:', i, moduleDescriptor); | ||
@@ -463,0 +462,0 @@ } |
{ | ||
"name": "eslint-import-resolver-webpack", | ||
"version": "0.13.1", | ||
"version": "0.13.2", | ||
"description": "Resolve paths to dependencies, given a webpack.config.js. Plugin for eslint-plugin-import.", | ||
@@ -9,5 +9,3 @@ "main": "index.js", | ||
"tests-only": "nyc mocha -t 5s", | ||
"test": "npm run tests-only", | ||
"report": "nyc report --reporter=html", | ||
"coveralls": "nyc report --reporter lcovonly && cd ../.. && coveralls < ./resolvers/webpack/coverage/lcov.info" | ||
"test": "npm run tests-only" | ||
}, | ||
@@ -20,3 +18,3 @@ "files": [ | ||
"type": "git", | ||
"url": "git+https://github.com/benmosher/eslint-plugin-import.git" | ||
"url": "git+https://github.com/import-js/eslint-plugin-import.git" | ||
}, | ||
@@ -33,5 +31,5 @@ "keywords": [ | ||
"bugs": { | ||
"url": "https://github.com/benmosher/eslint-plugin-import/issues" | ||
"url": "https://github.com/import-js/eslint-plugin-import/issues" | ||
}, | ||
"homepage": "https://github.com/benmosher/eslint-plugin-import/tree/master/resolvers/webpack", | ||
"homepage": "https://github.com/import-js/eslint-plugin-import/tree/HEAD/resolvers/webpack", | ||
"dependencies": { | ||
@@ -44,4 +42,4 @@ "array-find": "^1.0.0", | ||
"interpret": "^1.4.0", | ||
"is-core-module": "^2.4.0", | ||
"is-regex": "^1.1.3", | ||
"is-core-module": "^2.7.0", | ||
"is-regex": "^1.1.4", | ||
"lodash": "^4.17.21", | ||
@@ -57,6 +55,4 @@ "resolve": "^1.20.0", | ||
"babel-plugin-istanbul": "^4.1.6", | ||
"babel-preset-es2015-argon": "latest", | ||
"babel-register": "^6.26.0", | ||
"chai": "^3.5.0", | ||
"coveralls": "^3.1.0", | ||
"mocha": "^3.5.3", | ||
@@ -67,4 +63,4 @@ "nyc": "^11.9.0", | ||
"engines": { | ||
"node": "^16 || ^15 || ^14 || ^13 || ^12 || ^11 || ^10 || ^9 || ^8 || ^7 || ^6" | ||
"node": ">= 6" | ||
} | ||
} |
6
-25%20131
-28.75%5
-16.67%395
-0.25%Updated
Updated