eslint: Cleanup linting of /dist

* Move eslintrc.es5.json to /dist to avoid extra Grunt config
* Upgrade clean-webpack-plugin and exclude dist/.eslintrc.js
  from cleaning
* Set root:true and just enable wikimedia/language/not-es5 instead
  of disabling dozens of rules
* Remove getOwnPropertySymbols rule as webpack uses this.

Change-Id: I802138a8a591dd4c3cb0cc637112e383570286df
This commit is contained in:
Ed Sanders 2020-04-27 19:58:30 +01:00
parent 957e81747b
commit 85fc18d38d
7 changed files with 174 additions and 79 deletions

View file

@ -1,55 +0,0 @@
{
"parserOptions": {
"sourceType": "script",
"ecmaVersion": 5
},
"env": {
"browser": true,
"jquery": true,
"commonjs": false,
"qunit": true
},
"rules": {
"array-bracket-spacing": "off",
"block-spacing": "off",
"camelcase": "off",
"comma-spacing": "off",
"computed-property-spacing": "off",
"curly": "off",
"eol-last": "off",
"eqeqeq": "off",
"key-spacing": "off",
"keyword-spacing": "off",
"max-statements-per-line": "off",
"new-parens": "off",
"no-bitwise": "off",
"no-fallthrough": "off",
"no-floating-decimal": "off",
"no-implicit-coercion": "off",
"no-jquery/no-class-state": "off",
"no-jquery/no-global-selector": "off",
"no-jquery/variable-pattern": "off",
"no-loop-func": "off",
"no-new-func": "off",
"no-return-assign": "off",
"no-sequences": "off",
"no-undef": "off",
"no-underscore-dangle": "off",
"no-unused-expressions": "off",
"no-unused-vars": "off",
"no-void": "off",
"object-curly-spacing": "off",
"quote-props": "off",
"quotes": "off",
"semi": "off",
"semi-spacing": "off",
"space-before-blocks": "off",
"space-before-function-paren": "off",
"space-in-parens": "off",
"space-infix-ops": "off",
"spaced-comment": "off",
"switch-colon-spacing": "off",
"wrap-iife": "off",
"yoda": "off"
}
}

1
.gitattributes vendored
View file

@ -1,2 +1,3 @@
resources/dist/** -diff -whitespace
resources/dist/.eslintrc.js diff whitespace
package-lock.json -diff -whitespace

View file

@ -15,26 +15,16 @@ module.exports = function ( grunt ) {
options: {
cache: true,
maxWarnings: 0,
reportUnusedDisableDirectives: true,
extensions: [ '.js', '.json' ]
extensions: [ '.js', '.json' ],
fix: grunt.option( 'fix' )
},
// Lint the built artifacts with ES5 so that no ES6 slips to production
build: {
options: {
configFile: '.eslintrc.es5.json'
},
src: [
'resources/dist/*.js'
]
},
sources: {
options: {
fix: grunt.option( 'fix' )
},
all: {
src: [
'*.{js,json}',
'src/**/*.{js,json}',
'tests/**/*.{js,json}'
'tests/**/*.{js,json}',
// Lint the built artifacts with ES5 so that no ES6 slips to production
'resources/dist/*.js'
]
}
},
@ -80,6 +70,6 @@ module.exports = function ( grunt ) {
}
} );
grunt.registerTask( 'lint', [ 'eslint', 'stylelint', 'banana', 'eslint:build', 'svgmin' ] );
grunt.registerTask( 'lint', [ 'eslint', 'stylelint', 'banana', 'svgmin' ] );
grunt.registerTask( 'default', [ 'lint' ] );
};

165
package-lock.json generated
View file

@ -3244,6 +3244,12 @@
}
}
},
"@types/anymatch": {
"version": "1.3.1",
"resolved": "https://registry.npmjs.org/@types/anymatch/-/anymatch-1.3.1.tgz",
"integrity": "sha512-/+CRPXpBDpo2RK9C68N3b2cOvO0Cf5B9aPijHsoDQTHivnGSObdOF2BRQOYjojWTDy6nQvMjmqRXIxH55VjxxA==",
"dev": true
},
"@types/color-name": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/@types/color-name/-/color-name-1.1.1.tgz",
@ -3365,6 +3371,35 @@
"integrity": "sha512-7EJYyKTL7tFR8+gDbB6Wwz/arpGa0Mywk1TJbNzKzHtzbwVmY4HR9WqS5VV7dsBUKQmPNr192jHr/VpBluj/hg==",
"dev": true
},
"@types/source-list-map": {
"version": "0.1.2",
"resolved": "https://registry.npmjs.org/@types/source-list-map/-/source-list-map-0.1.2.tgz",
"integrity": "sha512-K5K+yml8LTo9bWJI/rECfIPrGgxdpeNbj+d53lwN4QjW1MCwlkhUms+gtdzigTeUyBr09+u8BwOIY3MXvHdcsA==",
"dev": true
},
"@types/tapable": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/@types/tapable/-/tapable-1.0.5.tgz",
"integrity": "sha512-/gG2M/Imw7cQFp8PGvz/SwocNrmKFjFsm5Pb8HdbHkZ1K8pmuPzOX4VeVoiEecFCVf4CsN1r3/BRvx+6sNqwtQ==",
"dev": true
},
"@types/uglify-js": {
"version": "3.9.0",
"resolved": "https://registry.npmjs.org/@types/uglify-js/-/uglify-js-3.9.0.tgz",
"integrity": "sha512-3ZcoyPYHVOCcLpnfZwD47KFLr8W/mpUcgjpf1M4Q78TMJIw7KMAHSjiCLJp1z3ZrBR9pTLbe191O0TldFK5zcw==",
"dev": true,
"requires": {
"source-map": "^0.6.1"
},
"dependencies": {
"source-map": {
"version": "0.6.1",
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
"integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==",
"dev": true
}
}
},
"@types/unist": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/@types/unist/-/unist-2.0.3.tgz",
@ -3392,6 +3427,47 @@
"@types/unist": "*"
}
},
"@types/webpack": {
"version": "4.41.12",
"resolved": "https://registry.npmjs.org/@types/webpack/-/webpack-4.41.12.tgz",
"integrity": "sha512-BpCtM4NnBen6W+KEhrL9jKuZCXVtiH6+0b6cxdvNt2EwU949Al334PjQSl2BeAyvAX9mgoNNG21wvjP3xZJJ5w==",
"dev": true,
"requires": {
"@types/anymatch": "*",
"@types/node": "*",
"@types/tapable": "*",
"@types/uglify-js": "*",
"@types/webpack-sources": "*",
"source-map": "^0.6.0"
},
"dependencies": {
"source-map": {
"version": "0.6.1",
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
"integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==",
"dev": true
}
}
},
"@types/webpack-sources": {
"version": "0.1.7",
"resolved": "https://registry.npmjs.org/@types/webpack-sources/-/webpack-sources-0.1.7.tgz",
"integrity": "sha512-XyaHrJILjK1VHVC4aVlKsdNN5KBTwufMb43cQs+flGxtPAf/1Qwl8+Q0tp5BwEGaI8D6XT1L+9bSWXckgkjTLw==",
"dev": true,
"requires": {
"@types/node": "*",
"@types/source-list-map": "*",
"source-map": "^0.6.1"
},
"dependencies": {
"source-map": {
"version": "0.6.1",
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
"integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==",
"dev": true
}
}
},
"@webassemblyjs/ast": {
"version": "1.7.11",
"resolved": "https://registry.npmjs.org/@webassemblyjs/ast/-/ast-1.7.11.tgz",
@ -5442,12 +5518,13 @@
"dev": true
},
"clean-webpack-plugin": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/clean-webpack-plugin/-/clean-webpack-plugin-1.0.0.tgz",
"integrity": "sha512-+f96f52UIET4tOFBbCqezx7KH+w7lz/p4fA1FEjf0hC6ugxqwZedBtENzekN2FnmoTF/bn1LrlkvebOsDZuXKw==",
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/clean-webpack-plugin/-/clean-webpack-plugin-3.0.0.tgz",
"integrity": "sha512-MciirUH5r+cYLGCOL5JX/ZLzOZbVr1ot3Fw+KcvbhUb6PM+yycqd9ZhIlcigQ5gl+XhppNmw3bEFuaaMNyLj3A==",
"dev": true,
"requires": {
"rimraf": "^2.6.1"
"@types/webpack": "^4.4.31",
"del": "^4.1.1"
}
},
"cli-boxes": {
@ -6825,6 +6902,56 @@
}
}
},
"del": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/del/-/del-4.1.1.tgz",
"integrity": "sha512-QwGuEUouP2kVwQenAsOof5Fv8K9t3D8Ca8NxcXKrIpEHjTXK5J2nXLdP+ALI1cgv8wj7KuwBhTwBkOZSJKM5XQ==",
"dev": true,
"requires": {
"@types/glob": "^7.1.1",
"globby": "^6.1.0",
"is-path-cwd": "^2.0.0",
"is-path-in-cwd": "^2.0.0",
"p-map": "^2.0.0",
"pify": "^4.0.1",
"rimraf": "^2.6.3"
},
"dependencies": {
"globby": {
"version": "6.1.0",
"resolved": "https://registry.npmjs.org/globby/-/globby-6.1.0.tgz",
"integrity": "sha1-9abXDoOV4hyFj7BInWTfAkJNUGw=",
"dev": true,
"requires": {
"array-union": "^1.0.1",
"glob": "^7.0.3",
"object-assign": "^4.0.1",
"pify": "^2.0.0",
"pinkie-promise": "^2.0.0"
},
"dependencies": {
"pify": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz",
"integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=",
"dev": true
}
}
},
"p-map": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/p-map/-/p-map-2.1.0.tgz",
"integrity": "sha512-y3b8Kpd8OAN444hxfBbFfj1FY/RjtTd8tzYwhUqNYXx0fXx2iX4maP4Qr6qhIKbQXI02wTLAda4fYUbDagTUFw==",
"dev": true
},
"pify": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/pify/-/pify-4.0.1.tgz",
"integrity": "sha512-uB80kBFb/tfd68bVleG9T5GGsGPjJrLAUpR5PZIrhBnIaRTQRjqdJSsIKkOP6OAIFbj7GOrcudc5pNjZ+geV2g==",
"dev": true
}
}
},
"delayed-stream": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz",
@ -10904,6 +11031,30 @@
"integrity": "sha1-PkcprB9f3gJc19g6iW2rn09n2w8=",
"dev": true
},
"is-path-cwd": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/is-path-cwd/-/is-path-cwd-2.2.0.tgz",
"integrity": "sha512-w942bTcih8fdJPJmQHFzkS76NEP8Kzzvmw92cXsazb8intwLqPibPPdXf4ANdKV3rYMuuQYGIWtvz9JilB3NFQ==",
"dev": true
},
"is-path-in-cwd": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/is-path-in-cwd/-/is-path-in-cwd-2.1.0.tgz",
"integrity": "sha512-rNocXHgipO+rvnP6dk3zI20RpOtrAM/kzbB258Uw5BWr3TpXi861yzjo16Dn4hUox07iw5AyeMLHWsujkjzvRQ==",
"dev": true,
"requires": {
"is-path-inside": "^2.1.0"
}
},
"is-path-inside": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-2.1.0.tgz",
"integrity": "sha512-wiyhTzfDWsvwAW53OBWF5zuvaOGlZ6PwYxAbPVDhpm+gM09xKQGjBq/8uYN12aDvMxnAnq3dxTyoSoRNmg5YFg==",
"dev": true,
"requires": {
"path-is-inside": "^1.0.2"
}
},
"is-plain-obj": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-1.1.0.tgz",
@ -13662,6 +13813,12 @@
"integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=",
"dev": true
},
"path-is-inside": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/path-is-inside/-/path-is-inside-1.0.2.tgz",
"integrity": "sha1-NlQX3t5EQw0cEa9hAn+s8HS9/FM=",
"dev": true
},
"path-key": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/path-key/-/path-key-2.0.1.tgz",

View file

@ -31,7 +31,7 @@
"@wikimedia/mw-node-qunit": "6.1.0",
"babel-loader": "8.0.4",
"bundlesize": "0.18.0",
"clean-webpack-plugin": "1.0.0",
"clean-webpack-plugin": "3.0.0",
"cssjanus": "1.3.1",
"eslint-config-wikimedia": "0.15.3",
"expose-loader": "0.7.5",

BIN
resources/dist/.eslintrc.js vendored Normal file

Binary file not shown.

View file

@ -1,5 +1,5 @@
/* eslint-env node */
const CleanPlugin = require( 'clean-webpack-plugin' );
const { CleanWebpackPlugin } = require( 'clean-webpack-plugin' );
const path = require( 'path' );
const PUBLIC_PATH = '/w/extensions/Popups';
@ -100,7 +100,9 @@ module.exports = ( env, argv ) => ( {
plugins: [
// Delete the output directory on each build.
new CleanPlugin( distDir, { verbose: false } )
new CleanWebpackPlugin( {
cleanOnceBeforeBuildPatterns: [ '**/*', '!.eslintrc.js' ]
} )
],
performance: {