Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Pedro Filipe Martins committed Aug 12, 2022
1 parent 7fdbbdb commit 47396be
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 3,549 deletions.
11 changes: 8 additions & 3 deletions lib/rules/no-contradicting-classname.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,18 @@ module.exports = {
classNames = sorted.filter((slot) => slot.length > 1);

// Sorts each groups' classnames
const arbitraryValues = String.raw`(\[(.*${mergedConfig.separator}))`
const arbitraryValuesOr = String.raw`(\[(.*${mergedConfig.separator}))|(^((?!:).)*$)`
const arbitraryRegex = new RegExp(arbitraryValues);

classNames.forEach((slot) => {
const variants = [];
slot.forEach((cls) => {
const start = cls.lastIndexOf(mergedConfig.separator) + 1;
const arbiratySeparator = arbitraryRegex.test(cls);
const start = arbiratySeparator? 0 : cls.lastIndexOf(mergedConfig.separator) + 1;
const prefix = cls.substr(0, start);
const name = cls.substr(start);
const rePrefix = prefix === '' ? '((?!:).)*$' : prefix;
const rePrefix = prefix === '' ? arbitraryValuesOr : '^' + prefix;
const idx = variants.findIndex((v) => v.prefix === rePrefix);
if (idx === -1) {
variants.push({
Expand All @@ -109,7 +114,7 @@ module.exports = {
const troubles = variants.filter((v) => v.name.length > 1);
if (troubles.length) {
troubles.forEach((issue) => {
const re = new RegExp('^' + issue.prefix);
const re = new RegExp(issue.prefix);
const conflicting = slot.filter((c) => re.test(c));
context.report({
node: node,
Expand Down
Loading

0 comments on commit 47396be

Please sign in to comment.