Skip to content

Commit e737863

Browse files
committed
Setup ESLint
1 parent 0ed1809 commit e737863

File tree

7 files changed

+3323
-160
lines changed

7 files changed

+3323
-160
lines changed

.eslintcache

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/webapp/public/**

.eslintrc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"parser": "babel-eslint",
3+
"extends": ["airbnb"],
4+
"rules": {}
5+
}

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ require (
1313
github.com/felixge/fgprof v0.9.1
1414
github.com/google/go-cmp v0.5.2 // indirect
1515
github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99
16-
github.com/google/uuid v1.1.2 // indirect
16+
github.com/google/uuid v1.1.2
1717
github.com/iancoleman/strcase v0.1.2
1818
github.com/ianlancetaylor/demangle v0.0.0-20200715173712-053cf528c12f // indirect
1919
github.com/imdario/mergo v0.3.11 // indirect
@@ -25,7 +25,7 @@ require (
2525
github.com/mattn/go-runewidth v0.0.9 // indirect
2626
github.com/mattn/goreman v0.3.5
2727
github.com/mgechev/revive v1.0.2
28-
github.com/mitchellh/go-ps v1.0.0 // indirect
28+
github.com/mitchellh/go-ps v1.0.0
2929
github.com/morikuni/aec v1.0.0 // indirect
3030
github.com/onsi/ginkgo v1.14.0
3131
github.com/onsi/gomega v1.10.1

package.json

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,15 @@
99
},
1010
"scripts": {
1111
"dev": "webpack --progress --colors --config scripts/webpack/webpack.dev.js",
12-
"test": "jest"
12+
"test": "jest",
13+
"lint": "eslint ./ --ext .js --cache"
1314
},
1415
"devDependencies": {
1516
"@babel/core": "7.8.4",
1617
"@babel/preset-react": "^7.12.10",
1718
"@babel/preset-typescript": "7.8.3",
1819
"autoprefixer": "^9.8.5",
20+
"babel-eslint": "^10.1.0",
1921
"babel-plugin-transform-class-properties": "^6.24.1",
2022
"clean-webpack-plugin": "^3.0.0",
2123
"contributor-faces": "^1.1.0",
@@ -24,6 +26,13 @@
2426
"css-loader": "^4.0.0",
2527
"enzyme": "^3.11.0",
2628
"enzyme-adapter-react-16": "^1.15.5",
29+
"eslint": "7.2.0",
30+
"eslint-config-airbnb": "18.2.1",
31+
"eslint-plugin-import": "^2.22.1",
32+
"eslint-plugin-jsx-a11y": "^6.4.1",
33+
"eslint-plugin-react": "^7.21.5",
34+
"eslint-plugin-react-hooks": "4.0.0",
35+
"eslint-webpack-plugin": "^2.4.1",
2736
"html-webpack-plugin": "^4.3.0",
2837
"jest": "^26.6.3",
2938
"mini-css-extract-plugin": "^0.9.0",

scripts/webpack/webpack.common.js

Lines changed: 58 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,41 @@
1-
'use strict';
1+
"use strict";
22

3-
const webpack = require('webpack');
4-
const path = require('path');
5-
const HtmlWebpackPlugin = require('html-webpack-plugin');
6-
const {BundleAnalyzerPlugin} = require('webpack-bundle-analyzer');
7-
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
8-
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
9-
const CopyPlugin = require('copy-webpack-plugin');
10-
const fs = require('fs');
3+
const webpack = require("webpack");
4+
const path = require("path");
5+
const HtmlWebpackPlugin = require("html-webpack-plugin");
6+
const { BundleAnalyzerPlugin } = require("webpack-bundle-analyzer");
7+
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
8+
const { CleanWebpackPlugin } = require("clean-webpack-plugin");
9+
const CopyPlugin = require("copy-webpack-plugin");
10+
const ESLintPlugin = require("eslint-webpack-plugin");
11+
12+
const fs = require("fs");
1113

1214
module.exports = {
13-
target: 'web',
15+
target: "web",
1416

1517
entry: {
16-
app: './webapp/javascript/index.jsx',
17-
styles: './webapp/sass/profile.scss',
18+
app: "./webapp/javascript/index.jsx",
19+
styles: "./webapp/sass/profile.scss",
1820
},
1921

2022
output: {
21-
publicPath: '',
22-
path: path.resolve(__dirname, '../../webapp/public/build'),
23-
filename: '[name].[hash].js',
23+
publicPath: "",
24+
path: path.resolve(__dirname, "../../webapp/public/build"),
25+
filename: "[name].[hash].js",
2426
},
2527

2628
resolve: {
27-
extensions: ['.ts', '.tsx', '.es6', '.js', '.jsx', '.json', '.svg'],
29+
extensions: [".ts", ".tsx", ".es6", ".js", ".jsx", ".json", ".svg"],
2830
alias: {
2931
// rc-trigger uses babel-runtime which has internal dependency to core-js@2
3032
// this alias maps that dependency to core-js@t3
31-
'core-js/library/fn': 'core-js/stable',
33+
"core-js/library/fn": "core-js/stable",
3234
},
3335
modules: [
34-
'node_modules',
35-
path.resolve('webapp'),
36-
path.resolve('node_modules'),
36+
"node_modules",
37+
path.resolve("webapp"),
38+
path.resolve("node_modules"),
3739
],
3840
},
3941

@@ -55,30 +57,30 @@ module.exports = {
5557
exclude: /node_modules/,
5658
use: [
5759
{
58-
loader: 'babel-loader',
60+
loader: "babel-loader",
5961
options: {
6062
cacheDirectory: true,
6163
babelrc: true,
6264
// Note: order is bottom-to-top and/or right-to-left
6365
presets: [
6466
[
65-
'@babel/preset-env',
67+
"@babel/preset-env",
6668
{
6769
targets: {
68-
browsers: 'last 3 versions',
70+
browsers: "last 3 versions",
6971
},
70-
useBuiltIns: 'entry',
72+
useBuiltIns: "entry",
7173
corejs: 3,
7274
modules: false,
7375
},
7476
],
7577
[
76-
'@babel/preset-typescript',
78+
"@babel/preset-typescript",
7779
{
7880
allowNamespaces: true,
7981
},
8082
],
81-
'@babel/preset-react',
83+
"@babel/preset-react",
8284
],
8385
},
8486
},
@@ -88,9 +90,9 @@ module.exports = {
8890
test: /\.js$/,
8991
use: [
9092
{
91-
loader: 'babel-loader',
93+
loader: "babel-loader",
9294
options: {
93-
presets: [['@babel/preset-env']],
95+
presets: [["@babel/preset-env"]],
9496
},
9597
},
9698
],
@@ -100,7 +102,7 @@ module.exports = {
100102
exclude: /(index|error)\.html/,
101103
use: [
102104
{
103-
loader: 'html-loader',
105+
loader: "html-loader",
104106
options: {
105107
attrs: [],
106108
minimize: true,
@@ -113,81 +115,84 @@ module.exports = {
113115
{
114116
test: /\.css$/,
115117
// include: MONACO_DIR, // https://github.com/react-monaco-editor/react-monaco-editor
116-
use: ['style-loader', 'css-loader'],
118+
use: ["style-loader", "css-loader"],
117119
},
118120
{
119121
test: /\.scss$/,
120122
use: [
121123
MiniCssExtractPlugin.loader,
122124
{
123-
loader: 'css-loader',
125+
loader: "css-loader",
124126
options: {
125127
importLoaders: 2,
126128
url: true,
127-
sourceMap: true
129+
sourceMap: true,
128130
},
129131
},
130132
{
131-
loader: 'postcss-loader',
133+
loader: "postcss-loader",
132134
options: {
133135
sourceMap: true,
134136
config: { path: __dirname },
135137
},
136138
},
137139
{
138-
loader: 'sass-loader',
140+
loader: "sass-loader",
139141
options: {
140-
sourceMap: true
142+
sourceMap: true,
141143
},
142144
},
143145
],
144146
},
145147
{
146148
test: /\.(svg|ico|jpg|jpeg|png|gif|eot|otf|webp|ttf|woff|woff2|cur|ani|pdf)(\?.*)?$/,
147-
loader: 'file-loader',
148-
options: { name: 'static/img/[name].[hash:8].[ext]' },
149+
loader: "file-loader",
150+
options: { name: "static/img/[name].[hash:8].[ext]" },
149151
},
150152
],
151153
},
152154

153155
plugins: [
156+
new ESLintPlugin(),
154157
new webpack.ProvidePlugin({
155-
$: 'jquery',
156-
jQuery: 'jquery',
158+
$: "jquery",
159+
jQuery: "jquery",
157160
}),
158161
new HtmlWebpackPlugin({
159-
filename: path.resolve(__dirname, '../../webapp/public/index.html'),
160-
template: path.resolve(__dirname, '../../webapp/templates/index.html'),
162+
filename: path.resolve(__dirname, "../../webapp/public/index.html"),
163+
template: path.resolve(__dirname, "../../webapp/templates/index.html"),
161164
inject: false,
162-
chunksSortMode: 'none',
165+
chunksSortMode: "none",
163166
templateParameters: (compilation, assets, options) => {
164-
return ({
165-
extra_metadata: process.env.EXTRA_METADATA ? fs.readFileSync(process.env.EXTRA_METADATA) : "",
167+
return {
168+
extra_metadata: process.env.EXTRA_METADATA
169+
? fs.readFileSync(process.env.EXTRA_METADATA)
170+
: "",
166171
mode: process.env.NODE_ENV,
167172
webpack: compilation.getStats().toJson(),
168173
compilation: compilation,
169174
webpackConfig: compilation.options,
170175
htmlWebpackPlugin: {
171176
files: assets,
172-
options: options
173-
}
174-
})
177+
options: options,
178+
},
179+
};
175180
},
176181
}),
177182
new MiniCssExtractPlugin({
178-
filename: '[name].[hash].css',
183+
filename: "[name].[hash].css",
179184
}),
180185
new webpack.DefinePlugin({
181-
PYROSCOPE_VERSION: JSON.stringify(require("../../package.json").version)
186+
PYROSCOPE_VERSION: JSON.stringify(require("../../package.json").version),
182187
}),
183188
new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/),
184189
new CopyPlugin({
185190
patterns: [
186191
{
187-
from: 'webapp/images',
188-
to: 'images'
189-
}
190-
]
192+
from: "webapp/images",
193+
to: "images",
194+
},
195+
],
191196
}),
192197
],
193198
};

0 commit comments

Comments
 (0)