]> git.ipfire.org Git - thirdparty/bootstrap.git/commitdiff
Clean up and tweak ESLint rules.
authorXhmikosR <xhmikosr@gmail.com>
Sat, 16 Dec 2017 11:44:17 +0000 (13:44 +0200)
committerXhmikosR <xhmikosr@gmail.com>
Thu, 11 Jan 2018 16:48:46 +0000 (18:48 +0200)
Also, refactor ESLint and stylelint config files; now everything will work from our root dir.

12 files changed:
.eslintignore
.eslintrc.json [moved from js/.eslintrc.json with 95% similarity]
.stylelintignore [new file with mode: 0644]
.stylelintrc [moved from build/.stylelintrc with 100% similarity]
assets/js/.eslintrc.json [new file with mode: 0644]
assets/js/src/ie-emulation-modes-warning.js
build/.eslintrc.json [new file with mode: 0644]
docs/4.0/examples/.eslintrc.json [new file with mode: 0644]
docs/4.0/examples/.stylelintrc
js/tests/karma.conf.js
js/tests/unit/.eslintrc.json [moved from js/tests/.eslintrc.json with 59% similarity]
package.json

index 8e0f5225cf236f4696d613ff67159c8ee6e02890..e1d5490eef65f63241681755659c1bba976a01f5 100644 (file)
@@ -1,3 +1,5 @@
 **/*.min.js
-**/vendor/*
-**/dist/*
+**/dist/
+**/vendor/
+/_gh_pages/
+/package.js
similarity index 95%
rename from js/.eslintrc.json
rename to .eslintrc.json
index fc5f6a49168d47690af742c092971c92cf37e1bd..8cfaeea153db3c90fa2054b012370d22c2f19a33 100644 (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",
     "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],
     "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",
     "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",
     "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",
     "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",
diff --git a/.stylelintignore b/.stylelintignore
new file mode 100644 (file)
index 0000000..7bc488e
--- /dev/null
@@ -0,0 +1,4 @@
+**/*.min.css
+**/dist/
+**/vendor/
+/_gh_pages/
similarity index 100%
rename from build/.stylelintrc
rename to .stylelintrc
diff --git a/assets/js/.eslintrc.json b/assets/js/.eslintrc.json
new file mode 100644 (file)
index 0000000..7ea25a9
--- /dev/null
@@ -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"
+  }
+}
index c8984cc35fd48b436c011372c8b82494a20e0358..ca2ae1222bb1c4f81de009fe614e36212d4fad1a 100644 (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!')
   }
 }())
diff --git a/build/.eslintrc.json b/build/.eslintrc.json
new file mode 100644 (file)
index 0000000..76e7f37
--- /dev/null
@@ -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"
+  }
+}
diff --git a/docs/4.0/examples/.eslintrc.json b/docs/4.0/examples/.eslintrc.json
new file mode 100644 (file)
index 0000000..f04fd6a
--- /dev/null
@@ -0,0 +1,11 @@
+{
+  "env": {
+    "es6": false,
+    "jquery": true
+  },
+  "parserOptions": {
+    "ecmaVersion": 5,
+    "sourceType": "script"
+  },
+  "extends": "../../../js/tests/unit/.eslintrc.json"
+}
index 44cf7c0e0f8a91e583022b9bb9703bd12df98e54..6a77dcedb652626fbd30582ddf2639de41b32387 100644 (file)
@@ -1,5 +1,5 @@
 {
-  "extends": "../../../build/.stylelintrc",
+  "extends": "../../../.stylelintrc",
   "rules": {
     "at-rule-no-vendor-prefix": null,
     "comment-empty-line-before": null,
index da4e1ccb19d307f095c8870d3e9b034795c1772d..57d44718da80b13d82897c122907ae0b67e25fc4 100644 (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'
similarity index 59%
rename from js/tests/.eslintrc.json
rename to js/tests/unit/.eslintrc.json
index 1452045e21f7c53050153091d51812fdbefdefce..9e1c60a6cd1460c955947b4d68d1da4d84840968 100644 (file)
     "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
index 95b3e07cdb73ed525913c383dc006b938e904337..4335f2778b96271dd10dda5e9c930030cc11854f 100644 (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",