diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml index 9a999874c..10ecd41a4 100644 --- a/.github/workflows/node.js.yml +++ b/.github/workflows/node.js.yml @@ -4,31 +4,31 @@ name: Node.js CI on: - push: - branches: [ master ] - pull_request: - branches: [ master ] + push: + branches: [master] + pull_request: + branches: [master] jobs: - build: - name: Build and test for ${{ matrix.os }} - runs-on: ${{ matrix.os }} - env: - PLAYWRIGHT_BROWSERS_PATH: 0 - - strategy: - fail-fast: false - matrix: - node-version: [12.x, 13.x, 14.x] - os: [ubuntu-latest, windows-latest] + build: + name: Build and test for ${{ matrix.os }} + runs-on: ${{ matrix.os }} + env: + PLAYWRIGHT_BROWSERS_PATH: 0 - steps: - - uses: actions/checkout@v2 - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v1 - with: - node-version: ${{ matrix.node-version }} - - name: Install Dependencies - run: npm install - - name: Run Tests - run: npm test + strategy: + fail-fast: false + matrix: + node-version: [12.x, 13.x, 14.x] + os: [ubuntu-latest, windows-latest] + + steps: + - uses: actions/checkout@v2 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node-version }} + - name: Install Dependencies + run: npm install + - name: Run Tests + run: npm test diff --git a/src/BabelConfig.js b/src/BabelConfig.js index 451d12c01..e84f1fdfa 100644 --- a/src/BabelConfig.js +++ b/src/BabelConfig.js @@ -17,8 +17,7 @@ class BabelConfig { mixBabelConfig ], { - arrayMerge: (destinationArray, sourceArray, options) => - sourceArray + arrayMerge: (destinationArray, sourceArray, options) => sourceArray } ); } diff --git a/src/File.js b/src/File.js index 97a229a01..79684ffab 100644 --- a/src/File.js +++ b/src/File.js @@ -168,7 +168,9 @@ class File { pathWithoutQueryString() { const queryStringIndex = this.path().indexOf('?'); - return queryStringIndex < 0 ? this.path() : this.path().substr(0, queryStringIndex); + return queryStringIndex < 0 + ? this.path() + : this.path().substr(0, queryStringIndex); } /** diff --git a/src/FileCollection.js b/src/FileCollection.js index ac999776a..6e3331a5c 100644 --- a/src/FileCollection.js +++ b/src/FileCollection.js @@ -30,15 +30,13 @@ class FileCollection { * @param {object} wantsBabel */ merge(output, wantsBabel = false) { - return concat(this.files, output.makeDirectories().path()).then( - contents => { - if (this.shouldCompileWithBabel(wantsBabel, output)) { - output.write(this.babelify(contents)); - } - - return new File(output.makeDirectories().path()); + return concat(this.files, output.makeDirectories().path()).then(contents => { + if (this.shouldCompileWithBabel(wantsBabel, output)) { + output.write(this.babelify(contents)); } - ); + + return new File(output.makeDirectories().path()); + }); } /** @@ -95,9 +93,7 @@ class FileCollection { let files = glob.sync(src.path(), { nodir: true }); if (!files.length) { - Log.feedback( - `Notice: The ${src.path()} search produced no matches.` - ); + Log.feedback(`Notice: The ${src.path()} search produced no matches.`); } return this.copyTo(destination, files); diff --git a/src/Manifest.js b/src/Manifest.js index 440c5f712..870bb058b 100644 --- a/src/Manifest.js +++ b/src/Manifest.js @@ -24,9 +24,7 @@ class Manifest { ); } - return collect(this.manifest) - .sortKeys() - .all(); + return collect(this.manifest).sortKeys().all(); } /** @@ -74,9 +72,7 @@ class Manifest { * Refresh the mix-manifest.js file. */ refresh() { - File.find(this.path()) - .makeDirectories() - .write(this.manifest); + File.find(this.path()).makeDirectories().write(this.manifest); } /** @@ -103,9 +99,7 @@ class Manifest { // If there's a temporary mix.js chunk, we can safely remove it. if (assets.mix) { - assets.mix = collect(assets.mix) - .except('mix.js') - .all(); + assets.mix = collect(assets.mix).except('mix.js').all(); } return ( diff --git a/src/PostCssPluginsFactory.js b/src/PostCssPluginsFactory.js index c2879553a..b7aee546c 100644 --- a/src/PostCssPluginsFactory.js +++ b/src/PostCssPluginsFactory.js @@ -54,14 +54,8 @@ class PostCssPluginsFactory { * Load any postcss plugins that were passed to the Mix command. */ loadLocalPlugins() { - if ( - this.preprocessor.postCssPlugins && - this.preprocessor.postCssPlugins.length - ) { - this.plugins = [ - ...this.plugins, - ...this.preprocessor.postCssPlugins - ]; + if (this.preprocessor.postCssPlugins && this.preprocessor.postCssPlugins.length) { + this.plugins = [...this.plugins, ...this.preprocessor.postCssPlugins]; } return this; @@ -72,9 +66,7 @@ class PostCssPluginsFactory { */ loadAutoprefixer() { if (this.Config.autoprefixer) { - this.plugins.push( - require('autoprefixer')(this.Config.autoprefixer) - ); + this.plugins.push(require('autoprefixer')(this.Config.autoprefixer)); } return this; diff --git a/src/builder/Entry.js b/src/builder/Entry.js index 054775c40..bb0ce685c 100644 --- a/src/builder/Entry.js +++ b/src/builder/Entry.js @@ -53,16 +53,11 @@ class Entry { * Add a default entry script to the structure. */ addDefault() { - this.add( - 'mix', - new File(path.resolve(__dirname, 'mock-entry.js')).path() - ); + this.add('mix', new File(path.resolve(__dirname, 'mock-entry.js')).path()); } hasDefault() { - return (this.structure.mix || []).some(path => - path.includes('mock-entry.js') - ); + return (this.structure.mix || []).some(path => path.includes('mock-entry.js')); } /** @@ -94,18 +89,13 @@ class Entry { !pathFromPublicDir.startsWith('/' + Config.publicPath) && !pathFromPublicDir.startsWith('\\' + Config.publicPath) ) { - output = new File( - path.join(Config.publicPath, output.pathFromPublic()) - ); + output = new File(path.join(Config.publicPath, output.pathFromPublic())); } // If the output points to a directory, we'll grab a file name from the fallback src. if (output.isDirectory()) { output = new File( - path.join( - output.filePath, - fallback.nameWithoutExtension() + '.js' - ) + path.join(output.filePath, fallback.nameWithoutExtension() + '.js') ); } diff --git a/src/builder/MergeSmart.js b/src/builder/MergeSmart.js index 0b7462245..1568cf940 100644 --- a/src/builder/MergeSmart.js +++ b/src/builder/MergeSmart.js @@ -15,8 +15,7 @@ const isArray = Array.isArray; function uniteRules(rules, key, newRule, rule) { if ( String(rule.test) !== String(newRule.test) || - ((newRule.enforce || rule.enforce) && - rule.enforce !== newRule.enforce) || + ((newRule.enforce || rule.enforce) && rule.enforce !== newRule.enforce) || (newRule.include && !isSameValue(rule.include, newRule.include)) || (newRule.exclude && !isSameValue(rule.exclude, newRule.exclude)) ) { @@ -30,10 +29,7 @@ function uniteRules(rules, key, newRule, rule) { ) { // Don't merge the rule if there isn't any identifying fields and the loaders don't match return false; - } else if ( - (rule.include || rule.exclude) && - (!newRule.include && !newRule.exclude) - ) { + } else if ((rule.include || rule.exclude) && !newRule.include && !newRule.exclude) { // Don't merge child without include/exclude to parent that has either return false; } @@ -51,9 +47,7 @@ function uniteRules(rules, key, newRule, rule) { // newRule.loader should always override use, loaders and oneOf if (newRule.loader) { - const optionsKey = newRule.options - ? 'options' - : newRule.query && 'query'; + const optionsKey = newRule.options ? 'options' : newRule.query && 'query'; delete rule.use; delete rule.loaders; @@ -74,8 +68,7 @@ function uniteRules(rules, key, newRule, rule) { (rule.use || rule.loaders || rule.loader) && (newRule.use || newRule.loaders) ) { - const expandEntry = loader => - typeof loader === 'string' ? { loader } : loader; + const expandEntry = loader => (typeof loader === 'string' ? { loader } : loader); // this is only here to avoid breaking existing tests const unwrapEntry = entry => !entry.options && !entry.query ? entry.loader : entry; @@ -97,9 +90,7 @@ function uniteRules(rules, key, newRule, rule) { } else { entries = [].concat(rule.use || rule.loaders).map(expandEntry); } - const newEntries = [] - .concat(newRule.use || newRule.loaders) - .map(expandEntry); + const newEntries = [].concat(newRule.use || newRule.loaders).map(expandEntry); const loadersKey = rule.use || newRule.use ? 'use' : 'loaders'; const resolvedKey = `${key}.${loadersKey}`; @@ -115,9 +106,7 @@ function uniteRules(rules, key, newRule, rule) { rule[loadersKey] = newRule.use || newRule.loaders; break; default: - rule[loadersKey] = combineEntries(newEntries, entries).map( - unwrapEntry - ); + rule[loadersKey] = combineEntries(newEntries, entries).map(unwrapEntry); } } @@ -185,8 +174,7 @@ function combineEntries(newEntries, existingEntries) { areEqualEntries, existingEntriesIteratorIndex ); - const hasEquivalentEntryInExistingEntries = - indexInExistingEntries !== -1; + const hasEquivalentEntryInExistingEntries = indexInExistingEntries !== -1; if (hasEquivalentEntryInExistingEntries) { // If the same entry exists in existing entries, we should add all of the entries that @@ -215,10 +203,7 @@ function combineEntries(newEntries, existingEntries) { existingEntriesIteratorIndex -= 1; } - uniteEntries( - currentEntry, - existingEntries[existingEntriesIteratorIndex] - ); + uniteEntries(currentEntry, existingEntries[existingEntriesIteratorIndex]); // uniteEntries mutates the second parameter to be a merged version, so that's what's pushed resultSet.unshift(existingEntries[existingEntriesIteratorIndex]); @@ -245,11 +230,8 @@ function combineEntries(newEntries, existingEntries) { ) { const existingEntry = existingEntries[existingEntriesIteratorIndex]; const alreadyHasMatchingEntryInResultSet = - findLastIndexUsingComparinator( - resultSet, - existingEntry, - areEqualEntries - ) !== -1; + findLastIndexUsingComparinator(resultSet, existingEntry, areEqualEntries) !== + -1; if (!alreadyHasMatchingEntryInResultSet) { resultSet.unshift(existingEntry); diff --git a/src/builder/WebpackConfig.js b/src/builder/WebpackConfig.js index a4a94c2cb..46a3624a0 100644 --- a/src/builder/WebpackConfig.js +++ b/src/builder/WebpackConfig.js @@ -129,7 +129,7 @@ class WebpackConfig { * @param {{app: import("express").Application}} param0 */ onBeforeSetupMiddleware({ app }) { - app.use(function(req, _, next) { + app.use(function (req, _, next) { // Something causes hot update chunks (except for the JSON payload) // to start with a double slash // e.g. GET http://localhost:8080//js/app.[hash].hot-update.js diff --git a/src/builder/webpack-default.js b/src/builder/webpack-default.js index cd3de2522..d2efdee19 100644 --- a/src/builder/webpack-default.js +++ b/src/builder/webpack-default.js @@ -1,7 +1,7 @@ let path = require('path'); let TerserPlugin = require('terser-webpack-plugin'); -module.exports = function() { +module.exports = function () { return { context: Mix.paths.root(), diff --git a/src/builder/webpack-plugins.js b/src/builder/webpack-plugins.js index 0065bcd76..ca30f1ef0 100644 --- a/src/builder/webpack-plugins.js +++ b/src/builder/webpack-plugins.js @@ -5,7 +5,7 @@ let ManifestPlugin = require('../webpackPlugins/ManifestPlugin'); let MockEntryPlugin = require('../webpackPlugins/MockEntryPlugin'); let BuildOutputPlugin = require('../webpackPlugins/BuildOutputPlugin'); -module.exports = function() { +module.exports = function () { let plugins = []; // If the user didn't declare any JS compilation, we still need to diff --git a/src/builder/webpack-rules.js b/src/builder/webpack-rules.js index 71f93f3d1..bc78229de 100644 --- a/src/builder/webpack-rules.js +++ b/src/builder/webpack-rules.js @@ -1,4 +1,4 @@ -module.exports = function() { +module.exports = function () { let rules = []; // Add support for loading HTML files. diff --git a/src/components/Autoload.js b/src/components/Autoload.js index 917f2d18b..f9acdd547 100644 --- a/src/components/Autoload.js +++ b/src/components/Autoload.js @@ -10,9 +10,7 @@ class Autoload { Object.keys(libs).forEach(library => { [].concat(libs[library]).forEach(alias => { - aliases[alias] = library.includes('.') - ? library.split('.') - : library; + aliases[alias] = library.includes('.') ? library.split('.') : library; }); }); diff --git a/src/components/BrowserSync.js b/src/components/BrowserSync.js index 70c643920..81419447a 100644 --- a/src/components/BrowserSync.js +++ b/src/components/BrowserSync.js @@ -52,7 +52,7 @@ class BrowserSync { snippetOptions: { rule: { match: this.regex(), - fn: function(snippet, match) { + fn: function (snippet, match) { return snippet + match; } } diff --git a/src/components/DumpWebpackConfig.js b/src/components/DumpWebpackConfig.js index e4c3b7c9f..2cc7e4949 100644 --- a/src/components/DumpWebpackConfig.js +++ b/src/components/DumpWebpackConfig.js @@ -13,7 +13,7 @@ class DumpWebpackConfig { */ register() { Mix.listen('configReadyForUser', config => { - RegExp.prototype.toJSON = function() { + RegExp.prototype.toJSON = function () { return this.toString(); }; diff --git a/src/components/Less.js b/src/components/Less.js index 66831fa2b..97b89e8e3 100644 --- a/src/components/Less.js +++ b/src/components/Less.js @@ -17,13 +17,7 @@ class Less extends Preprocessor { * @param {Array} postCssPlugins */ register(src, output, pluginOptions = {}, postCssPlugins = []) { - return this.preprocess( - 'less', - src, - output, - pluginOptions, - postCssPlugins - ); + return this.preprocess('less', src, output, pluginOptions, postCssPlugins); } chunkRegex() { diff --git a/src/components/Stylus.js b/src/components/Stylus.js index 858152672..919a7fcd9 100644 --- a/src/components/Stylus.js +++ b/src/components/Stylus.js @@ -17,13 +17,7 @@ class Stylus extends Preprocessor { * @param {Array} postCssPlugins */ register(src, output, pluginOptions = {}, postCssPlugins = []) { - return this.preprocess( - 'stylus', - src, - output, - pluginOptions, - postCssPlugins - ); + return this.preprocess('stylus', src, output, pluginOptions, postCssPlugins); } chunkRegex() { diff --git a/src/components/Version.js b/src/components/Version.js index 3a88a9936..df1e9b25f 100644 --- a/src/components/Version.js +++ b/src/components/Version.js @@ -19,10 +19,9 @@ class Version { if (!filePath.includes('*')) return filePath; - return glob.sync( - new File(filePath).forceFromPublic().relativePath(), - { nodir: true } - ); + return glob.sync(new File(filePath).forceFromPublic().relativePath(), { + nodir: true + }); }) ); diff --git a/src/config.js b/src/config.js index 9f7aa111e..071a6979e 100644 --- a/src/config.js +++ b/src/config.js @@ -1,6 +1,6 @@ const argv = require('yargs').argv; -module.exports = function() { +module.exports = function () { return { /** * Determine if webpack should be triggered in a production environment. @@ -112,7 +112,7 @@ module.exports = function() { * * @type {String} babelRcPath */ - babel: function(babelRcPath) { + babel: function (babelRcPath) { babelRcPath = babelRcPath || Mix.paths.root('.babelrc'); return require('./BabelConfig').generate(this.babelConfig, babelRcPath); diff --git a/src/helpers.js b/src/helpers.js index 1eac0aaa7..700f7e6db 100644 --- a/src/helpers.js +++ b/src/helpers.js @@ -6,7 +6,7 @@ let objectValues = require('lodash').values; * @param {*} val * @param {Function} callback */ -global.tap = function(val, callback) { +global.tap = function (val, callback) { callback(val); return val; @@ -19,7 +19,7 @@ global.tap = function(val, callback) { * @param {Function} callback */ Object.defineProperty(Array.prototype, 'tap', { - value: function(callback) { + value: function (callback) { if (this.length) { callback(this); } @@ -49,6 +49,6 @@ Object.defineProperty(Array, 'wrap', { * * @param {Array} arr */ -global.flatten = function(arr) { +global.flatten = function (arr) { return [].concat.apply([], objectValues(arr)); }; diff --git a/src/tasks/CopyFilesTask.js b/src/tasks/CopyFilesTask.js index caa79bd74..f369f289a 100644 --- a/src/tasks/CopyFilesTask.js +++ b/src/tasks/CopyFilesTask.js @@ -28,14 +28,9 @@ class CopyFilesTask extends Task { // If we're copying a src directory recursively, we have to calculate // the correct destination path, based on the src directory tree. - if ( - !Array.isArray(this.data.from) && - new File(this.data.from).isDirectory() - ) { + if (!Array.isArray(this.data.from) && new File(this.data.from).isDirectory()) { destination = destination.append( - path - .normalize(updatedFile) - .replace(path.normalize(this.data.from), '') + path.normalize(updatedFile).replace(path.normalize(this.data.from), '') ); } diff --git a/src/webpackPlugins/Css/AppendVueStylesPlugin.js b/src/webpackPlugins/Css/AppendVueStylesPlugin.js index 2db16e0e6..f489e4e53 100644 --- a/src/webpackPlugins/Css/AppendVueStylesPlugin.js +++ b/src/webpackPlugins/Css/AppendVueStylesPlugin.js @@ -28,10 +28,7 @@ class AppendVueStylesPlugin { let largestIndex = 0; for (const { module, group } of queue) { - largestIndex = Math.max( - largestIndex, - group.getModulePostOrderIndex(module) - ); + largestIndex = Math.max(largestIndex, group.getModulePostOrderIndex(module)); } // Push all vue assets after it in their original order diff --git a/src/webpackPlugins/ManifestPlugin.js b/src/webpackPlugins/ManifestPlugin.js index f81d74cea..998fa140b 100644 --- a/src/webpackPlugins/ManifestPlugin.js +++ b/src/webpackPlugins/ManifestPlugin.js @@ -5,17 +5,14 @@ class ManifestPlugin { * @param {import("webpack").Compiler} compiler */ apply(compiler) { - compiler.hooks.emit.tapAsync( - 'ManifestPlugin', - (curCompiler, callback) => { - let stats = curCompiler.getStats().toJson(); + compiler.hooks.emit.tapAsync('ManifestPlugin', (curCompiler, callback) => { + let stats = curCompiler.getStats().toJson(); - // Handle the creation of the mix-manifest.json file. - Mix.manifest.transform(stats).refresh(); + // Handle the creation of the mix-manifest.json file. + Mix.manifest.transform(stats).refresh(); - callback(); - } - ); + callback(); + }); } } diff --git a/src/webpackPlugins/MixDefinitionsPlugin.js b/src/webpackPlugins/MixDefinitionsPlugin.js index e192f191a..6821a091d 100644 --- a/src/webpackPlugins/MixDefinitionsPlugin.js +++ b/src/webpackPlugins/MixDefinitionsPlugin.js @@ -20,10 +20,8 @@ function MixDefinitionsPlugin(envPath) { * * @param {Object|null} merge */ -MixDefinitionsPlugin.build = function(merge = {}) { - return new webpack.DefinePlugin( - new MixDefinitionsPlugin().getDefinitions(merge) - ); +MixDefinitionsPlugin.build = function (merge = {}) { + return new webpack.DefinePlugin(new MixDefinitionsPlugin().getDefinitions(merge)); }; /** @@ -31,7 +29,7 @@ MixDefinitionsPlugin.build = function(merge = {}) { * * @param {object} merge */ -MixDefinitionsPlugin.prototype.getDefinitions = function(merge) { +MixDefinitionsPlugin.prototype.getDefinitions = function (merge) { let regex = /^MIX_/i; // Filter out env vars that don't begin with MIX_. diff --git a/test/features/babel.js b/test/features/babel.js index 7866e93b2..1884ed75b 100644 --- a/test/features/babel.js +++ b/test/features/babel.js @@ -62,13 +62,13 @@ test('Values from duplicate keys in the .babelrc file override the defaults enti test('Babel config from Mix extensions is merged with the defaults', async t => { mix.extend( 'extensionWithBabelConfig', - new class { + new (class { babelConfig() { return { plugins: ['@babel/plugin-proposal-unicode-property-regex'] }; } - }() + })() ); mix.extensionWithBabelConfig(); diff --git a/test/features/browsersync.js b/test/features/browsersync.js index d49be3d1a..64c06e6fd 100644 --- a/test/features/browsersync.js +++ b/test/features/browsersync.js @@ -20,9 +20,7 @@ test('it handles Browsersync reloading', async t => { let { config } = await webpack.compile(); t.truthy( - config.plugins.find( - plugin => plugin.constructor.name === 'BrowserSyncPluginStub' - ) + config.plugins.find(plugin => plugin.constructor.name === 'BrowserSyncPluginStub') ); }); @@ -64,11 +62,7 @@ test('it configures Browsersync server', t => { let config = browserSyncConfig({ server: './app' }); t.is(config.server, './app', 'sets server from user Browsersync config'); - t.is( - config.proxy, - undefined, - 'does not set default proxy when using server' - ); + t.is(config.proxy, undefined, 'does not set default proxy when using server'); }); let browserSyncConfig = userConfig => { diff --git a/test/features/combine.js b/test/features/combine.js index 2f06407d2..9b6a1580c 100644 --- a/test/features/combine.js +++ b/test/features/combine.js @@ -57,10 +57,7 @@ test('it compiles JS and then combines the bundles files.', async t => { mix.js(`test/fixtures/app/src/js/app.js`, 'js') .js(`test/fixtures/app/src/js/another.js`, 'js') .scripts( - [ - `test/fixtures/app/dist/js/app.js`, - `test/fixtures/app/dist/js/another.js` - ], + [`test/fixtures/app/dist/js/app.js`, `test/fixtures/app/dist/js/another.js`], `test/fixtures/app/dist/js/all.js` ); @@ -89,10 +86,7 @@ test('it concatenates a directory of files, copies the output to a new location, 'test/fixtures/app/dist/output/combined-scripts.js' ); - mix.copyDirectory( - 'test/fixtures/app/dist/output', - 'test/fixtures/app/dist/js' - ); + mix.copyDirectory('test/fixtures/app/dist/output', 'test/fixtures/app/dist/js'); await webpack.compile(); diff --git a/test/features/extraction.js b/test/features/extraction.js index 71c4b8a43..9fd1ab653 100644 --- a/test/features/extraction.js +++ b/test/features/extraction.js @@ -50,9 +50,7 @@ test('JS compilation with vendor extraction with default config', async t => { }); test('JS compilation with total vendor extraction', async t => { - mix.js(`test/fixtures/app/src/extract/app.js`, 'js') - .vue({ version: 2 }) - .extract(); + mix.js(`test/fixtures/app/src/extract/app.js`, 'js').vue({ version: 2 }).extract(); await webpack.compile(); diff --git a/test/features/plugins.js b/test/features/plugins.js index 64cb49253..f346a016d 100644 --- a/test/features/plugins.js +++ b/test/features/plugins.js @@ -21,11 +21,11 @@ test('mix can be extended with new functionality as a callback', async t => { test('mix can be extended with new functionality as a class', t => { mix.extend( 'foobar', - new class { + new (class { register(val) { t.is('baz', val); } - }() + })() ); mix.foobar('baz'); @@ -38,13 +38,13 @@ test('dependencies can be requested for download', t => { mix.extend( 'foobar', - new class { + new (class { dependencies() { return ['npm-package']; } register() {} - }() + })() ); mix.foobar(); @@ -57,13 +57,13 @@ test('dependencies can be requested for download', t => { test('webpack entry may be appended to', async t => { mix.extend( 'foobar', - new class { + new (class { register() {} webpackEntry(entry) { entry.add('foo', 'path'); } - }() + })() ); mix.foobar(); @@ -83,13 +83,13 @@ test('webpack rules may be added', async t => { mix.extend( 'foobar', - new class { + new (class { register() {} webpackRules() { return rule; } - }() + })() ); mix.foobar(); @@ -106,13 +106,13 @@ test('webpack plugins may be added', async t => { mix.extend( 'foobar', - new class { + new (class { register() {} webpackPlugins() { return plugin; } - }() + })() ); mix.foobar(); @@ -127,13 +127,13 @@ test('webpack plugins may be added', async t => { test('custom Babel config may be merged', async t => { mix.extend( 'reactNext', - new class { + new (class { babelConfig() { return { plugins: ['@babel/plugin-proposal-unicode-property-regex'] }; } - }() + })() ); mix.reactNext(); @@ -152,13 +152,13 @@ test('custom Babel config may be merged', async t => { test('the fully constructed webpack config object is available for modification, if needed', async t => { mix.extend( 'extension', - new class { + new (class { register() {} webpackConfig(config) { config.stats.performance = true; } - }() + })() ); t.false((await new WebpackConfig().build()).stats.performance); @@ -192,17 +192,17 @@ test('prior Mix components can be overwritten', t => { test('components can be passive', t => { let stub = sinon.spy(); - let component = new class { + let component = new (class { register() { stub(); } - }(); + })(); mix.extend('example', component); t.true(stub.notCalled); - component = new class { + component = new (class { constructor() { this.passive = true; } @@ -210,7 +210,7 @@ test('components can be passive', t => { register() { stub(); } - }(); + })(); mix.extend('example', component); @@ -218,7 +218,7 @@ test('components can be passive', t => { }); test('components can manually hook into the mix API', t => { - let component = new class { + let component = new (class { mix() { return { foo: arg => { @@ -230,7 +230,7 @@ test('components can manually hook into the mix API', t => { } }; } - }(); + })(); mix.extend('example', component); @@ -241,11 +241,11 @@ test('components can manually hook into the mix API', t => { test('components can be booted, after the webpack.mix.js configuration file has processed', async t => { let stub = sinon.spy(); - let component = new class { + let component = new (class { boot() { stub(); } - }(); + })(); mix.extend('example', component); diff --git a/test/features/vue.js b/test/features/vue.js index 121b401ae..708288f91 100644 --- a/test/features/vue.js +++ b/test/features/vue.js @@ -311,9 +311,7 @@ test('it supports global Vue styles for sass', async t => { t.is( expected.trim(), - File.find(`test/fixtures/app/dist/css/components.css`) - .read() - .trim() + File.find(`test/fixtures/app/dist/css/components.css`).read().trim() ); postCssConfigFile.delete(); diff --git a/test/features/vue3.js b/test/features/vue3.js index 3145212ac..5a779b938 100644 --- a/test/features/vue3.js +++ b/test/features/vue3.js @@ -306,9 +306,7 @@ test('it supports global Vue styles for sass', async t => { t.is( expected.trim(), - File.find(`test/fixtures/app/dist/css/components.css`) - .read() - .trim() + File.find(`test/fixtures/app/dist/css/components.css`).read().trim() ); postCssConfigFile.delete(); diff --git a/test/fixtures/app/src/dynamic/dynamic.js b/test/fixtures/app/src/dynamic/dynamic.js index 23d50715a..ec66590aa 100644 --- a/test/fixtures/app/src/dynamic/dynamic.js +++ b/test/fixtures/app/src/dynamic/dynamic.js @@ -2,6 +2,6 @@ import('./dynamic-module').then(module => module.default.init()); import(/* webpackChunkName: 'named' */ './dynamic-module-named').then(module => module.default.init() ); -import(/* webpackChunkName: '/js/absolute' */ './dynamic-module-absolute').then( - module => module.default.init() +import(/* webpackChunkName: '/js/absolute' */ './dynamic-module-absolute').then(module => + module.default.init() ); diff --git a/test/fixtures/app/src/extract/VueSplit.vue b/test/fixtures/app/src/extract/VueSplit.vue index c447f8cf3..b3f9f067d 100644 --- a/test/fixtures/app/src/extract/VueSplit.vue +++ b/test/fixtures/app/src/extract/VueSplit.vue @@ -8,8 +8,7 @@ diff --git a/test/fixtures/app/src/vue3/SeparateFiles.vue b/test/fixtures/app/src/vue3/SeparateFiles.vue index 32b8fc172..65d271b58 100644 --- a/test/fixtures/app/src/vue3/SeparateFiles.vue +++ b/test/fixtures/app/src/vue3/SeparateFiles.vue @@ -1,2 +1,3 @@ - + + diff --git a/test/fixtures/integration/src/js/dynamic.js b/test/fixtures/integration/src/js/dynamic.js index a78b02bc3..9bfff446c 100644 --- a/test/fixtures/integration/src/js/dynamic.js +++ b/test/fixtures/integration/src/js/dynamic.js @@ -1,5 +1,5 @@ console.log('loaded: dynamic.js'); -export default function() { +export default function () { console.log('run: dynamic.js'); } diff --git a/test/helpers/assertions.js b/test/helpers/assertions.js index 50a227c2c..951c1243e 100644 --- a/test/helpers/assertions.js +++ b/test/helpers/assertions.js @@ -40,12 +40,7 @@ export default { * @param {import("ava").Assertions} t */ fileNotEmpty: (path, t) => { - t.not( - File.find(path) - .read() - .replace(/\s/g, ''), - '' - ); + t.not(File.find(path).read().replace(/\s/g, ''), ''); }, /** @@ -56,12 +51,7 @@ export default { * @param {import("ava").Assertions} t */ fileMatchesCss: (path, expected, t) => { - t.is( - File.find(path) - .read() - .replace(/\s/g, ''), - expected.replace(/\s/g, '') - ); + t.is(File.find(path).read().replace(/\s/g, ''), expected.replace(/\s/g, '')); }, /** diff --git a/test/helpers/cli.js b/test/helpers/cli.js index 55edb4bb4..2f651f752 100644 --- a/test/helpers/cli.js +++ b/test/helpers/cli.js @@ -21,7 +21,7 @@ export function cli(opts) { * * @param {string[]} args */ - return async function(args = []) { + return async function (args = []) { let cmd = [ `cross-env`, testing ? 'TESTING=1' : '', diff --git a/test/integration/plugins/MixDefinitionsPlugin.js b/test/integration/plugins/MixDefinitionsPlugin.js index ee6e86c46..12b126acf 100644 --- a/test/integration/plugins/MixDefinitionsPlugin.js +++ b/test/integration/plugins/MixDefinitionsPlugin.js @@ -3,9 +3,7 @@ import MixDefinitionsPlugin from '../../../src/webpackPlugins/MixDefinitionsPlug import path from 'path'; test('it fetches the MIX_ definitions properly', t => { - let plugin = new MixDefinitionsPlugin( - path.resolve(__dirname, 'testing.env') - ); + let plugin = new MixDefinitionsPlugin(path.resolve(__dirname, 'testing.env')); let MIX_TESTING = '"123"'; let NODE_ENV = '"production"'; diff --git a/test/unit/FileCollection.js b/test/unit/FileCollection.js index bccd53a79..06633ac52 100644 --- a/test/unit/FileCollection.js +++ b/test/unit/FileCollection.js @@ -23,10 +23,7 @@ test('that it can get the underlying files', t => { }); test.cb('that it can merge multiple files into one.', t => { - let files = [ - path.resolve(stubsDir, 'one.js'), - path.resolve(stubsDir, 'two.js') - ]; + let files = [path.resolve(stubsDir, 'one.js'), path.resolve(stubsDir, 'two.js')]; new File(files[0]).write('class Foo {}'); new File(files[1]).write('class Bar {}'); @@ -41,10 +38,7 @@ test.cb('that it can merge multiple files into one.', t => { }); test.cb('that it can merge JS files and apply Babel compilation.', t => { - let files = [ - path.resolve(stubsDir, 'one.js'), - path.resolve(stubsDir, 'two.js') - ]; + let files = [path.resolve(stubsDir, 'one.js'), path.resolve(stubsDir, 'two.js')]; new File(files[0]).write('class Foo {}'); new File(files[1]).write('class Bar {}'); diff --git a/test/unit/Manifest.js b/test/unit/Manifest.js index 77d6fb44b..08747b3a5 100644 --- a/test/unit/Manifest.js +++ b/test/unit/Manifest.js @@ -43,19 +43,14 @@ test('it can get the underlying manifest object', t => { }); test('it knows the path to the underlying file', t => { - t.is( - path.join(Config.publicPath, 'mix-manifest.json'), - Mix.manifest.path() - ); + t.is(path.join(Config.publicPath, 'mix-manifest.json'), Mix.manifest.path()); }); test('it can be refreshed', t => { mix.setPublicPath(__dirname); new File(Mix.manifest.path()).write('{}'); - new File(path.resolve(__dirname, 'js/app.js')) - .makeDirectories() - .write('var foo;'); + new File(path.resolve(__dirname, 'js/app.js')).makeDirectories().write('var foo;'); // The initial state of the manifest file should be an empty object. t.deepEqual({}, Mix.manifest.read()); diff --git a/test/unit/Mix.js b/test/unit/Mix.js index a8c74652d..231ea7024 100644 --- a/test/unit/Mix.js +++ b/test/unit/Mix.js @@ -58,9 +58,9 @@ test('that it can add a task', t => { }); test('that it can fetch a registered component', t => { - let component = new class { + let component = new (class { register() {} - }(); + })(); mix.extend('foo', component); diff --git a/types/extract.d.ts b/types/extract.d.ts index 8635350c9..e01477e80 100644 --- a/types/extract.d.ts +++ b/types/extract.d.ts @@ -6,7 +6,7 @@ import * as webpack from 'webpack'; * Specify a custom extraction test * Equivalent to providing a function to webpack's split chunks */ -export type ExtractTestCallback = ((module: webpack.Module, context: any) => boolean); +export type ExtractTestCallback = (module: webpack.Module, context: any) => boolean; /** * Specify a custom extraction test