@master/eslint-plugin-css 2.0.0-beta.180 → 2.0.0-beta.182
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/rules/class-order.js +3 -10
- package/package.json +1 -1
- package/tests/class-order.js +7 -7
package/lib/rules/class-order.js
CHANGED
|
@@ -12,7 +12,7 @@ const removeDuplicatesFromClassnamesAndWhitespaces = require('../util/removeDupl
|
|
|
12
12
|
const getOption = require('../util/settings')
|
|
13
13
|
const parserUtil = require('../util/parser')
|
|
14
14
|
|
|
15
|
-
const
|
|
15
|
+
const { reorderForReadableClasses } = require('@master/css')
|
|
16
16
|
|
|
17
17
|
//------------------------------------------------------------------------------
|
|
18
18
|
// Rule Definition
|
|
@@ -73,8 +73,6 @@ module.exports = {
|
|
|
73
73
|
const masterCssConfig = getOption(context, 'config')
|
|
74
74
|
const classRegex = getOption(context, 'classRegex')
|
|
75
75
|
|
|
76
|
-
const masterCss = new MasterCSS(masterCssConfig)
|
|
77
|
-
|
|
78
76
|
//----------------------------------------------------------------------
|
|
79
77
|
// Helpers
|
|
80
78
|
//----------------------------------------------------------------------
|
|
@@ -167,13 +165,8 @@ module.exports = {
|
|
|
167
165
|
return
|
|
168
166
|
}
|
|
169
167
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
let orderedClassNames = masterCss.rules
|
|
175
|
-
.filter(x => classNames.includes(x.className))
|
|
176
|
-
.map(x => x.className)
|
|
168
|
+
let orderedClassNames = reorderForReadableClasses(classNames, masterCssConfig)
|
|
169
|
+
.filter(eachOrderedClassName => classNames.includes(eachOrderedClassName))
|
|
177
170
|
|
|
178
171
|
orderedClassNames = orderedClassNames.concat(classNames.filter(x => !orderedClassNames.includes(x)))
|
|
179
172
|
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"@master/eslint-plugin-css","scripts":{"test":"mocha tests --recursive --timeout 10000"},"keywords":["mastercss","eslint","eslintplugin"],"license":"MIT","description":"Master CSS ESLint Plugin","author":"Aoyue Design LLC.","funding":"https://css.master.co/docs/donate","homepage":"https://css.master.co","bugs":{"url":"https://github.com/master-co/css/issues"},"repository":{"type":"git","url":"https://github.com/master-co/css.git","directory":"packages/eslint-plugin"},"sideEffects":false,"main":"./lib/index.js","exports":"./lib/index.js","publishConfig":{"access":"public"},"dependencies":{"@master/css":"^2.0.0-beta.
|
|
1
|
+
{"name":"@master/eslint-plugin-css","scripts":{"test":"mocha tests --recursive --timeout 10000"},"keywords":["mastercss","eslint","eslintplugin"],"license":"MIT","description":"Master CSS ESLint Plugin","author":"Aoyue Design LLC.","funding":"https://css.master.co/docs/donate","homepage":"https://css.master.co","bugs":{"url":"https://github.com/master-co/css/issues"},"repository":{"type":"git","url":"https://github.com/master-co/css.git","directory":"packages/eslint-plugin"},"sideEffects":false,"main":"./lib/index.js","exports":"./lib/index.js","publishConfig":{"access":"public"},"dependencies":{"@master/css":"^2.0.0-beta.182","requireindex":"^1.2.0","explore-config":"^2.2.10"},"devDependencies":{"@angular-eslint/template-parser":"^16.2.0","@typescript-eslint/parser":"^5.50.0","@types/node":"^20.6.0","mocha":"^10.2.0","eslint":"^7.1.0","vue-eslint-parser":"^9.3.1"},"version":"2.0.0-beta.182"}
|
package/tests/class-order.js
CHANGED
|
@@ -44,10 +44,10 @@ describe('class-order', function () {
|
|
|
44
44
|
ruleTester.run('class-order', rule, {
|
|
45
45
|
valid: [
|
|
46
46
|
{
|
|
47
|
-
code: `<div class="
|
|
47
|
+
code: `<div class="bg:black fg:white f:24 m:8 p:8">Simple, basic</div>`,
|
|
48
48
|
},
|
|
49
49
|
{
|
|
50
|
-
code: `<div test="
|
|
50
|
+
code: `<div test="bg:black fg:white f:24 m:8 p:8">Simple, using 'test' prop</div>`,
|
|
51
51
|
options: [
|
|
52
52
|
{
|
|
53
53
|
classRegex: '^test$',
|
|
@@ -82,7 +82,7 @@ describe('class-order', function () {
|
|
|
82
82
|
}: FakeProps) {
|
|
83
83
|
return (
|
|
84
84
|
<>
|
|
85
|
-
<h1 className={"
|
|
85
|
+
<h1 className={"bg:black fg:white f:24 m:8 p:8"}>Welcome {name}</h1>
|
|
86
86
|
<p>Bye {name}</p>
|
|
87
87
|
</>
|
|
88
88
|
);
|
|
@@ -94,12 +94,12 @@ describe('class-order', function () {
|
|
|
94
94
|
},
|
|
95
95
|
{
|
|
96
96
|
code: `<div class="fg:white f:24 m:8 p:8 bg:black">Classnames will be ordered</div>`,
|
|
97
|
-
output: `<div class="
|
|
97
|
+
output: `<div class="bg:black fg:white f:24 m:8 p:8">Classnames will be ordered</div>`,
|
|
98
98
|
errors: errors,
|
|
99
99
|
},
|
|
100
100
|
{
|
|
101
101
|
code: `<template><div class="m:8 bg:black p:8 fg:white f:24">Enhancing readability</div></template>`,
|
|
102
|
-
output: `<template><div class="
|
|
102
|
+
output: `<template><div class="bg:black fg:white f:24 m:8 p:8">Enhancing readability</div></template>`,
|
|
103
103
|
errors: errors,
|
|
104
104
|
filename: 'test.vue',
|
|
105
105
|
parser: require.resolve('vue-eslint-parser'),
|
|
@@ -117,11 +117,11 @@ describe('class-order', function () {
|
|
|
117
117
|
</div>`,
|
|
118
118
|
output: `
|
|
119
119
|
<div class="
|
|
120
|
-
m:8
|
|
121
|
-
p:8
|
|
122
120
|
bg:black
|
|
123
121
|
fg:white
|
|
124
122
|
f:24
|
|
123
|
+
m:8
|
|
124
|
+
p:8
|
|
125
125
|
">
|
|
126
126
|
:)
|
|
127
127
|
</div>`,
|