configure eslint

This commit is contained in:
Ray Elliott 2021-01-03 23:51:23 +00:00
parent 86e3e475ce
commit d3a42baec4
6 changed files with 1117 additions and 116 deletions

11
static-html/.eslintrc.js Normal file
View File

@ -0,0 +1,11 @@
module.exports = {
env: {
es6: true,
browser: true,
},
parserOptions: {
ecmaVersion: 2017,
},
parser: 'babel-eslint',
extends: 'eslint-config-airbnb-base',
};

File diff suppressed because it is too large Load Diff

View File

@ -13,11 +13,16 @@
"devDependencies": { "devDependencies": {
"@babel/core": "^7.12.10", "@babel/core": "^7.12.10",
"@babel/preset-env": "^7.12.11", "@babel/preset-env": "^7.12.11",
"babel-eslint": "^10.1.0",
"babel-loader": "^8.2.2", "babel-loader": "^8.2.2",
"clean-webpack-plugin": "^3.0.0", "clean-webpack-plugin": "^3.0.0",
"css-loader": "^5.0.1", "css-loader": "^5.0.1",
"cssnano-webpack-plugin": "^1.0.3", "cssnano-webpack-plugin": "^1.0.3",
"ejs-compiled-loader": "^3.0.0", "ejs-compiled-loader": "^3.0.0",
"eslint": "^7.2.0",
"eslint-config-airbnb-base": "^14.2.1",
"eslint-plugin-import": "^2.22.1",
"eslint-webpack-plugin": "^2.4.1",
"html-webpack-plugin": "^4.5.0", "html-webpack-plugin": "^4.5.0",
"mini-css-extract-plugin": "^1.3.3", "mini-css-extract-plugin": "^1.3.3",
"postcss": "^8.2.2", "postcss": "^8.2.2",

View File

@ -1,18 +1,18 @@
module.exports = {
plugins: [
"postcss-import",
"postcss-mixins",
"postcss-preset-env",
"postcss-nesting",
"postcss-simple-vars",
["postcss-functions",
{
functions: { half },
}
],
],
};
function half(val) { function half(val) {
return val / 2; return val / 2;
} }
module.exports = {
plugins: [
'postcss-import',
'postcss-mixins',
'postcss-preset-env',
'postcss-nesting',
'postcss-simple-vars',
['postcss-functions',
{
functions: { half },
},
],
],
};

View File

@ -2,13 +2,11 @@ const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin'); const HtmlWebpackPlugin = require('html-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin'); const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const CssnanoPlugin = require('cssnano-webpack-plugin'); const CssnanoPlugin = require('cssnano-webpack-plugin');
const EsLintPlugin = require('eslint-webpack-plugin');
const StylelintPlugin = require('stylelint-webpack-plugin'); const StylelintPlugin = require('stylelint-webpack-plugin');
const { CleanWebpackPlugin } = require('clean-webpack-plugin'); const { CleanWebpackPlugin } = require('clean-webpack-plugin');
module.exports = env => { module.exports = (env) => ({
console.log(env);
return {
mode: env.production ? 'production' : 'development', mode: env.production ? 'production' : 'development',
target: 'web', target: 'web',
entry: './src/js/index.js', entry: './src/js/index.js',
@ -27,8 +25,9 @@ module.exports = env => {
}), }),
new CleanWebpackPlugin(), new CleanWebpackPlugin(),
new HtmlWebpackPlugin({ new HtmlWebpackPlugin({
template: './src/templates/index.ejs' template: './src/templates/index.ejs',
}), }),
new EsLintPlugin(),
new StylelintPlugin(), new StylelintPlugin(),
], ],
module: { module: {
@ -46,9 +45,9 @@ module.exports = env => {
use: { use: {
loader: 'babel-loader', loader: 'babel-loader',
options: { options: {
presets: ['@babel/preset-env'] presets: ['@babel/preset-env'],
} },
} },
}, },
{ {
test: /\.inline\.css$/i, test: /\.inline\.css$/i,
@ -58,10 +57,9 @@ module.exports = env => {
loader: 'style-loader', loader: 'style-loader',
options: { options: {
insert: function insertAtTop(element) { insert: function insertAtTop(element) {
var parent = document.querySelector('head'); const parent = document.querySelector('head');
// eslint-disable-next-line no-underscore-dangle // eslint-disable-next-line no-underscore-dangle
var lastInsertedElement = const lastInsertedElement = window._lastElementInsertedByStyleLoader;
window._lastElementInsertedByStyleLoader;
if (!lastInsertedElement) { if (!lastInsertedElement) {
parent.insertBefore(element, parent.firstChild); parent.insertBefore(element, parent.firstChild);
@ -90,7 +88,7 @@ module.exports = env => {
include: path.resolve(__dirname, 'src'), include: path.resolve(__dirname, 'src'),
type: 'asset', type: 'asset',
}, },
] ],
}, },
optimization: { optimization: {
minimizer: [ minimizer: [
@ -100,5 +98,4 @@ module.exports = env => {
'...', // access defaults (defaults are overridden when specifying minimizer: array) '...', // access defaults (defaults are overridden when specifying minimizer: array)
], ],
}, },
} });
};