Clean up and tweak ESLint rules.

Also, refactor ESLint and stylelint config files; now everything will work from our root dir.
This commit is contained in:
XhmikosR 2017-12-16 13:44:17 +02:00
parent 92cc0aba7b
commit 6d336502c7
12 changed files with 84 additions and 39 deletions

View File

@ -1,3 +1,5 @@
**/*.min.js
**/vendor/*
**/dist/*
**/dist/
**/vendor/
/_gh_pages/
/package.js

View File

@ -7,10 +7,6 @@
},
"extends": "eslint:recommended",
"plugins": ["compat"],
"parserOptions": {
"ecmaVersion": 8,
"sourceType": "module"
},
"rules": {
// Possible Errors
"no-await-in-loop": "error",
@ -85,7 +81,7 @@
"no-unused-expressions": "error",
"no-useless-call": "error",
"no-useless-concat": "error",
"no-useless-return": "off",
"no-useless-return": "error",
"no-void": "error",
"no-warning-comments": "off",
"no-with": "error",
@ -141,13 +137,12 @@
"id-blacklist": "error",
"id-length": "off",
"id-match": "error",
"indent": "off",
"indent-legacy": ["error", 2, { "SwitchCase": 1 }],
"indent": ["error", 2, { "SwitchCase": 1 }],
"jsx-quotes": "error",
"key-spacing": "off",
"keyword-spacing": "error",
"line-comment-position": "off",
"linebreak-style": ["error", "unix"],
"line-comment-position": "off",
"lines-around-comment": "off",
"lines-around-directive": "error",
"max-depth": ["error", 10],
@ -159,10 +154,9 @@
"max-statements-per-line": "error",
"multiline-ternary": "off",
"new-cap": ["error", { "capIsNewExceptionPattern": "$.*" }],
"new-parens": "error",
"newline-after-var": "off",
"newline-before-return": "off",
"newline-per-chained-call": ["error", { "ignoreChainWithDepth": 5 }],
"new-parens": "error",
"no-array-constructor": "error",
"no-bitwise": "error",
"no-continue": "off",
@ -171,6 +165,7 @@
"no-mixed-operators": "off",
"no-multi-assign": "error",
"no-multiple-empty-lines": "error",
"nonblock-statement-body-position": "error",
"no-negated-condition": "off",
"no-nested-ternary": "error",
"no-new-object": "error",
@ -182,15 +177,15 @@
"no-underscore-dangle": "off",
"no-unneeded-ternary": "error",
"no-whitespace-before-property": "error",
"nonblock-statement-body-position": "error",
"object-curly-newline": ["error", { "minProperties": 1 }],
"object-curly-spacing": ["error", "always"],
"object-property-newline": "error",
"one-var": ["error", "never"],
"one-var-declaration-per-line": "error",
"operator-assignment": "error",
"operator-linebreak": "off",
"padded-blocks": "off",
"operator-linebreak": "error",
"padded-blocks": ["error", "never"],
"padding-line-between-statements": "off",
"quote-props": ["error", "as-needed"],
"quotes": ["error", "single"],
"require-jsdoc": "off",
@ -200,8 +195,8 @@
"sort-vars": "error",
"space-before-blocks": "error",
"space-before-function-paren": ["error", {
"anonymous": "always",
"named": "never"
"anonymous": "always",
"named": "never"
}],
"space-in-parens": "error",
"space-infix-ops": "error",

4
.stylelintignore Normal file
View File

@ -0,0 +1,4 @@
**/*.min.css
**/dist/
**/vendor/
/_gh_pages/

26
assets/js/.eslintrc.json Normal file
View File

@ -0,0 +1,26 @@
{
"env": {
"es6": false,
"jquery": true
},
"parserOptions": {
"ecmaVersion": 5,
"sourceType": "script"
},
"extends": "../../.eslintrc.json",
"rules": {
// Best Practices
"no-magic-numbers": "off",
"vars-on-top": "off",
// Stylistic Issues
"spaced-comment": "off",
// ECMAScript 6
"no-var": "off",
"object-shorthand": "off",
"prefer-arrow-callback": "off",
"prefer-template": "off",
"prefer-rest-params": "off"
}
}

View File

@ -41,6 +41,7 @@
var nonEmulated = actualNonEmulatedIEMajorVersion()
if (emulated !== nonEmulated) {
// eslint-disable-next-line no-alert
window.alert('WARNING: You appear to be using IE' + nonEmulated + ' in IE' + emulated + ' emulation mode.\nIE emulation modes can behave significantly differently from ACTUAL older versions of IE.\nPLEASE DON\'T FILE BOOTSTRAP BUGS based on testing in IE emulation modes!')
}
}())

20
build/.eslintrc.json Normal file
View File

@ -0,0 +1,20 @@
{
"env": {
"browser": false,
"node": true
},
"parserOptions": {
"sourceType": "script"
},
"extends": "../.eslintrc.json",
"rules": {
"consistent-return": "off",
"func-style": "off",
"no-console": "off",
"no-magic-numbers": "off",
"no-process-env": "off",
"no-process-exit": "off",
"no-sync": "off",
"spaced-comment": "off"
}
}

View File

@ -0,0 +1,11 @@
{
"env": {
"es6": false,
"jquery": true
},
"parserOptions": {
"ecmaVersion": 5,
"sourceType": "script"
},
"extends": "../../../js/tests/unit/.eslintrc.json"
}

View File

@ -1,5 +1,5 @@
{
"extends": "../../../build/.stylelintrc",
"extends": "../../../.stylelintrc",
"rules": {
"at-rule-no-vendor-prefix": null,
"comment-empty-line-before": null,

View File

@ -1,6 +1,5 @@
/* eslint-env node */
'use strict'
/* eslint no-process-env: 0 */
module.exports = (config) => {
const jqueryFile = process.env.USE_OLD_JQUERY ? 'js/tests/vendor/jquery-1.9.1.min.js' : 'assets/js/vendor/jquery-slim.min.js'

View File

@ -11,29 +11,16 @@
"ecmaVersion": 5,
"sourceType": "script"
},
"extends": "../.eslintrc.json",
"extends": "../../../.eslintrc.json",
"rules": {
"no-console": "off",
// Best Practices
"consistent-return": "off",
"no-alert": "off",
"no-console": "off",
"no-empty-function": "off",
"no-extend-native": "off",
"no-magic-numbers": "off",
"vars-on-top": "off",
// NodeJS and CommonJS
"global-require": "off",
"no-process-env": "off",
"no-process-exit": "off",
"no-sync": "off",
// Stylistic Issues
"brace-style": "off",
"func-style": "off",
"max-statements-per-line": "off",
"object-curly-newline": "off",
"object-property-newline": "off",
"spaced-comment": "off",
// ECMAScript 6

View File

@ -23,8 +23,8 @@
"css-docs": "npm-run-all --parallel css-lint-docs css-compile-docs --sequential css-prefix-docs css-minify-docs",
"css-compile": "node-sass --output-style expanded --source-map true --source-map-contents true --precision 6 scss/bootstrap.scss dist/css/bootstrap.css && node-sass --output-style expanded --source-map true --source-map-contents true --precision 6 scss/bootstrap-grid.scss dist/css/bootstrap-grid.css && node-sass --output-style expanded --source-map true --source-map-contents true --precision 6 scss/bootstrap-reboot.scss dist/css/bootstrap-reboot.css",
"css-compile-docs": "node-sass --output-style expanded --source-map true --source-map-contents true --precision 6 assets/scss/docs.scss assets/css/docs.min.css",
"css-lint": "stylelint --config build/.stylelintrc --syntax scss \"scss/**/*.scss\"",
"css-lint-docs": "stylelint --config build/.stylelintrc --syntax scss \"assets/scss/*.scss\" && stylelint --config docs/4.0/examples/.stylelintrc \"docs/**/*.css\"",
"css-lint": "stylelint --syntax scss \"scss/**/*.scss\"",
"css-lint-docs": "stylelint --syntax scss \"assets/scss/*.scss\" && stylelint \"docs/**/*.css\"",
"css-lint-vars": "node build/lint-vars.js scss/ assets/scss/",
"css-prefix": "postcss --config build/postcss.config.js --replace \"dist/css/*.css\" \"!dist/css/*.min.css\"",
"css-prefix-docs": "postcss --config build/postcss.config.js --replace \"assets/css/docs.min.css\" \"docs/**/*.css\"",
@ -33,8 +33,8 @@
"js": "npm-run-all js-lint* js-compile js-minify",
"js-main": "npm-run-all js-lint js-compile js-minify",
"js-docs": "npm-run-all js-lint-docs js-minify-docs",
"js-lint": "eslint js/ && eslint --config js/tests/.eslintrc.json --env node build/",
"js-lint-docs": "eslint --config js/tests/.eslintrc.json assets/js/ docs/ sw.js",
"js-lint": "eslint js/ build/",
"js-lint-docs": "eslint assets/js/ docs/ sw.js",
"js-compile": "npm-run-all --parallel js-compile-*",
"js-compile-standalone": "rollup --environment BUNDLE:false --config build/rollup.config.js --sourcemap",
"js-compile-bundle": "rollup --environment BUNDLE:true --config build/rollup.config.js --sourcemap",