[build] upgrade eslint to 9.37.0 (#88)
Co-authored-by: tobi <tobi.smethurst@protonmail.com> Reviewed-on: https://codeberg.org/superseriousbusiness/masto-fe-standalone/pulls/88 Co-authored-by: Zoë Bijl <moiety@noreply.codeberg.org> Co-committed-by: Zoë Bijl <moiety@noreply.codeberg.org>
This commit is contained in:
@@ -1,21 +1,21 @@
|
||||
// Common configuration for webpacker loaded from config/webpacker.yml
|
||||
|
||||
const { lstatSync, readFileSync } = require('fs');
|
||||
const { basename, dirname, extname, join, resolve } = require('path');
|
||||
const { env } = require('process');
|
||||
const { lstatSync, readFileSync } = require("fs");
|
||||
const { basename, dirname, extname, join, resolve } = require("path");
|
||||
const { env } = require("process");
|
||||
|
||||
const glob = require('glob');
|
||||
const { load } = require('js-yaml');
|
||||
const glob = require("glob");
|
||||
const { load } = require("js-yaml");
|
||||
|
||||
const configPath = resolve('config', 'webpacker.yml');
|
||||
const settings = load(readFileSync(configPath), 'utf8')[env.RAILS_ENV || env.NODE_ENV];
|
||||
const flavourFiles = glob.sync('app/javascript/flavours/*/theme.yml');
|
||||
const skinFiles = glob.sync('app/javascript/skins/*/*');
|
||||
const configPath = resolve("config", "webpacker.yml");
|
||||
const settings = load(readFileSync(configPath), "utf8")[env.RAILS_ENV || env.NODE_ENV];
|
||||
const flavourFiles = glob.sync("app/javascript/flavours/*/theme.yml");
|
||||
const skinFiles = glob.sync("app/javascript/skins/*/*");
|
||||
const flavours = {};
|
||||
|
||||
const core = function () {
|
||||
const coreFile = resolve('app', 'javascript', 'core', 'theme.yml');
|
||||
const data = load(readFileSync(coreFile), 'utf8');
|
||||
const coreFile = resolve("app", "javascript", "core", "theme.yml");
|
||||
const data = load(readFileSync(coreFile), "utf8");
|
||||
if (!data.pack_directory) {
|
||||
data.pack_directory = dirname(coreFile);
|
||||
}
|
||||
@@ -23,7 +23,7 @@ const core = function () {
|
||||
}();
|
||||
|
||||
flavourFiles.forEach((flavourFile) => {
|
||||
const data = load(readFileSync(flavourFile), 'utf8');
|
||||
const data = load(readFileSync(flavourFile), "utf8");
|
||||
data.name = basename(dirname(flavourFile));
|
||||
data.skin = {};
|
||||
if (!data.pack_directory) {
|
||||
@@ -32,7 +32,7 @@ flavourFiles.forEach((flavourFile) => {
|
||||
if (data.locales) {
|
||||
data.locales = join(dirname(flavourFile), data.locales);
|
||||
}
|
||||
if (data.pack && typeof data.pack === 'object') {
|
||||
if (data.pack && typeof data.pack === "object") {
|
||||
flavours[data.name] = data;
|
||||
}
|
||||
});
|
||||
@@ -46,7 +46,7 @@ skinFiles.forEach((skinFile) => {
|
||||
const data = flavours[name].skin;
|
||||
if (lstatSync(skinFile).isDirectory()) {
|
||||
data[skin] = {};
|
||||
const skinPacks = glob.sync(join(skinFile, '*.{css,scss}'));
|
||||
const skinPacks = glob.sync(join(skinFile, "*.{css,scss}"));
|
||||
skinPacks.forEach((pack) => {
|
||||
data[skin][basename(pack, extname(pack))] = pack;
|
||||
});
|
||||
@@ -56,7 +56,7 @@ skinFiles.forEach((skinFile) => {
|
||||
});
|
||||
|
||||
const output = {
|
||||
path: resolve('public', settings.public_output_path),
|
||||
path: resolve("public", settings.public_output_path),
|
||||
publicPath: `/${settings.public_output_path}/`,
|
||||
};
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
// Note: You must restart bin/webpack-dev-server for changes to take effect
|
||||
|
||||
const { merge } = require('webpack-merge');
|
||||
const { merge } = require("webpack-merge");
|
||||
|
||||
const { settings, output } = require('./configuration');
|
||||
const sharedConfig = require('./shared');
|
||||
const { settings, output } = require("./configuration");
|
||||
const sharedConfig = require("./shared");
|
||||
|
||||
const watchOptions = {};
|
||||
|
||||
@@ -15,9 +15,9 @@ if (process.env.VAGRANT) {
|
||||
}
|
||||
|
||||
module.exports = merge(sharedConfig, {
|
||||
mode: 'development',
|
||||
mode: "development",
|
||||
cache: true,
|
||||
devtool: 'eval-cheap-module-source-map',
|
||||
devtool: "eval-cheap-module-source-map",
|
||||
|
||||
stats: {
|
||||
errorDetails: true,
|
||||
@@ -38,7 +38,7 @@ module.exports = merge(sharedConfig, {
|
||||
},
|
||||
headers: settings.dev_server.headers,
|
||||
client: {
|
||||
logging: 'none',
|
||||
logging: "none",
|
||||
overlay: settings.dev_server.overlay,
|
||||
},
|
||||
static: {
|
||||
@@ -58,7 +58,7 @@ module.exports = merge(sharedConfig, {
|
||||
modules: false,
|
||||
moduleTrace: false,
|
||||
},
|
||||
writeToDisk: filePath => /ocr/.test(filePath)
|
||||
}
|
||||
writeToDisk: filePath => /ocr/.test(filePath),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
@@ -1,23 +1,23 @@
|
||||
// Note: You must restart bin/webpack-dev-server for changes to take effect
|
||||
|
||||
const { createHash } = require('crypto');
|
||||
const { readFileSync } = require('fs');
|
||||
const { resolve } = require('path');
|
||||
const { createHash } = require("crypto");
|
||||
const { readFileSync } = require("fs");
|
||||
const { resolve } = require("path");
|
||||
|
||||
const CompressionPlugin = require('@renchap/compression-webpack-plugin');
|
||||
const TerserPlugin = require('terser-webpack-plugin');
|
||||
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
|
||||
const { merge } = require('webpack-merge');
|
||||
const { InjectManifest } = require('workbox-webpack-plugin');
|
||||
const CompressionPlugin = require("@renchap/compression-webpack-plugin");
|
||||
const TerserPlugin = require("terser-webpack-plugin");
|
||||
const { BundleAnalyzerPlugin } = require("webpack-bundle-analyzer");
|
||||
const { merge } = require("webpack-merge");
|
||||
const { InjectManifest } = require("workbox-webpack-plugin");
|
||||
|
||||
const sharedConfig = require('./shared');
|
||||
const sharedConfig = require("./shared");
|
||||
|
||||
const root = resolve(__dirname, '..', '..');
|
||||
const root = resolve(__dirname, "..", "..");
|
||||
|
||||
module.exports = merge(sharedConfig, {
|
||||
mode: 'production',
|
||||
devtool: 'source-map',
|
||||
stats: 'normal',
|
||||
mode: "production",
|
||||
devtool: "source-map",
|
||||
stats: "normal",
|
||||
bail: true,
|
||||
optimization: {
|
||||
minimize: true,
|
||||
@@ -30,31 +30,31 @@ module.exports = merge(sharedConfig, {
|
||||
|
||||
plugins: [
|
||||
new CompressionPlugin({
|
||||
filename: '[path][base].gz[query]',
|
||||
filename: "[path][base].gz[query]",
|
||||
cache: true,
|
||||
test: /\.(js|css|html|json|ico|svg|eot|otf|ttf|map)$/,
|
||||
}),
|
||||
new CompressionPlugin({
|
||||
filename: '[path][base].br[query]',
|
||||
algorithm: 'brotliCompress',
|
||||
filename: "[path][base].br[query]",
|
||||
algorithm: "brotliCompress",
|
||||
cache: true,
|
||||
test: /\.(js|css|html|json|ico|svg|eot|otf|ttf|map)$/,
|
||||
}),
|
||||
new BundleAnalyzerPlugin({ // generates report.html
|
||||
analyzerMode: 'static',
|
||||
analyzerMode: "static",
|
||||
openAnalyzer: false,
|
||||
logLevel: 'silent', // do not bother Webpacker, who runs with --json and parses stdout
|
||||
logLevel: "silent", // do not bother Webpacker, who runs with --json and parses stdout
|
||||
}),
|
||||
new InjectManifest({
|
||||
additionalManifestEntries: ['1f602.svg', 'sheet_13.png'].map((filename) => {
|
||||
const path = resolve(root, 'public', 'emoji', filename);
|
||||
additionalManifestEntries: ["1f602.svg", "sheet_13.png"].map((filename) => {
|
||||
const path = resolve(root, "public", "emoji", filename);
|
||||
const body = readFileSync(path);
|
||||
const md5 = createHash('md5');
|
||||
const md5 = createHash("md5");
|
||||
|
||||
md5.update(body);
|
||||
|
||||
return {
|
||||
revision: md5.digest('hex'),
|
||||
revision: md5.digest("hex"),
|
||||
url: `/emoji/${filename}`,
|
||||
};
|
||||
}),
|
||||
@@ -65,8 +65,8 @@ module.exports = merge(sharedConfig, {
|
||||
],
|
||||
include: [/\.js$/, /\.css$/],
|
||||
maximumFileSizeToCacheInBytes: 2 * 1_024 * 1_024, // 2 MiB
|
||||
swDest: resolve(root, 'public', 'packs', 'sw.js'),
|
||||
swSrc: resolve(root, 'app', 'javascript', 'mastodon', 'service_worker', 'entry.js'),
|
||||
swDest: resolve(root, "public", "packs", "sw.js"),
|
||||
swSrc: resolve(root, "app", "javascript", "mastodon", "service_worker", "entry.js"),
|
||||
}),
|
||||
],
|
||||
});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const { join, resolve } = require('path');
|
||||
const { join, resolve } = require("path");
|
||||
|
||||
const { env, settings } = require('../configuration');
|
||||
const { env, settings } = require("../configuration");
|
||||
|
||||
module.exports = {
|
||||
test: /\.(js|jsx|mjs|ts|tsx)$/,
|
||||
@@ -11,12 +11,12 @@ module.exports = {
|
||||
exclude: /node_modules/,
|
||||
use: [
|
||||
{
|
||||
loader: 'babel-loader',
|
||||
loader: "babel-loader",
|
||||
options: {
|
||||
sourceRoot: 'app/javascript',
|
||||
cacheDirectory: join(settings.cache_path, 'babel-loader'),
|
||||
cacheCompression: env.NODE_ENV === 'production',
|
||||
compact: env.NODE_ENV === 'production',
|
||||
sourceRoot: "app/javascript",
|
||||
cacheDirectory: join(settings.cache_path, "babel-loader"),
|
||||
cacheCompression: env.NODE_ENV === "production",
|
||||
compact: env.NODE_ENV === "production",
|
||||
},
|
||||
},
|
||||
],
|
||||
|
||||
@@ -1,29 +1,29 @@
|
||||
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
||||
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
|
||||
|
||||
module.exports = {
|
||||
test: /\.s?css$/i,
|
||||
use: [
|
||||
MiniCssExtractPlugin.loader,
|
||||
{
|
||||
loader: 'css-loader',
|
||||
loader: "css-loader",
|
||||
options: {
|
||||
sourceMap: true,
|
||||
importLoaders: 2,
|
||||
},
|
||||
},
|
||||
{
|
||||
loader: 'postcss-loader',
|
||||
loader: "postcss-loader",
|
||||
options: {
|
||||
sourceMap: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
loader: 'sass-loader',
|
||||
loader: "sass-loader",
|
||||
options: {
|
||||
sassOptions: {
|
||||
includePaths: ['app/javascript'],
|
||||
includePaths: ["app/javascript"],
|
||||
},
|
||||
implementation: require('sass'),
|
||||
implementation: require("sass"),
|
||||
sourceMap: true,
|
||||
},
|
||||
},
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
const { join } = require('path');
|
||||
const { join } = require("path");
|
||||
|
||||
const { settings } = require('../configuration');
|
||||
const { settings } = require("../configuration");
|
||||
|
||||
module.exports = {
|
||||
test: new RegExp(`(${settings.static_assets_extensions.join('|')})$`, 'i'),
|
||||
test: new RegExp(`(${settings.static_assets_extensions.join("|")})$`, "i"),
|
||||
use: [
|
||||
{
|
||||
loader: 'file-loader',
|
||||
loader: "file-loader",
|
||||
options: {
|
||||
name(file) {
|
||||
if (file.includes(settings.source_path)) {
|
||||
return 'media/[path][name]-[hash].[ext]';
|
||||
return "media/[path][name]-[hash].[ext]";
|
||||
}
|
||||
return 'media/[folder]/[name]-[hash:8].[ext]';
|
||||
return "media/[folder]/[name]-[hash:8].[ext]";
|
||||
},
|
||||
context: join(settings.source_path),
|
||||
},
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
const babel = require('./babel');
|
||||
const css = require('./css');
|
||||
const file = require('./file');
|
||||
const materialIcons = require('./material_icons');
|
||||
const nodeModules = require('./node_modules');
|
||||
const tesseract = require('./tesseract');
|
||||
const babel = require("./babel");
|
||||
const css = require("./css");
|
||||
const file = require("./file");
|
||||
const materialIcons = require("./material_icons");
|
||||
const nodeModules = require("./node_modules");
|
||||
const tesseract = require("./tesseract");
|
||||
|
||||
// Webpack loaders are processed in reverse order
|
||||
// https://webpack.js.org/concepts/loaders/#loader-features
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
if (process.env.NODE_ENV === 'production') {
|
||||
if (process.env.NODE_ENV === "production") {
|
||||
module.exports = {};
|
||||
} else {
|
||||
module.exports = {
|
||||
test: /\.js$/,
|
||||
loader: 'mark-loader',
|
||||
loader: "mark-loader",
|
||||
};
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ module.exports = {
|
||||
issuer: /\.[jt]sx?$/,
|
||||
use: [
|
||||
{
|
||||
loader: '@svgr/webpack',
|
||||
loader: "@svgr/webpack",
|
||||
options: {
|
||||
svgo: false,
|
||||
},
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const { join } = require('path');
|
||||
const { join } = require("path");
|
||||
|
||||
const { settings, env } = require('../configuration');
|
||||
const { settings, env } = require("../configuration");
|
||||
|
||||
module.exports = {
|
||||
test: /\.(js|mjs)$/,
|
||||
@@ -11,14 +11,14 @@ module.exports = {
|
||||
],
|
||||
use: [
|
||||
{
|
||||
loader: 'babel-loader',
|
||||
loader: "babel-loader",
|
||||
options: {
|
||||
babelrc: false,
|
||||
plugins: [
|
||||
'transform-react-remove-prop-types',
|
||||
"transform-react-remove-prop-types",
|
||||
],
|
||||
cacheDirectory: join(settings.cache_path, 'babel-loader-node-modules'),
|
||||
cacheCompression: env.NODE_ENV === 'production',
|
||||
cacheDirectory: join(settings.cache_path, "babel-loader-node-modules"),
|
||||
cacheCompression: env.NODE_ENV === "production",
|
||||
compact: false,
|
||||
sourceMaps: false,
|
||||
},
|
||||
|
||||
@@ -6,9 +6,9 @@ module.exports = {
|
||||
/tesseract\.js-core\/tesseract-core\.wasm.js$/,
|
||||
],
|
||||
use: {
|
||||
loader: 'file-loader',
|
||||
loader: "file-loader",
|
||||
options: {
|
||||
name: 'ocr/[name]-[hash].[ext]',
|
||||
name: "ocr/[name]-[hash].[ext]",
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
@@ -1,44 +1,55 @@
|
||||
// Note: You must restart bin/webpack-dev-server for changes to take effect
|
||||
|
||||
const { resolve } = require('path');
|
||||
const { resolve } = require("path");
|
||||
|
||||
const CircularDependencyPlugin = require('circular-dependency-plugin');
|
||||
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
||||
const webpack = require('webpack');
|
||||
const AssetsManifestPlugin = require('webpack-assets-manifest');
|
||||
const CircularDependencyPlugin = require("circular-dependency-plugin");
|
||||
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
|
||||
const webpack = require("webpack");
|
||||
const AssetsManifestPlugin = require("webpack-assets-manifest");
|
||||
|
||||
const { env, settings, core, flavours, output } = require('./configuration');
|
||||
const rules = require('./rules');
|
||||
const { env, settings, core, flavours, output } = require("./configuration");
|
||||
const rules = require("./rules");
|
||||
|
||||
function reducePacks (data, into = {}) {
|
||||
if (!data.pack) return into;
|
||||
if (!data.pack) {
|
||||
return into;
|
||||
}
|
||||
|
||||
for (const entry in data.pack) {
|
||||
const pack = data.pack[entry];
|
||||
if (!pack) continue;
|
||||
if (!pack) {
|
||||
continue;
|
||||
}
|
||||
|
||||
let packFiles = [];
|
||||
if (typeof pack === 'string')
|
||||
let packFiles;
|
||||
if (typeof pack === "string") {
|
||||
packFiles = [pack];
|
||||
else if (Array.isArray(pack))
|
||||
} else if (Array.isArray(pack)) {
|
||||
packFiles = pack;
|
||||
else
|
||||
} else {
|
||||
packFiles = [pack.filename];
|
||||
}
|
||||
|
||||
if (packFiles) {
|
||||
into[data.name ? `flavours/${data.name}/${entry}` : `core/${entry}`] = packFiles.map(packFile => resolve(data.pack_directory, packFile));
|
||||
}
|
||||
}
|
||||
|
||||
if (!data.name) return into;
|
||||
if (!data.name) {
|
||||
return into;
|
||||
}
|
||||
|
||||
for (const skinName in data.skin) {
|
||||
const skin = data.skin[skinName];
|
||||
if (!skin) continue;
|
||||
if (!skin) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (const entry in skin) {
|
||||
const packFile = skin[entry];
|
||||
if (!packFile) continue;
|
||||
if (!packFile) {
|
||||
continue;
|
||||
}
|
||||
|
||||
into[`skins/${data.name}/${skinName}/${entry}`] = resolve(packFile);
|
||||
}
|
||||
@@ -57,24 +68,24 @@ module.exports = {
|
||||
entry: entries,
|
||||
|
||||
output: {
|
||||
filename: 'js/[name].js',
|
||||
hotUpdateChunkFilename: 'js/[id]-[hash].hot-update.js',
|
||||
hashFunction: 'sha256',
|
||||
crossOriginLoading: 'anonymous',
|
||||
filename: "js/[name].js",
|
||||
hotUpdateChunkFilename: "js/[id]-[hash].hot-update.js",
|
||||
hashFunction: "sha256",
|
||||
crossOriginLoading: "anonymous",
|
||||
path: output.path,
|
||||
publicPath: output.publicPath,
|
||||
},
|
||||
|
||||
optimization: {
|
||||
runtimeChunk: {
|
||||
name: 'common',
|
||||
name: "common",
|
||||
},
|
||||
splitChunks: {
|
||||
cacheGroups: {
|
||||
default: false,
|
||||
vendorsVendors: false,
|
||||
common: {
|
||||
name: 'common',
|
||||
name: "common",
|
||||
chunks (chunk) {
|
||||
return !(chunk.name in entries);
|
||||
},
|
||||
@@ -84,8 +95,8 @@ module.exports = {
|
||||
},
|
||||
},
|
||||
},
|
||||
chunkIds: 'total-size',
|
||||
moduleIds: 'size'
|
||||
chunkIds: "total-size",
|
||||
moduleIds: "size",
|
||||
},
|
||||
|
||||
module: {
|
||||
@@ -99,33 +110,33 @@ module.exports = {
|
||||
/^history\//, (resource) => {
|
||||
// temporary fix for https://github.com/ReactTraining/react-router/issues/5576
|
||||
// to reduce bundle size
|
||||
resource.request = resource.request.replace(/^history/, 'history/es');
|
||||
resource.request = resource.request.replace(/^history/, "history/es");
|
||||
},
|
||||
),
|
||||
new MiniCssExtractPlugin({
|
||||
filename: 'css/[name].css',
|
||||
filename: "css/[name].css",
|
||||
}),
|
||||
new AssetsManifestPlugin({
|
||||
integrity: true,
|
||||
integrityHashes: ['sha256'],
|
||||
integrityHashes: ["sha256"],
|
||||
entrypoints: true,
|
||||
writeToDisk: true,
|
||||
publicPath: true,
|
||||
}),
|
||||
new CircularDependencyPlugin({
|
||||
failOnError: true,
|
||||
})
|
||||
}),
|
||||
],
|
||||
|
||||
resolve: {
|
||||
extensions: settings.extensions,
|
||||
modules: [
|
||||
resolve(settings.source_path),
|
||||
'node_modules',
|
||||
"node_modules",
|
||||
],
|
||||
},
|
||||
|
||||
resolveLoader: {
|
||||
modules: ['node_modules'],
|
||||
modules: ["node_modules"],
|
||||
},
|
||||
};
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
// Note: You must restart bin/webpack-dev-server for changes to take effect
|
||||
|
||||
const { merge } = require('webpack-merge');
|
||||
const { merge } = require("webpack-merge");
|
||||
|
||||
const sharedConfig = require('./shared');
|
||||
const sharedConfig = require("./shared");
|
||||
|
||||
module.exports = merge(sharedConfig, {
|
||||
mode: 'production',
|
||||
mode: "production",
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user