eslint-plugin-tailwindcss
Advanced tools
Comparing version 2.0.0 to 2.0.1-beta.0
@@ -225,4 +225,9 @@ /** | ||
const range = astUtil.extractRangeFromNode(node); | ||
start = range[0] + 1; | ||
end = range[1] - 1; | ||
if (node.type === 'TextAttribute') { | ||
start = range[0]; | ||
end = range[1]; | ||
} else { | ||
start = range[0] + 1; | ||
end = range[1] - 1; | ||
} | ||
} else { | ||
@@ -331,9 +336,13 @@ switch (arg.type) { | ||
//---------------------------------------------------------------------- | ||
const attributeVisitor = function (node) { | ||
if (!astUtil.isValidJSXAttribute(node)) { | ||
return; | ||
} | ||
sortNodeArgumentValue(node); | ||
}; | ||
const scriptVisitor = { | ||
JSXAttribute: function (node) { | ||
if (!astUtil.isValidJSXAttribute(node)) { | ||
return; | ||
} | ||
sortNodeArgumentValue(node); | ||
}, | ||
JSXAttribute: attributeVisitor, | ||
TextAttribute: attributeVisitor, | ||
CallExpression: function (node) { | ||
@@ -340,0 +349,0 @@ if (callees.findIndex((name) => node.callee.name === name) === -1) { |
@@ -132,9 +132,12 @@ /** | ||
const attributeVisitor = function (node) { | ||
if (!astUtil.isValidJSXAttribute(node)) { | ||
return; | ||
} | ||
astUtil.parseNodeRecursive(node, null, parseForContradictingClassNames, true); | ||
}; | ||
const scriptVisitor = { | ||
JSXAttribute: function (node) { | ||
if (!astUtil.isValidJSXAttribute(node)) { | ||
return; | ||
} | ||
astUtil.parseNodeRecursive(node, null, parseForContradictingClassNames, true); | ||
}, | ||
JSXAttribute: attributeVisitor, | ||
TextAttribute: attributeVisitor, | ||
CallExpression: function (node) { | ||
@@ -141,0 +144,0 @@ if (callees.findIndex((name) => node.callee.name === name) === -1) { |
@@ -128,9 +128,12 @@ /** | ||
const attributeVisitor = function (node) { | ||
if (!astUtil.isValidJSXAttribute(node)) { | ||
return; | ||
} | ||
astUtil.parseNodeRecursive(node, null, parseForCustomClassNames); | ||
}; | ||
const scriptVisitor = { | ||
JSXAttribute: function (node) { | ||
if (!astUtil.isValidJSXAttribute(node)) { | ||
return; | ||
} | ||
astUtil.parseNodeRecursive(node, null, parseForCustomClassNames); | ||
}, | ||
JSXAttribute: attributeVisitor, | ||
TextAttribute: attributeVisitor, | ||
CallExpression: function (node) { | ||
@@ -137,0 +140,0 @@ if (callees.findIndex((name) => node.callee.name === name) === -1) { |
@@ -7,2 +7,6 @@ /** | ||
// context.parserPath | ||
// /.../eslint-plugin-tailwindcss/node_modules/espree/espree.js | ||
// /.../eslint-plugin-tailwindcss/node_modules/@angular-eslint/template-parser/dist/index.js | ||
const attrUtil = require('./attr'); | ||
@@ -18,3 +22,14 @@ const removeDuplicatesFromArray = require('./removeDuplicatesFromArray'); | ||
function isClassAttribute(node) { | ||
return node.name && /^class(Name)?$/.test(node.name.name); | ||
if (!node.name) { | ||
return false; | ||
} | ||
let name = ''; | ||
switch (node.type) { | ||
case 'TextAttribute': | ||
name = node.name; | ||
break; | ||
default: | ||
name = node.name.name; | ||
} | ||
return /^class(Name)?$/.test(name); | ||
} | ||
@@ -52,2 +67,5 @@ | ||
function isLiteralAttributeValue(node) { | ||
if (node.type === 'TextAttribute' && node.name === 'class' && typeof node.value === 'string') { | ||
return true; | ||
} | ||
if (node.value) { | ||
@@ -103,2 +121,5 @@ switch (node.value.type) { | ||
function extractRangeFromNode(node) { | ||
if (node.type === 'TextAttribute' && node.name === 'class') { | ||
return [node.valueSpan.fullStart.offset, node.valueSpan.end.offset]; | ||
} | ||
switch (node.value.type) { | ||
@@ -113,2 +134,5 @@ case 'JSXExpressionContainer': | ||
function extractValueFromNode(node) { | ||
if (node.type === 'TextAttribute' && node.name === 'class') { | ||
return node.value; | ||
} | ||
switch (node.value.type) { | ||
@@ -115,0 +139,0 @@ case 'JSXExpressionContainer': |
{ | ||
"name": "eslint-plugin-tailwindcss", | ||
"version": "2.0.0", | ||
"version": "2.0.1-beta.0", | ||
"description": "Rules enforcing best practices while using Tailwind CSS", | ||
@@ -21,2 +21,3 @@ "keywords": [ | ||
"scripts": { | ||
"wip": "mocha tests/lib/rules/wip/ --recursive", | ||
"test": "mocha tests --recursive" | ||
@@ -33,2 +34,3 @@ }, | ||
"devDependencies": { | ||
"@angular-eslint/template-parser": "^13.0.1", | ||
"@tailwindcss/aspect-ratio": "^0.2.0", | ||
@@ -35,0 +37,0 @@ "@tailwindcss/line-clamp": "^0.2.0", |
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
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
96414
2815
9
1