Make code prettier

This updates ESLint and our shared eslint-config-openlayers to use Prettier.  Most formatting changes were automatically applied with this:

    npm run lint -- --fix

A few manual changes were required:

 * In `examples/offscreen-canvas.js`, the `//eslint-disable-line` comment needed to be moved to the appropriate line to disable the error about the `'worker-loader!./offscreen-canvas.worker.js'` import.
 * In `examples/webpack/exapmle-builder.js`, spaces could not be added after a couple `function`s for some reason.  While editing this, I reworked `ExampleBuilder` to be a class.
 * In `src/ol/format/WMSGetFeatureInfo.js`, the `// @ts-ignore` comment needed to be moved down one line so it applied to the `parsersNS` argument.
This commit is contained in:
Tim Schaub
2020-04-06 12:25:12 -06:00
parent 53b48baf62
commit 054af09032
790 changed files with 46833 additions and 33765 deletions

View File

@@ -6,12 +6,13 @@ const path = require('path');
const src = path.join(__dirname, '..');
const examples = fs.readdirSync(src)
.filter(name => /^(?!index).*\.html$/.test(name))
.map(name => name.replace(/\.html$/, ''));
const examples = fs
.readdirSync(src)
.filter((name) => /^(?!index).*\.html$/.test(name))
.map((name) => name.replace(/\.html$/, ''));
const entry = {};
examples.forEach(example => {
examples.forEach((example) => {
entry[example] = `./${example}.js`;
});
@@ -21,67 +22,68 @@ module.exports = {
entry: entry,
stats: 'minimal',
module: {
rules: [{
test: /^((?!es2015-)[\s\S])*\.js$/,
use: {
loader: 'buble-loader'
rules: [
{
test: /^((?!es2015-)[\s\S])*\.js$/,
use: {
loader: 'buble-loader',
},
include: [
path.join(__dirname, '..', '..', 'src'),
path.join(__dirname, '..'),
],
},
include: [
path.join(__dirname, '..', '..', 'src'),
path.join(__dirname, '..')
]
}, {
test: /\.js$/,
use: {
loader: path.join(__dirname, './worker-loader.js')
{
test: /\.js$/,
use: {
loader: path.join(__dirname, './worker-loader.js'),
},
include: [path.join(__dirname, '../../src/ol/worker')],
},
include: [
path.join(__dirname, '../../src/ol/worker')
]
}]
],
},
optimization: {
minimizer: [
new TerserPlugin({
sourceMap: true,
// Do not minify examples that inject code into workers
exclude: [/(color-manipulation|region-growing|raster)\.js/]
})
exclude: [/(color-manipulation|region-growing|raster)\.js/],
}),
],
runtimeChunk: {
name: 'common'
name: 'common',
},
splitChunks: {
name: 'common',
chunks: 'initial',
minChunks: 2
}
minChunks: 2,
},
},
plugins: [
new ExampleBuilder({
templates: path.join(__dirname, '..', 'templates'),
common: 'common'
common: 'common',
}),
new CopyPlugin([
{from: '../src/ol/ol.css', to: 'css'},
{from: 'data', to: 'data'},
{from: 'resources', to: 'resources'},
{from: 'Jugl.js', to: 'Jugl.js'},
{from: 'index.html', to: 'index.html'}
])
{from: 'index.html', to: 'index.html'},
]),
],
devtool: 'source-map',
output: {
filename: '[name].js',
path: path.join(__dirname, '..', '..', 'build', 'examples')
path: path.join(__dirname, '..', '..', 'build', 'examples'),
},
node: {
fs: 'empty' // required by ol-mapbox-stlye
fs: 'empty', // required by ol-mapbox-stlye
},
resolve: {
alias: {
// allow imports from 'ol/module' instead of specifiying the source path
ol: path.join(__dirname, '..', '..', 'src', 'ol')
}
}
ol: path.join(__dirname, '..', '..', 'src', 'ol'),
},
},
};