]> git.ipfire.org Git - thirdparty/bootstrap.git/commitdiff
Switch to find-unused-sass-variables for finding unused Sass variables.
authorXhmikosR <xhmikosr@gmail.com>
Mon, 17 Sep 2018 06:57:07 +0000 (09:57 +0300)
committerXhmikosR <xhmikosr@gmail.com>
Mon, 17 Sep 2018 16:34:15 +0000 (19:34 +0300)
build/lint-vars.js [deleted file]
package-lock.json
package.json

diff --git a/build/lint-vars.js b/build/lint-vars.js
deleted file mode 100644 (file)
index 8873d36..0000000
+++ /dev/null
@@ -1,80 +0,0 @@
-#!/usr/bin/env node
-
-/*!
- * Script to find unused Sass variables.
- * Copyright 2017-2018 The Bootstrap Authors
- * Copyright 2017-2018 Twitter, Inc.
- * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
- */
-
-const fs = require('fs')
-const path = require('path')
-const glob = require('glob')
-
-// Blame TC39... https://github.com/benjamingr/RegExp.escape/issues/37
-function regExpQuote(str) {
-  return str.replace(/[-\\^$*+?.()|[\]{}]/g, '\\$&')
-}
-
-let globalSuccess = true
-
-function findUnusedVars(dir) {
-  if (!(fs.existsSync(dir) && fs.statSync(dir).isDirectory())) {
-    console.log(`"${dir}": Not a valid directory!`)
-    process.exit(1)
-  }
-
-  console.log(`Finding unused variables in "${dir}"...`)
-
-  // A variable to handle success/failure message in this function
-  let unusedVarsFound = false
-
-  // Array of all Sass files' content
-  const sassFiles = glob.sync(path.join(dir, '**/*.scss'))
-  // String of all Sass files' content
-  let sassFilesString = ''
-
-  sassFiles.forEach((file) => {
-    sassFilesString += fs.readFileSync(file, 'utf8')
-  })
-
-  // Array of all Sass variables
-  const variables = sassFilesString.match(/(^\$[a-zA-Z0-9_-]+[^:])/gm)
-
-  console.log(`Found ${variables.length} total variables.`)
-
-  // Loop through each variable
-  variables.forEach((variable) => {
-    const re = new RegExp(regExpQuote(variable), 'g')
-    const count = (sassFilesString.match(re) || []).length
-
-    if (count === 1) {
-      console.log(`Variable "${variable}" is not being used.`)
-      unusedVarsFound = true
-      globalSuccess = false
-    }
-  })
-
-  if (unusedVarsFound === false) {
-    console.log(`No unused variables found in "${dir}".`)
-  }
-}
-
-function main(args) {
-  if (args.length < 1) {
-    console.log('Wrong arguments!')
-    console.log('Usage: lint-vars.js folder [, folder2...]')
-    process.exit(1)
-  }
-
-  args.forEach((arg) => {
-    findUnusedVars(arg)
-  })
-
-  if (globalSuccess === false) {
-    process.exit(1)
-  }
-}
-
-// The first and second args are: path/to/node script.js
-main(process.argv.slice(2))
index 2c2e33e3d9426f5ecdca7b07a0fa8bb9f9411c82..f408e25b71d8a272cec7a8fa655c04ff0598d0d9 100644 (file)
         "restore-cursor": "^2.0.0"
       }
     },
+    "cli-spinners": {
+      "version": "1.3.1",
+      "resolved": "https://registry.npmjs.org/cli-spinners/-/cli-spinners-1.3.1.tgz",
+      "integrity": "sha512-1QL4544moEsDVH9T/l6Cemov/37iv1RtoKf7NJ04A60+4MREXNfx/QvavbH6QoGdsD4N4Mwy49cmaINR/o2mdg==",
+      "dev": true
+    },
     "cli-table": {
       "version": "0.3.1",
       "resolved": "https://registry.npmjs.org/cli-table/-/cli-table-0.3.1.tgz",
         }
       }
     },
+    "clone": {
+      "version": "1.0.4",
+      "resolved": "https://registry.npmjs.org/clone/-/clone-1.0.4.tgz",
+      "integrity": "sha1-2jCcwmPfFZlMaIypAheco8fNfH4=",
+      "dev": true
+    },
     "clone-regexp": {
       "version": "1.0.1",
       "resolved": "https://registry.npmjs.org/clone-regexp/-/clone-regexp-1.0.1.tgz",
         "os-name": "~1.0.3"
       }
     },
+    "defaults": {
+      "version": "1.0.3",
+      "resolved": "https://registry.npmjs.org/defaults/-/defaults-1.0.3.tgz",
+      "integrity": "sha1-xlYFHpgX2f8I7YgUd/P+QBnz730=",
+      "dev": true,
+      "requires": {
+        "clone": "^1.0.2"
+      }
+    },
     "define-properties": {
       "version": "1.1.3",
       "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.1.3.tgz",
         }
       }
     },
+    "find-unused-sass-variables": {
+      "version": "0.2.1",
+      "resolved": "https://registry.npmjs.org/find-unused-sass-variables/-/find-unused-sass-variables-0.2.1.tgz",
+      "integrity": "sha512-AluOKUZHVERMDSjv6SUJ+k/ad6wgpqFsU6vZOTeGk+wZiE7K77I679qyVJP8pw9gr8zHiSdFRiqnRVpXNMyW1Q==",
+      "dev": true,
+      "requires": {
+        "chalk": "^2.4.1",
+        "glob": "^7.1.3",
+        "ora": "^3.0.0",
+        "postcss": "^7.0.2",
+        "postcss-scss": "^2.0.0"
+      }
+    },
     "find-up": {
       "version": "3.0.0",
       "resolved": "https://registry.npmjs.org/find-up/-/find-up-3.0.0.tgz",
         "wordwrap": "~1.0.0"
       }
     },
+    "ora": {
+      "version": "3.0.0",
+      "resolved": "https://registry.npmjs.org/ora/-/ora-3.0.0.tgz",
+      "integrity": "sha512-LBS97LFe2RV6GJmXBi6OKcETKyklHNMV0xw7BtsVn2MlsgsydyZetSCbCANr+PFLmDyv4KV88nn0eCKza665Mg==",
+      "dev": true,
+      "requires": {
+        "chalk": "^2.3.1",
+        "cli-cursor": "^2.1.0",
+        "cli-spinners": "^1.1.0",
+        "log-symbols": "^2.2.0",
+        "strip-ansi": "^4.0.0",
+        "wcwidth": "^1.0.1"
+      },
+      "dependencies": {
+        "ansi-regex": {
+          "version": "3.0.0",
+          "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz",
+          "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=",
+          "dev": true
+        },
+        "strip-ansi": {
+          "version": "4.0.0",
+          "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz",
+          "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=",
+          "dev": true,
+          "requires": {
+            "ansi-regex": "^3.0.0"
+          }
+        }
+      }
+    },
     "os-homedir": {
       "version": "1.0.2",
       "resolved": "https://registry.npmjs.org/os-homedir/-/os-homedir-1.0.2.tgz",
         }
       }
     },
+    "wcwidth": {
+      "version": "1.0.1",
+      "resolved": "https://registry.npmjs.org/wcwidth/-/wcwidth-1.0.1.tgz",
+      "integrity": "sha1-8LDc+RW8X/FSivrbLA4XtTLaL+g=",
+      "dev": true,
+      "requires": {
+        "defaults": "^1.0.3"
+      }
+    },
     "which": {
       "version": "1.3.1",
       "resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz",
index d9918cbc1dfee247ce096203d2182b5f5f338908..d85ea56f9ca5b2279462c643bd37544450ab94f5 100644 (file)
@@ -30,7 +30,7 @@
     "css-copy": "shx mkdir -p site/docs/4.1/dist/ && shx cp -r dist/css/ site/docs/4.1/dist/",
     "css-lint": "stylelint --syntax scss \"scss/**/*.scss\"",
     "css-lint-docs": "stylelint --syntax scss \"site/docs/4.1/assets/scss/*.scss\" && stylelint \"site/docs/**/*.css\"",
-    "css-lint-vars": "node build/lint-vars.js scss/ site/docs/",
+    "css-lint-vars": "fusv scss/ site/docs/",
     "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 \"site/docs/**/*.css\" \"site/docs/**/*.css\"",
     "css-minify": "cleancss --level 1 --format breaksWith=lf --source-map --source-map-inline-sources --output dist/css/bootstrap.min.css dist/css/bootstrap.css && cleancss --level 1 --format breaksWith=lf --source-map --source-map-inline-sources --output dist/css/bootstrap-grid.min.css dist/css/bootstrap-grid.css && cleancss --level 1 --format breaksWith=lf --source-map --source-map-inline-sources --output dist/css/bootstrap-reboot.min.css dist/css/bootstrap-reboot.css",
     "coveralls": "^3.0.2",
     "cross-env": "^5.2.0",
     "eslint": "^5.5.0",
+    "find-unused-sass-variables": "^0.2.1",
     "glob": "^7.1.3",
     "htmllint-cli": "^0.0.7",
     "http-server": "^0.11.1",