diff --git a/lib/parse-variable.js b/lib/parse-variable.js index ef2d614..bba41af 100644 --- a/lib/parse-variable.js +++ b/lib/parse-variable.js @@ -27,7 +27,12 @@ const findVars = (node, result, ignoreList) => { return; } - if (node instanceof Declaration && node.prop.startsWith('$') && !ignoreList.includes(node.prop) && fusvEnabled) { + if ( + node instanceof Declaration && + (node.prop.startsWith('$') || node.prop.startsWith('--')) && + !ignoreList.includes(node.prop) && + fusvEnabled + ) { result.push(new UnusedInfo(node)); return; } diff --git a/package.json b/package.json index 51c6d2c..58e00c2 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,7 @@ "lint": "xo", "fix": "xo --fix", "test": "npm-run-all --aggregate-output --continue-on-error --parallel --parallel test:*", - "test:cli": "node ./bin/cli.js tests/ --ignore=\"$a,$b\" --ignoreFiles=\"**/ignored-file*.scss\"", + "test:cli": "node ./bin/cli.js tests/ --ignore=\"$a,$b,--a,--b\" --ignoreFiles=\"**/ignored-file*.scss\"", "test:integration": "node tests/integration.js", "test:options": "node tests/options.js", "test-ci": "npm-run-all --aggregate-output --continue-on-error --parallel test:integration test:options" diff --git a/tests/fixtures/_variables.scss b/tests/fixtures/_variables.scss index cca75b6..db03129 100644 --- a/tests/fixtures/_variables.scss +++ b/tests/fixtures/_variables.scss @@ -17,3 +17,15 @@ $disabled-variable: #bada55; // fusv-enable $enabled-variable: #b000b5; + +:root { + --a: 10px; + --b: 20px; + --black-light: #{$black-light}; + --black-lightest: #{$black-lightest}; + --ignored-variable: #ace; + // fusv-disable + --disabled-variable: #bada55; + // fusv-enable + --enabled-variable: #101; +} diff --git a/tests/fixtures/ignored-file.scss b/tests/fixtures/ignored-file.scss index 474231f..a36a7e9 100644 --- a/tests/fixtures/ignored-file.scss +++ b/tests/fixtures/ignored-file.scss @@ -1,2 +1,5 @@ // unused but ignored file variables $unused-but-ignored : #000; +:root { + --unused-but-ignored: #000; +} diff --git a/tests/fixtures/test.scss b/tests/fixtures/test.scss index de085e9..fac7741 100644 --- a/tests/fixtures/test.scss +++ b/tests/fixtures/test.scss @@ -22,3 +22,11 @@ .black-lightest { background-color: $black-lightest; } + +.modal-black-light { + background-color: var(--black-light); +} + +.modal-black-lightest { + background-color: var(--black-lightest); +} diff --git a/tests/integration.js b/tests/integration.js index 4b5532f..ab66310 100644 --- a/tests/integration.js +++ b/tests/integration.js @@ -9,9 +9,12 @@ const expectedUnused = [ '$black', '$nestedVar', '$nestNestedVar', - '$enabled-variable' + '$enabled-variable', + '--a', + '--b', + '--enabled-variable' ]; -const ignore = ['$ignored-variable']; +const ignore = ['$ignored-variable', '--ignored-variable']; const ignoreFiles = ['**/ignored-file*.scss']; const runTests = (type, result) => { diff --git a/tests/options.js b/tests/options.js index ca83ae9..1bb1bd6 100644 --- a/tests/options.js +++ b/tests/options.js @@ -11,16 +11,23 @@ const allExpectedUnused = [ '$nestedVar', '$nestNestedVar', '$enabled-variable', - '$ignored-variable' + '$ignored-variable', + '--a', + '--b', + '--ignored-variable', + '--enabled-variable' ]; const expectedUnused = [ '$unused', '$black', '$nestedVar', '$nestNestedVar', - '$enabled-variable' + '$enabled-variable', + '--a', + '--b', + '--enabled-variable' ]; -const ignore = ['$ignored-variable', '$a', '$b']; +const ignore = ['$ignored-variable', '$a', '$b', '--ignored-variable']; const ignoreFiles = ['**/ignored-file*.scss']; console.log('Running "Options" tests...');