Skip to content

Commit 68a9397

Browse files
refactor: exporting separatorRegEx in regex.js
1 parent 594c75d commit 68a9397

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

lib/util/ast.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
'use strict';
66

7+
const { separatorRegEx } = require('./regex');
78
// context.parserPath
89
// /.../eslint-plugin-tailwindcss/node_modules/espree/espree.js
910
// /.../eslint-plugin-tailwindcss/node_modules/@angular-eslint/template-parser/dist/index.js
@@ -217,7 +218,6 @@ function extractClassnamesFromValue(classStr) {
217218
if (typeof classStr !== 'string') {
218219
return { classNames: [], whitespaces: [], headSpace: false, tailSpace: false };
219220
}
220-
const separatorRegEx = /([\t\n\f\r ]+)/;
221221
let parts = classStr.split(separatorRegEx);
222222
if (parts[0] === '') {
223223
parts.shift();

lib/util/prettier/order.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
const { separatorRegEx } = require('../regex');
2+
13
function bigSign(bigIntValue) {
24
return (bigIntValue > 0n) - (bigIntValue < 0n);
35
}
@@ -45,7 +47,7 @@ function sortClasses(classStr, { env, ignoreFirst = false, ignoreLast = false })
4547
}
4648

4749
let result = '';
48-
let parts = classStr.split(/([\t\n\f\r ]+)/);
50+
let parts = classStr.split(separatorRegEx);
4951
let classes = parts.filter((_, i) => i % 2 === 0);
5052
let whitespace = parts.filter((_, i) => i % 2 !== 0);
5153

lib/util/regex.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ function escapeRegex(input) {
88
return input.replace(/[/\-\\^$*+?.()|[\]{}]/g, '\\$&');
99
}
1010

11+
const separatorRegEx = /([\t\n\f\r ]+)/;
12+
1113
module.exports = {
1214
escapeRegex,
15+
separatorRegEx,
1316
};

0 commit comments

Comments
 (0)