at path:
ROOT
/
sistema
/
vendors
/
bootstrap
/
build
/
lint-vars.js
run:
R
W
Run
.eslintrc.json
385 By
2018-11-08 02:46:18
R
W
Run
Delete
Rename
.htmllintrc
1.27 KB
2018-11-08 02:46:18
R
W
Run
Delete
Rename
build-plugins.js
2.45 KB
2018-11-08 02:46:18
R
W
Run
Delete
Rename
change-version.js
2.68 KB
2018-11-08 02:46:18
R
W
Run
Delete
Rename
gcp-key.json.enc
2.25 KB
2018-11-08 02:46:18
R
W
Run
Delete
Rename
generate-sri.js
1.5 KB
2018-11-08 02:46:18
R
W
Run
Delete
Rename
lint-vars.js
2.02 KB
2018-11-08 02:46:18
R
W
Run
Delete
Rename
postcss.config.js
238 By
2018-11-08 02:46:18
R
W
Run
Delete
Rename
rollup.config.js
1.38 KB
2018-11-08 02:46:18
R
W
Run
Delete
Rename
sauce_browsers.json
1.19 KB
2018-11-08 02:46:18
R
W
Run
Delete
Rename
saucelabs-unit-test.js
3.2 KB
2018-11-08 02:46:18
R
W
Run
Delete
Rename
ship.sh
2.77 KB
2018-11-08 02:46:18
R
W
Run
Delete
Rename
vnu-jar.js
2.53 KB
2018-11-08 02:46:18
R
W
Run
Delete
Rename
workbox.config.json
161 By
2018-11-08 02:46:18
R
W
Run
Delete
Rename
workbox.js
1.69 KB
2018-11-08 02:46:18
R
W
Run
Delete
Rename
error_log
up
📄
lint-vars.js
Save
#!/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) */ 'use strict' 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))