Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

logical properties #63

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ function trbl (prefix) {
])
}

function startEnd (prefix) {
return [prefix + '-start', prefix + '-end']
}

function minMax (suffix) {
return [suffix, 'min-' + suffix, 'max-' + suffix]
}
Expand Down Expand Up @@ -49,14 +53,18 @@ var positioning = []
'z-index'
])
.concat(trbl())
.concat(startEnd('inset-block'))
.concat(startEnd('inset-inline'))

var displayAndBoxModel = []
.concat([
'display',
'overflow'
])
.concat(minMax('width'))
.concat(minMax('inline-size'))
.concat(minMax('height'))
.concat(minMax('block-size'))
.concat([
'box-sizing',
'flex',
Expand All @@ -73,13 +81,28 @@ var displayAndBoxModel = []
'order'
])
.concat(trbl('padding'))
.concat(startEnd('padding-block'))
.concat(startEnd('padding-inline'))
.concat([]
.concat(border())
.concat(border('top'))
.concat(border('right'))
.concat(border('bottom'))
.concat(border('left')))
.concat(border('left'))
.concat(border('block-start'))
.concat(border('block-end'))
.concat(border('inline-start'))
.concat(border('inline-end'))
.concat([
'border-start-start-radius',
'border-start-end-radius',
'border-end-start-radius',
'border-end-end-radius'
])
)
.concat(trbl('margin'))
.concat(startEnd('margin-block'))
.concat(startEnd('margin-inline'))

module.exports = {
plugins: 'stylelint-order',
Expand Down
80 changes: 80 additions & 0 deletions test/expectedLogicalProperties.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
.test-logical-properties {
top: 10;
right: 10;
bottom: 10;
left: 10;
inset-block-start: 20;
inset-block-end: 20;
inset-inline-start: 20;
inset-inline-end: 20;

width: 40;
min-width: 40;
max-width: 40;
inline-size: 40;
min-inline-size: 40;
max-inline-size: 40;
height: 40;
min-height: 40;
max-height: 40;
block-size: 40;
min-block-size: 40;
max-block-size: 40;

padding: 30;
padding-top: 30;
padding-right: 30;
padding-bottom: 30;
padding-left: 30;
padding-block-start: 30;
padding-block-end: 30;
padding-inline-start: 30;
padding-inline-end: 30;

border-top: 1px solid red;
border-top-width: 50;
border-top-style: dotted;
border-top-color: red;
border-right: 1px solid red;
border-right-width: 50;
border-right-style: dotted;
border-right-color: red;
border-bottom: 1px solid red;
border-bottom-width: 50;
border-bottom-style: dotted;
border-bottom-color: red;
border-left: 1px solid red;
border-left-width: 50;
border-left-style: dotted;
border-left-color: red;
border-block-start: 1px solid red;
border-block-start-width: 50;
border-block-start-style: dotted;
border-block-start-color: red;
border-block-end: 1px solid red;
border-block-end-width: 50;
border-block-end-style: dotted;
border-block-end-color: red;
border-inline-start: 1px solid red;
border-inline-start-width: 50;
border-inline-start-style: dotted;
border-inline-start-color: red;
border-inline-end: 1px solid red;
border-inline-end-width: 50;
border-inline-end-style: dotted;
border-inline-end-color: red;
border-start-start-radius: 15;
border-start-end-radius: 15;
border-end-start-radius: 15;
border-end-end-radius: 15;

margin: 30;
margin-top: 30;
margin-right: 30;
margin-bottom: 30;
margin-left: 30;
margin-block-start: 30;
margin-block-end: 30;
margin-inline-start: 30;
margin-inline-end: 30;
}
80 changes: 80 additions & 0 deletions test/fixtureLogicalProperties.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
.test-logical-properties {
top: 10;
right: 10;
bottom: 10;
left: 10;
inset-block-start: 20;
inset-block-end: 20;
inset-inline-start: 20;
inset-inline-end: 20;

margin: 30;
margin-top: 30;
margin-right: 30;
margin-bottom: 30;
margin-left: 30;
margin-block-start: 30;
margin-block-end: 30;
margin-inline-start: 30;
margin-inline-end: 30;

padding: 30;
padding-top: 30;
padding-right: 30;
padding-bottom: 30;
padding-left: 30;
padding-block-start: 30;
padding-block-end: 30;
padding-inline-start: 30;
padding-inline-end: 30;

width: 40;
min-width: 40;
max-width: 40;
inline-size: 40;
min-inline-size: 40;
max-inline-size: 40;
height: 40;
min-height: 40;
max-height: 40;
block-size: 40;
min-block-size: 40;
max-block-size: 40;

border-top: 1px solid red;
border-block-start: 1px solid red;
border-top-color: red;
border-block-start-color: red;
border-top-style: dotted;
border-block-start-style: dotted;
border-top-width: 50;
border-block-start-width: 50;
border-bottom: 1px solid red;
border-block-end: 1px solid red;
border-bottom-color: red;
border-block-end-color: red;
border-bottom-style: dotted;
border-block-end-style: dotted;
border-bottom-width: 50;
border-block-end-width: 50;
border-left: 1px solid red;
border-inline-start: 1px solid red;
border-left-color: red;
border-inline-start-color: red;
border-left-style: dotted;
border-inline-start-style: dotted;
border-left-width: 50;
border-inline-start-width: 50;
border-right: 1px solid red;
border-inline-end: 1px solid red;
border-right-color: red;
border-inline-end-color: red;
border-right-style: dotted;
border-inline-end-style: dotted;
border-right-width: 50;
border-inline-end-width: 50;
border-start-start-radius: 15;
border-start-end-radius: 15;
border-end-start-radius: 15;
border-end-end-radius: 15;
}
16 changes: 15 additions & 1 deletion test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,22 @@ function testOrder () {
})
}

function testLogicalPropertiesOrder () {
const fixture = fs.readFileSync(path.join(__dirname, 'fixtureLogicalProperties.css'), 'utf8')
const expected = fs.readFileSync(path.join(__dirname, 'expectedLogicalProperties.css'), 'utf8')

return stylelint.lint({
code: fixture,
config: require('..'),
fix: true
}).then(result => {
assert.strictEqual(result.errored, false)
assert.strictEqual(result.output, expected, 'Stylelint output does not equal expected output')
})
}

Promise
.all([testConfigFile(), testOrder()])
.all([testConfigFile(), testOrder(), testLogicalPropertiesOrder()])
.then(() => console.log('OK'))
.catch(e => {
console.error(e.name, e.message)
Expand Down