Skip to content

Commit

Permalink
Fix lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
LouisInFlow committed Jan 16, 2021
1 parent ec55923 commit 14ad03e
Show file tree
Hide file tree
Showing 13 changed files with 139 additions and 120 deletions.
2 changes: 1 addition & 1 deletion .eslintcache

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = {
presets: ['@babel/preset-env', '@babel/preset-react'],
plugins: ['transform-class-properties'],
presets: ["@babel/preset-env", "@babel/preset-react"],
plugins: ["transform-class-properties"],
};
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
"classnames": "^2.2.6",
"clsx": "^1.1.1",
"file-loader": "^6.2.0",
"lodash": "^4.17.20",
"moment": "^2.27.0",
"normalize.css": "^8.0.1",
"react": "16.12.0",
Expand Down
4 changes: 2 additions & 2 deletions scripts/webpack/postcss.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module.exports = () => ({
plugins: {
autoprefixer: {},
'postcss-reporter': {},
'postcss-browser-reporter': {},
"postcss-reporter": {},
"postcss-browser-reporter": {},
},
});
87 changes: 43 additions & 44 deletions scripts/webpack/webpack.common.js
Original file line number Diff line number Diff line change
@@ -1,39 +1,37 @@
const webpack = require('webpack');
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const CopyPlugin = require('copy-webpack-plugin');
const ESLintPlugin = require('eslint-webpack-plugin');
const webpack = require("webpack");
const path = require("path");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const CopyPlugin = require("copy-webpack-plugin");
const ESLintPlugin = require("eslint-webpack-plugin");

const fs = require('fs');
const fs = require("fs");

module.exports = {
target: 'web',
target: "web",

entry: {
app: './webapp/javascript/index.jsx',
styles: './webapp/sass/profile.scss',
app: "./webapp/javascript/index.jsx",
styles: "./webapp/sass/profile.scss",
},

output: {
publicPath: '',
path: path.resolve(__dirname, '../../webapp/public/build'),
filename: '[name].[hash].js',
publicPath: "",
path: path.resolve(__dirname, "../../webapp/public/build"),
filename: "[name].[hash].js",
},

resolve: {
extensions: ['.ts', '.tsx', '.es6', '.js', '.jsx', '.json', '.svg'],
extensions: [".ts", ".tsx", ".es6", ".js", ".jsx", ".json", ".svg"],
alias: {
// rc-trigger uses babel-runtime which has internal dependency to core-js@2
// this alias maps that dependency to core-js@t3
'core-js/library/fn': 'core-js/stable',
"core-js/library/fn": "core-js/stable",
},
modules: [
'node_modules',
path.resolve('webapp'),
path.resolve('node_modules'),
"node_modules",
path.resolve("webapp"),
path.resolve("node_modules"),
],
},

Expand All @@ -55,30 +53,30 @@ module.exports = {
exclude: /node_modules/,
use: [
{
loader: 'babel-loader',
loader: "babel-loader",
options: {
cacheDirectory: true,
babelrc: true,
// Note: order is bottom-to-top and/or right-to-left
presets: [
[
'@babel/preset-env',
"@babel/preset-env",
{
targets: {
browsers: 'last 3 versions',
browsers: "last 3 versions",
},
useBuiltIns: 'entry',
useBuiltIns: "entry",
corejs: 3,
modules: false,
},
],
[
'@babel/preset-typescript',
"@babel/preset-typescript",
{
allowNamespaces: true,
},
],
'@babel/preset-react',
"@babel/preset-react",
],
},
},
Expand All @@ -88,9 +86,9 @@ module.exports = {
test: /\.js$/,
use: [
{
loader: 'babel-loader',
loader: "babel-loader",
options: {
presets: [['@babel/preset-env']],
presets: [["@babel/preset-env"]],
},
},
],
Expand All @@ -100,7 +98,7 @@ module.exports = {
exclude: /(index|error)\.html/,
use: [
{
loader: 'html-loader',
loader: "html-loader",
options: {
attrs: [],
minimize: true,
Expand All @@ -113,29 +111,29 @@ module.exports = {
{
test: /\.css$/,
// include: MONACO_DIR, // https://github.com/react-monaco-editor/react-monaco-editor
use: ['style-loader', 'css-loader'],
use: ["style-loader", "css-loader"],
},
{
test: /\.scss$/,
use: [
MiniCssExtractPlugin.loader,
{
loader: 'css-loader',
loader: "css-loader",
options: {
importLoaders: 2,
url: true,
sourceMap: true,
},
},
{
loader: 'postcss-loader',
loader: "postcss-loader",
options: {
sourceMap: true,
config: { path: __dirname },
},
},
{
loader: 'sass-loader',
loader: "sass-loader",
options: {
sourceMap: true,
},
Expand All @@ -144,27 +142,27 @@ module.exports = {
},
{
test: /\.(svg|ico|jpg|jpeg|png|gif|eot|otf|webp|ttf|woff|woff2|cur|ani|pdf)(\?.*)?$/,
loader: 'file-loader',
options: { name: 'static/img/[name].[hash:8].[ext]' },
loader: "file-loader",
options: { name: "static/img/[name].[hash:8].[ext]" },
},
],
},

plugins: [
new ESLintPlugin(),
new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery',
$: "jquery",
jQuery: "jquery",
}),
new HtmlWebpackPlugin({
filename: path.resolve(__dirname, '../../webapp/public/index.html'),
template: path.resolve(__dirname, '../../webapp/templates/index.html'),
filename: path.resolve(__dirname, "../../webapp/public/index.html"),
template: path.resolve(__dirname, "../../webapp/templates/index.html"),
inject: false,
chunksSortMode: 'none',
chunksSortMode: "none",
templateParameters: (compilation, assets, options) => ({
extra_metadata: process.env.EXTRA_METADATA
? fs.readFileSync(process.env.EXTRA_METADATA)
: '',
: "",
mode: process.env.NODE_ENV,
webpack: compilation.getStats().toJson(),
compilation,
Expand All @@ -176,17 +174,18 @@ module.exports = {
}),
}),
new MiniCssExtractPlugin({
filename: '[name].[hash].css',
filename: "[name].[hash].css",
}),
new webpack.DefinePlugin({
// eslint-disable-next-line
PYROSCOPE_VERSION: JSON.stringify(require('../../package.json').version),
}),
new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/),
new CopyPlugin({
patterns: [
{
from: 'webapp/images',
to: 'images',
from: "webapp/images",
to: "images",
},
],
}),
Expand Down
7 changes: 3 additions & 4 deletions scripts/webpack/webpack.dev.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
const { DefinePlugin } = require('webpack');
const { merge } = require('webpack-merge');
const { merge } = require("webpack-merge");

const common = require('./webpack.common.js');
const common = require("./webpack.common.js");

module.exports = merge(common, {
mode: 'development',
mode: "development",
});
7 changes: 3 additions & 4 deletions scripts/webpack/webpack.prod.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
const { DefinePlugin } = require('webpack');
const { merge } = require('webpack-merge');
const { merge } = require("webpack-merge");

const common = require('./webpack.common.js');
const common = require("./webpack.common.js");

module.exports = merge(common, {
mode: 'production',
mode: "production",
});
24 changes: 12 additions & 12 deletions webapp/javascript/redux/actionTypes.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
export const SET_DATE_RANGE = 'SET_DATE_RANGE';
export const SET_FROM = 'SET_FROM';
export const SET_UNTIL = 'SET_UNTIL';
export const SET_MAX_NODES = 'SET_MAX_NODES';
export const SET_LABELS = 'SET_LABELS';
export const ADD_LABEL = 'ADD_LABEL';
export const REMOVE_LABEL = 'REMOVE_LABEL';
export const REFRESH = 'REFRESH';
export const REQUEST_JSON = 'REQUEST_JSON';
export const RECEIVE_JSON = 'RECEIVE_JSON';
export const REQUEST_NAMES = 'REQUEST_NAMES';
export const RECEIVE_NAMES = 'RECEIVE_NAMES';
export const SET_DATE_RANGE = "SET_DATE_RANGE";
export const SET_FROM = "SET_FROM";
export const SET_UNTIL = "SET_UNTIL";
export const SET_MAX_NODES = "SET_MAX_NODES";
export const SET_LABELS = "SET_LABELS";
export const ADD_LABEL = "ADD_LABEL";
export const REMOVE_LABEL = "REMOVE_LABEL";
export const REFRESH = "REFRESH";
export const REQUEST_JSON = "REQUEST_JSON";
export const RECEIVE_JSON = "RECEIVE_JSON";
export const REQUEST_NAMES = "REQUEST_NAMES";
export const RECEIVE_NAMES = "RECEIVE_NAMES";
36 changes: 28 additions & 8 deletions webapp/javascript/redux/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,36 @@ import {
RECEIVE_JSON,
REQUEST_NAMES,
RECEIVE_NAMES,
} from './actionTypes';
} from "./actionTypes";

export const setDateRange = (from, until) => ({ type: SET_DATE_RANGE, payload: { from, until } });
export const setDateRange = (from, until) => ({
type: SET_DATE_RANGE,
payload: { from, until },
});

export const setFrom = (from) => ({ type: SET_FROM, payload: { from } });

export const setUntil = (until) => ({ type: SET_UNTIL, payload: { until } });

export const setMaxNodes = (maxNodes) => ({ type: SET_MAX_NODES, payload: { maxNodes } });
export const setMaxNodes = (maxNodes) => ({
type: SET_MAX_NODES,
payload: { maxNodes },
});

export const setLabels = (labels) => ({ type: SET_LABELS, payload: { labels } });
export const setLabels = (labels) => ({
type: SET_LABELS,
payload: { labels },
});

export const addLabel = (name, value) => ({ type: ADD_LABEL, payload: { name, value } });
export const addLabel = (name, value) => ({
type: ADD_LABEL,
payload: { name, value },
});

export const removeLabel = (name) => ({ type: REMOVE_LABEL, payload: { name } });
export const removeLabel = (name) => ({
type: REMOVE_LABEL,
payload: { name },
});

export const refresh = (url) => ({ type: REFRESH, payload: { url } });

Expand All @@ -35,7 +50,10 @@ export const receiveJSON = (data) => ({ type: RECEIVE_JSON, payload: data });

export const requestNames = () => ({ type: REQUEST_NAMES, payload: {} });

export const receiveNames = (names) => ({ type: RECEIVE_NAMES, payload: { names } });
export const receiveNames = (names) => ({
type: RECEIVE_NAMES,
payload: { names },
});

let currentJSONController;
export function fetchJSON(url) {
Expand Down Expand Up @@ -64,7 +82,9 @@ export function fetchNames() {
currentNamesController = new AbortController();

dispatch(requestNames());
return fetch('/label-values?label=__name__', { signal: currentNamesController.signal })
return fetch("/label-values?label=__name__", {
signal: currentNamesController.signal,
})
.then((response) => response.json())
.then((data) => {
dispatch(receiveNames(data));
Expand Down

0 comments on commit 14ad03e

Please sign in to comment.