Skip to content

Commit

Permalink
Fix eslints
Browse files Browse the repository at this point in the history
  • Loading branch information
OlivierZal committed Sep 1, 2023
1 parent 6b95a02 commit 8f3e08b
Show file tree
Hide file tree
Showing 22 changed files with 36 additions and 48 deletions.
3 changes: 1 addition & 2 deletions resolvers/node/test/packageMains.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
'use strict';

const chai = require('chai');
const expect = chai.expect;
const { expect } = require('chai');
const path = require('path');

const resolver = require('../');
Expand Down
2 changes: 1 addition & 1 deletion resolvers/node/test/paths.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const expect = require('chai').expect;
const { expect } = require('chai');

const path = require('path');
const node = require('../index.js');
Expand Down
6 changes: 3 additions & 3 deletions resolvers/webpack/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -293,15 +293,15 @@ function createWebpack1ResolveSync(webpackRequire, resolveConfig, plugins) {
&& plugin.constructor.name === 'ResolverPlugin'
&& Array.isArray(plugin.plugins)
) {
resolvePlugins.push.apply(resolvePlugins, plugin.plugins);
resolvePlugins.push(...plugin.plugins);
}
});
}

resolver.apply.apply(resolver, resolvePlugins);
resolver.apply(...resolvePlugins);

return function () {
return resolver.resolveSync.apply(resolver, arguments);
return resolver.resolveSync(...arguments);
};
}

Expand Down
3 changes: 1 addition & 2 deletions resolvers/webpack/test/alias.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
'use strict';

const chai = require('chai');
const expect = chai.expect;
const { expect } = require('chai');
const path = require('path');

const webpack = require('../index');
Expand Down
5 changes: 2 additions & 3 deletions resolvers/webpack/test/config.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
'use strict';

const chai = require('chai');
const expect = chai.expect;
const { expect } = require('chai');
const path = require('path');

const resolve = require('../index').resolve;
const { resolve } = require('../index');

const file = path.join(__dirname, 'files', 'src', 'jsx', 'dummy.js');
const extensionFile = path.join(__dirname, 'config-extensions', 'src', 'dummy.js');
Expand Down
2 changes: 1 addition & 1 deletion resolvers/webpack/test/example.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

const path = require('path');

const resolve = require('../index').resolve;
const { resolve } = require('../index');

const file = path.join(__dirname, 'files', 'src', 'dummy.js');

Expand Down
5 changes: 2 additions & 3 deletions resolvers/webpack/test/extensions.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
'use strict';

const chai = require('chai');
const expect = chai.expect;
const { expect } = require('chai');
const path = require('path');

const resolve = require('../index').resolve;
const { resolve } = require('../index');

const file = path.join(__dirname, 'files', 'dummy.js');
const extensions = path.join(__dirname, 'custom-extensions', 'dummy.js');
Expand Down
3 changes: 1 addition & 2 deletions resolvers/webpack/test/externals.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
'use strict';

const chai = require('chai');
const expect = chai.expect;
const { expect } = require('chai');
const path = require('path');
const semver = require('semver');

Expand Down
5 changes: 2 additions & 3 deletions resolvers/webpack/test/fallback.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
'use strict';

const chai = require('chai');
const expect = chai.expect;
const { expect } = require('chai');
const path = require('path');

const resolve = require('../index').resolve;
const { resolve } = require('../index');

const file = path.join(__dirname, 'files', 'src', 'dummy.js');

Expand Down
5 changes: 2 additions & 3 deletions resolvers/webpack/test/loaders.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
'use strict';

const chai = require('chai');
const expect = chai.expect;
const { expect } = require('chai');
const path = require('path');

const resolve = require('../index').resolve;
const { resolve } = require('../index');

const file = path.join(__dirname, 'files', 'dummy.js');

Expand Down
5 changes: 2 additions & 3 deletions resolvers/webpack/test/modules.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
'use strict';

const chai = require('chai');
const expect = chai.expect;
const { expect } = require('chai');
const path = require('path');

const resolve = require('../index').resolve;
const { resolve } = require('../index');

const file = path.join(__dirname, 'files', 'dummy.js');

Expand Down
3 changes: 1 addition & 2 deletions resolvers/webpack/test/packageMains.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
'use strict';

const chai = require('chai');
const expect = chai.expect;
const { expect } = require('chai');
const path = require('path');

const resolver = require('../');
Expand Down
3 changes: 1 addition & 2 deletions resolvers/webpack/test/plugins.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
'use strict';

const chai = require('chai');
const expect = chai.expect;
const { expect } = require('chai');
const path = require('path');

const webpack = require('../index');
Expand Down
5 changes: 2 additions & 3 deletions resolvers/webpack/test/root.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
'use strict';

const chai = require('chai');
const expect = chai.expect;
const { expect } = require('chai');
const path = require('path');

const resolve = require('../index').resolve;
const { resolve } = require('../index');

const file = path.join(__dirname, 'files', 'src', 'dummy.js');
const webpackDir = path.join(__dirname, 'different-package-location');
Expand Down
2 changes: 1 addition & 1 deletion utils/declaredScope.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
exports.__esModule = true;

exports.default = function declaredScope(context, name) {
const references = context.getScope().references;
const { references } = context.getScope();
const reference = references.find((x) => x.identifier.name === name);
if (!reference) { return undefined; }
return reference.resolved.scope.type;
Expand Down
4 changes: 2 additions & 2 deletions utils/hash.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

exports.__esModule = true;

const createHash = require('crypto').createHash;
const { createHash } = require('crypto');

const stringify = JSON.stringify;
const { stringify } = JSON;

function hashify(value, hash) {
if (!hash) { hash = createHash('sha256'); }
Expand Down
2 changes: 1 addition & 1 deletion utils/ignore.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

exports.__esModule = true;

const extname = require('path').extname;
const { extname } = require('path');

const log = require('debug')('eslint-plugin-import:utils:ignore');

Expand Down
6 changes: 3 additions & 3 deletions utils/moduleVisitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ exports.default = function visitModules(visitor, options) {
if (node.callee.type !== 'Import') { return; }
if (node.arguments.length !== 1) { return; }

modulePath = node.arguments[0];
[modulePath] = node.arguments;
}

if (modulePath.type !== 'Literal') { return; }
Expand All @@ -61,7 +61,7 @@ exports.default = function visitModules(visitor, options) {
if (call.callee.name !== 'require') { return; }
if (call.arguments.length !== 1) { return; }

const modulePath = call.arguments[0];
const [modulePath] = call.arguments;
if (modulePath.type !== 'Literal') { return; }
if (typeof modulePath.value !== 'string') { return; }

Expand All @@ -73,7 +73,7 @@ exports.default = function visitModules(visitor, options) {
if (call.callee.name !== 'require' && call.callee.name !== 'define') { return; }
if (call.arguments.length !== 2) { return; }

const modules = call.arguments[0];
const [modules] = call.arguments;
if (modules.type !== 'ArrayExpression') { return; }

for (const element of modules.elements) {
Expand Down
4 changes: 2 additions & 2 deletions utils/parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
exports.__esModule = true;

const moduleRequire = require('./module-require').default;
const extname = require('path').extname;
const { extname } = require('path');
const fs = require('fs');

const log = require('debug')('eslint-plugin-import:parse');
Expand Down Expand Up @@ -95,7 +95,7 @@ exports.default = function parse(path, content, context) {
let ast;
try {
const parserRaw = parser.parseForESLint(content, parserOptions);
ast = parserRaw.ast;
({ ast } = parserRaw);
return makeParseReturn(ast, keysFromParser(parserOrPath, parser, parserRaw));
} catch (e) {
console.warn();
Expand Down
2 changes: 1 addition & 1 deletion utils/pkgUp.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const path = require('path');
*/
function findUp(filename, cwd) {
let dir = path.resolve(cwd || '');
const root = path.parse(dir).root;
const { root } = path.parse(dir);

const filenames = [].concat(filename);

Expand Down
7 changes: 3 additions & 4 deletions utils/resolve.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const fs = require('fs');
const Module = require('module');
const path = require('path');

const hashObject = require('./hash').hashObject;
const { hashObject } = require('./hash');
const ModuleCache = require('./ModuleCache').default;
const pkgDir = require('./pkgDir').default;

Expand Down Expand Up @@ -60,7 +60,7 @@ exports.fileExistsWithCaseSync = function fileExistsWithCaseSync(filepath, cache
if (filepath === null) { return true; }
if (filepath.toLowerCase() === process.cwd().toLowerCase() && !strict) { return true; }
const parsedPath = path.parse(filepath);
const dir = parsedPath.dir;
const { dir } = parsedPath;

let result = fileExistsCache.get(filepath, cacheSettings);
if (result != null) { return result; }
Expand Down Expand Up @@ -129,8 +129,7 @@ function fullResolve(modulePath, sourceFile, settings) {
const resolvers = resolverReducer(configResolvers, new Map());

for (const pair of resolvers) {
const name = pair[0];
const config = pair[1];
const [name, config] = pair;
const resolver = requireResolver(name, sourceFile);
const resolved = withResolver(resolver, config);

Expand Down
2 changes: 1 addition & 1 deletion utils/visit.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ exports.default = function visit(node, keys, visitorSpec) {
if (!node || !keys) {
return;
}
const type = node.type;
const { type } = node;
if (typeof visitorSpec[type] === 'function') {
visitorSpec[type](node);
}
Expand Down

0 comments on commit 8f3e08b

Please sign in to comment.