eslint-plugin-tailwindcss
Advanced tools
Comparing version 3.10.1-beta.2 to 3.10.1-beta.3
@@ -51,6 +51,2 @@ /** | ||
}, | ||
rangeOffset: { | ||
default: 0, | ||
type: 'number', | ||
}, | ||
removeDuplicates: { | ||
@@ -103,4 +99,3 @@ default: true, | ||
originalClassNamesValue = astUtil.extractValueFromNode(node); | ||
const rangeOffset = getOption('rangeOffset'); | ||
const range = astUtil.extractRangeFromNode(node, rangeOffset); | ||
const range = astUtil.extractRangeFromNode(node); | ||
if (node.type === 'TextAttribute') { | ||
@@ -254,3 +249,3 @@ start = range[0]; | ||
switch (true) { | ||
case !astUtil.isValidVueAttribute(node): | ||
case !astUtil.isValidVueAttribute(node, classRegex): | ||
return; | ||
@@ -257,0 +252,0 @@ case astUtil.isVLiteralValue(node): |
@@ -191,3 +191,3 @@ /** | ||
switch (true) { | ||
case !astUtil.isValidVueAttribute(node): | ||
case !astUtil.isValidVueAttribute(node, classRegex): | ||
return; | ||
@@ -194,0 +194,0 @@ case astUtil.isVLiteralValue(node): |
@@ -424,3 +424,3 @@ /** | ||
switch (true) { | ||
case !astUtil.isValidVueAttribute(node): | ||
case !astUtil.isValidVueAttribute(node, classRegex): | ||
return; | ||
@@ -427,0 +427,0 @@ case astUtil.isVLiteralValue(node): |
@@ -302,3 +302,3 @@ /** | ||
switch (true) { | ||
case !astUtil.isValidVueAttribute(node): | ||
case !astUtil.isValidVueAttribute(node, classRegex): | ||
return; | ||
@@ -305,0 +305,0 @@ case astUtil.isVLiteralValue(node): |
@@ -191,3 +191,3 @@ /** | ||
switch (true) { | ||
case !astUtil.isValidVueAttribute(node): | ||
case !astUtil.isValidVueAttribute(node, classRegex): | ||
return; | ||
@@ -194,0 +194,0 @@ case astUtil.isVLiteralValue(node): |
@@ -219,3 +219,3 @@ /** | ||
switch (true) { | ||
case !astUtil.isValidVueAttribute(node): | ||
case !astUtil.isValidVueAttribute(node, classRegex): | ||
return; | ||
@@ -222,0 +222,0 @@ case astUtil.isVLiteralValue(node): |
@@ -190,3 +190,3 @@ /** | ||
switch (true) { | ||
case !astUtil.isValidVueAttribute(node): | ||
case !astUtil.isValidVueAttribute(node, classRegex): | ||
return; | ||
@@ -193,0 +193,0 @@ case astUtil.isVLiteralValue(node): |
@@ -12,3 +12,2 @@ /** | ||
const removeDuplicatesFromArray = require('./removeDuplicatesFromArray'); | ||
const getOption = require('./settings'); | ||
@@ -41,10 +40,12 @@ /** | ||
* @param {ASTNode} node The AST node being checked | ||
* @param {String} classRegex Regex to test the attribute that is being checked against | ||
* @returns {Boolean} | ||
*/ | ||
function isVueClassAttribute(node) { | ||
function isVueClassAttribute(node, classRegex) { | ||
const re = new RegExp(classRegex); | ||
let name = ''; | ||
switch (true) { | ||
case node.key && /^class$/.test(node.key.name): | ||
case node.key && node.key.name && re.test(node.key.name): | ||
// class="vue-classes-as-litteral" | ||
return true; | ||
break; | ||
case node.key && | ||
@@ -56,7 +57,6 @@ node.key.name && | ||
/^bind$/.test(node.key.name.name) && | ||
/^class$/.test(node.key.argument.name): | ||
re.test(node.key.argument.name): | ||
// v-bind:class="vue-classes-as-bind" | ||
// :class="vue-classes-as-bind" | ||
return true; | ||
break; | ||
default: | ||
@@ -161,6 +161,7 @@ return false; | ||
* @param {ASTNode} node The AST node being checked | ||
* @param {String} classRegex Regex to test the attribute that is being checked against | ||
* @returns {Boolean} | ||
*/ | ||
function isValidVueAttribute(node) { | ||
if (!isVueClassAttribute(node)) { | ||
function isValidVueAttribute(node, classRegex) { | ||
if (!isVueClassAttribute(node, classRegex)) { | ||
// Only run for class attributes | ||
@@ -176,5 +177,5 @@ return false; | ||
function extractRangeFromNode(node, rangeOffset = 0) { | ||
function extractRangeFromNode(node) { | ||
if (node.type === 'TextAttribute' && node.name === 'class') { | ||
return [node.valueSpan.fullStart.offset + rangeOffset, node.valueSpan.end.offset + rangeOffset]; | ||
return [node.valueSpan.fullStart.offset, node.valueSpan.end.offset]; | ||
} | ||
@@ -181,0 +182,0 @@ switch (node.value.type) { |
@@ -5,6 +5,3 @@ 'use strict'; | ||
// Options (defined at rule level) | ||
let options = {}; | ||
if (context.options && context.options[0]) { | ||
options = context.options[0]; | ||
} | ||
const options = context.options[0] || {}; | ||
if (options[name] != undefined) { | ||
@@ -25,4 +22,2 @@ return options[name]; | ||
return ['**/*.css', '!**/node_modules', '!**/.*', '!**/dist', '!**/build']; | ||
case 'rangeOffset': | ||
return 0; | ||
case 'removeDuplicates': | ||
@@ -37,3 +32,3 @@ return true; | ||
case 'classRegex': | ||
return '^class(Name)?$'; | ||
return "^class(Name)?$" | ||
} | ||
@@ -40,0 +35,0 @@ } |
{ | ||
"name": "eslint-plugin-tailwindcss", | ||
"version": "3.10.1-beta.2", | ||
"version": "3.10.1-beta.3", | ||
"description": "Rules enforcing best practices while using Tailwind CSS", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
173851
4615