Skip to content

Commit

Permalink
[meta] enable quotes rule everywhere
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb committed Jan 26, 2021
1 parent 877e22c commit fd4b16b
Show file tree
Hide file tree
Showing 17 changed files with 163 additions and 172 deletions.
9 changes: 9 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,14 @@
"no-console": "off",
},
},
{
"files": [
"resolvers/*/test/**/*",
],
"env": {
"mocha": true,
"es6": false
},
}
],
}
9 changes: 0 additions & 9 deletions resolvers/node/test/.eslintrc

This file was deleted.

2 changes: 1 addition & 1 deletion resolvers/node/test/native.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
exports.natively = function () { return "but where do we feature?"; };
exports.natively = function () { return 'but where do we feature?'; };
26 changes: 13 additions & 13 deletions resolvers/node/test/paths.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,27 @@ const expect = require('chai').expect;
const path = require('path');
const node = require('../index.js');

describe("paths", function () {
it("handles base path relative to CWD", function () {
describe('paths', function () {
it('handles base path relative to CWD', function () {
expect(node.resolve('../', './test/file.js'))
.to.have.property('path')
.equal(path.resolve(__dirname, '../index.js'));
});
});


describe("core", function () {
it("returns found, but null path, for core Node modules", function () {
const resolved = node.resolve('fs', "./test/file.js");
expect(resolved).has.property("found", true);
expect(resolved).has.property("path", null);
describe('core', function () {
it('returns found, but null path, for core Node modules', function () {
const resolved = node.resolve('fs', './test/file.js');
expect(resolved).has.property('found', true);
expect(resolved).has.property('path', null);
});
});


describe("default options", function () {
describe('default options', function () {

it("finds .json files", function () {
it('finds .json files', function () {
expect(node.resolve('./data', './test/file.js'))
.to.have.property('path')
.equal(path.resolve(__dirname, './data.json'));
Expand All @@ -34,25 +34,25 @@ describe("default options", function () {
.to.have.property('found', false);
});

it("finds mjs modules, with precedence over .js", function () {
it('finds mjs modules, with precedence over .js', function () {
expect(node.resolve('./native', './test/file.js'))
.to.have.property('path')
.equal(path.resolve(__dirname, './native.mjs'));
});

it("finds .node modules, with lowest precedence", function () {
it('finds .node modules, with lowest precedence', function () {
expect(node.resolve('./native.node', './test/file.js'))
.to.have.property('path')
.equal(path.resolve(__dirname, './native.node'));
});

it("finds .node modules", function () {
it('finds .node modules', function () {
expect(node.resolve('./dot-node', './test/file.js'))
.to.have.property('path')
.equal(path.resolve(__dirname, './dot-node.node'));
});

it("still finds .js if explicit", function () {
it('still finds .js if explicit', function () {
expect(node.resolve('./native.js', './test/file.js'))
.to.have.property('path')
.equal(path.resolve(__dirname, './native.js'));
Expand Down
6 changes: 0 additions & 6 deletions resolvers/webpack/test/.eslintrc

This file was deleted.

152 changes: 76 additions & 76 deletions resolvers/webpack/test/alias.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,132 +8,132 @@ const webpack = require('../index');

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

describe("resolve.alias", function () {
describe('resolve.alias', function () {
let resolved;
before(function () { resolved = webpack.resolve('foo', file); });

it("is found", function () { expect(resolved).to.have.property('found', true); });
it('is found', function () { expect(resolved).to.have.property('found', true); });

it("is correct", function () {
it('is correct', function () {
expect(resolved).to.have.property('path')
.and.equal(path.join(__dirname, 'files', 'some', 'goofy', 'path', 'foo.js'));
});
});

// todo: reimplement with resolver function / config
// describe.skip("webpack alias spec", function () {
// describe.skip('webpack alias spec', function () {
// // from table: http://webpack.github.io/docs/configuration.html#resolve-alias
// function tableLine(alias, xyz, xyzFile) {
// describe(JSON.stringify(alias), function () {
// it("xyz: " + xyz, function () {
// expect(resolveAlias('xyz', alias)).to.equal(xyz)
// })
// it("xyz/file: " + (xyzFile.name || xyzFile), function () {
// it('xyz: ' + xyz, function () {
// expect(resolveAlias('xyz', alias)).to.equal(xyz);
// });
// it('xyz/file: ' + (xyzFile.name || xyzFile), function () {
// if (xyzFile === Error) {
// expect(resolveAlias.bind(null, 'xyz/file', alias)).to.throw(xyzFile)
// expect(resolveAlias.bind(null, 'xyz/file', alias)).to.throw(xyzFile);
// } else {
// expect(resolveAlias('xyz/file', alias)).to.equal(xyzFile)
// expect(resolveAlias('xyz/file', alias)).to.equal(xyzFile);
// }
// })
// })
// });
// });
// }

// tableLine( {}
// , 'xyz', 'xyz/file' )
// , 'xyz', 'xyz/file' );

// tableLine( { xyz: "/absolute/path/to/file.js" }
// , '/absolute/path/to/file.js', 'xyz/file' )
// tableLine( { xyz: '/absolute/path/to/file.js' }
// , '/absolute/path/to/file.js', 'xyz/file' );

// tableLine( { xyz$: "/absolute/path/to/file.js" }
// , "/absolute/path/to/file.js", Error )
// tableLine( { xyz$: '/absolute/path/to/file.js' }
// , '/absolute/path/to/file.js', Error );

// tableLine( { xyz: "./dir/file.js" }
// , './dir/file.js', 'xyz/file' )
// tableLine( { xyz: './dir/file.js' }
// , './dir/file.js', 'xyz/file' );

// tableLine( { xyz$: "./dir/file.js" }
// , './dir/file.js', Error )
// tableLine( { xyz$: './dir/file.js' }
// , './dir/file.js', Error );

// tableLine( { xyz: "/some/dir" }
// , '/some/dir', '/some/dir/file' )
// tableLine( { xyz: '/some/dir' }
// , '/some/dir', '/some/dir/file' );

// tableLine( { xyz$: "/some/dir" }
// , '/some/dir', 'xyz/file' )
// tableLine( { xyz$: '/some/dir' }
// , '/some/dir', 'xyz/file' );

// tableLine( { xyz: "./dir" }
// , './dir', './dir/file' )
// tableLine( { xyz: './dir' }
// , './dir', './dir/file' );

// tableLine( { xyz: "modu" }
// , 'modu', 'modu/file' )
// tableLine( { xyz: 'modu' }
// , 'modu', 'modu/file' );

// tableLine( { xyz$: "modu" }
// , 'modu', 'xyz/file' )
// tableLine( { xyz$: 'modu' }
// , 'modu', 'xyz/file' );

// tableLine( { xyz: "modu/some/file.js" }
// , 'modu/some/file.js', Error )
// tableLine( { xyz: 'modu/some/file.js' }
// , 'modu/some/file.js', Error );

// tableLine( { xyz: "modu/dir" }
// , 'modu/dir', 'modu/dir/file' )
// tableLine( { xyz: 'modu/dir' }
// , 'modu/dir', 'modu/dir/file' );

// tableLine( { xyz: "xyz/dir" }
// , 'xyz/dir', 'xyz/dir/file' )
// tableLine( { xyz: 'xyz/dir' }
// , 'xyz/dir', 'xyz/dir/file' );

// tableLine( { xyz$: "xyz/dir" }
// , 'xyz/dir', 'xyz/file' )
// })
// tableLine( { xyz$: 'xyz/dir' }
// , 'xyz/dir', 'xyz/file' );
// });

// describe.skip("nested module names", function () {
// describe.skip('nested module names', function () {
// // from table: http://webpack.github.io/docs/configuration.html#resolve-alias
// function nestedName(alias, xyz, xyzFile) {
// describe(JSON.stringify(alias), function () {
// it("top/xyz: " + xyz, function () {
// expect(resolveAlias('top/xyz', alias)).to.equal(xyz)
// })
// it("top/xyz/file: " + (xyzFile.name || xyzFile), function () {
// it('top/xyz: ' + xyz, function () {
// expect(resolveAlias('top/xyz', alias)).to.equal(xyz);
// });
// it('top/xyz/file: ' + (xyzFile.name || xyzFile), function () {
// if (xyzFile === Error) {
// expect(resolveAlias.bind(null, 'top/xyz/file', alias)).to.throw(xyzFile)
// expect(resolveAlias.bind(null, 'top/xyz/file', alias)).to.throw(xyzFile);
// } else {
// expect(resolveAlias('top/xyz/file', alias)).to.equal(xyzFile)
// expect(resolveAlias('top/xyz/file', alias)).to.equal(xyzFile);
// }
// })
// })
// });
// });
// }

// nestedName( { 'top/xyz': "/absolute/path/to/file.js" }
// , '/absolute/path/to/file.js', 'top/xyz/file' )
// nestedName( { 'top/xyz': '/absolute/path/to/file.js' }
// , '/absolute/path/to/file.js', 'top/xyz/file' );

// nestedName( { 'top/xyz$': "/absolute/path/to/file.js" }
// , "/absolute/path/to/file.js", Error )
// nestedName( { 'top/xyz$': '/absolute/path/to/file.js' }
// , '/absolute/path/to/file.js', Error );

// nestedName( { 'top/xyz': "./dir/file.js" }
// , './dir/file.js', 'top/xyz/file' )
// nestedName( { 'top/xyz': './dir/file.js' }
// , './dir/file.js', 'top/xyz/file' );

// nestedName( { 'top/xyz$': "./dir/file.js" }
// , './dir/file.js', Error )
// nestedName( { 'top/xyz$': './dir/file.js' }
// , './dir/file.js', Error );

// nestedName( { 'top/xyz': "/some/dir" }
// , '/some/dir', '/some/dir/file' )
// nestedName( { 'top/xyz': '/some/dir' }
// , '/some/dir', '/some/dir/file' );

// nestedName( { 'top/xyz$': "/some/dir" }
// , '/some/dir', 'top/xyz/file' )
// nestedName( { 'top/xyz$': '/some/dir' }
// , '/some/dir', 'top/xyz/file' );

// nestedName( { 'top/xyz': "./dir" }
// , './dir', './dir/file' )
// nestedName( { 'top/xyz': './dir' }
// , './dir', './dir/file' );

// nestedName( { 'top/xyz': "modu" }
// , 'modu', 'modu/file' )
// nestedName( { 'top/xyz': 'modu' }
// , 'modu', 'modu/file' );

// nestedName( { 'top/xyz$': "modu" }
// , 'modu', 'top/xyz/file' )
// nestedName( { 'top/xyz$': 'modu' }
// , 'modu', 'top/xyz/file' );

// nestedName( { 'top/xyz': "modu/some/file.js" }
// , 'modu/some/file.js', Error )
// nestedName( { 'top/xyz': 'modu/some/file.js' }
// , 'modu/some/file.js', Error );

// nestedName( { 'top/xyz': "modu/dir" }
// , 'modu/dir', 'modu/dir/file' )
// nestedName( { 'top/xyz': 'modu/dir' }
// , 'modu/dir', 'modu/dir/file' );

// nestedName( { 'top/xyz': "top/xyz/dir" }
// , 'top/xyz/dir', 'top/xyz/dir/file' )
// nestedName( { 'top/xyz': 'top/xyz/dir' }
// , 'top/xyz/dir', 'top/xyz/dir/file' );

// nestedName( { 'top/xyz$': "top/xyz/dir" }
// , 'top/xyz/dir', 'top/xyz/file' )
// })
// nestedName( { 'top/xyz$': 'top/xyz/dir' }
// , 'top/xyz/dir', 'top/xyz/file' );
// });
22 changes: 11 additions & 11 deletions resolvers/webpack/test/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,18 @@ const absoluteSettings = {
config: path.join(__dirname, 'files', 'some', 'absolute.path.webpack.config.js'),
};

describe("config", function () {
it("finds webpack.config.js in parent directories", function () {
describe('config', function () {
it('finds webpack.config.js in parent directories', function () {
expect(resolve('main-module', file)).to.have.property('path')
.and.equal(path.join(__dirname, 'files', 'src', 'main-module.js'));
});

it("finds absolute webpack.config.js files", function () {
it('finds absolute webpack.config.js files', function () {
expect(resolve('foo', file, absoluteSettings)).to.have.property('path')
.and.equal(path.join(__dirname, 'files', 'some', 'absolutely', 'goofy', 'path', 'foo.js'));
});

it("finds compile-to-js configs", function () {
it('finds compile-to-js configs', function () {
const settings = {
config: path.join(__dirname, './files/webpack.config.babel.js'),
};
Expand All @@ -34,13 +34,13 @@ describe("config", function () {
.and.equal(path.join(__dirname, 'files', 'src', 'main-module.js'));
});

it("finds compile-to-js config in parent directories", function () {
it('finds compile-to-js config in parent directories', function () {
expect(resolve('main-module', extensionFile))
.to.have.property('path')
.and.equal(path.join(__dirname, 'config-extensions', 'src', 'main-module.js'));
});

it("finds the first config with a resolve section", function () {
it('finds the first config with a resolve section', function () {
const settings = {
config: path.join(__dirname, './files/webpack.config.multiple.js'),
};
Expand All @@ -49,7 +49,7 @@ describe("config", function () {
.and.equal(path.join(__dirname, 'files', 'src', 'main-module.js'));
});

it("finds the config at option config-index", function () {
it('finds the config at option config-index', function () {
const settings = {
config: path.join(__dirname, './files/webpack.config.multiple.js'),
'config-index': 2,
Expand All @@ -66,23 +66,23 @@ describe("config", function () {
expect(function () { resolve('foo', file, settings); }).to.throw(Error);
});

it("finds config object when config is an object", function () {
it('finds config object when config is an object', function () {
const settings = {
config: require(path.join(__dirname, 'files', 'some', 'absolute.path.webpack.config.js')),
};
expect(resolve('foo', file, settings)).to.have.property('path')
.and.equal(path.join(__dirname, 'files', 'some', 'absolutely', 'goofy', 'path', 'foo.js'));
});

it("finds config object when config uses a path relative to working dir", function () {
it('finds config object when config uses a path relative to working dir', function () {
const settings = {
config: './test/files/some/absolute.path.webpack.config.js',
};
expect(resolve('foo', file, settings)).to.have.property('path')
.and.equal(path.join(__dirname, 'files', 'some', 'absolutely', 'goofy', 'path', 'foo.js'));
});

it("finds the first config with a resolve section when config is an array of config objects", function () {
it('finds the first config with a resolve section when config is an array of config objects', function () {
const settings = {
config: require(path.join(__dirname, './files/webpack.config.multiple.js')),
};
Expand All @@ -91,7 +91,7 @@ describe("config", function () {
.and.equal(path.join(__dirname, 'files', 'src', 'main-module.js'));
});

it("finds the config at option config-index when config is an array of config objects", function () {
it('finds the config at option config-index when config is an array of config objects', function () {
const settings = {
config: require(path.join(__dirname, './files/webpack.config.multiple.js')),
'config-index': 2,
Expand Down
Loading

0 comments on commit fd4b16b

Please sign in to comment.