Skip to content

Commit

Permalink
custom-property-pattern rule changed for compatibility with WP nami…
Browse files Browse the repository at this point in the history
…ng (#2539)

## Type of change

**MAJOR: breaking change**
fix #2538
  • Loading branch information
cawa-93 committed Jan 9, 2024
1 parent d5189fd commit 07083aa
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 1 deletion.
7 changes: 6 additions & 1 deletion sources/@roots/bud-preset-wordpress/config/stylelint.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
*/
module.exports = {
rules: {
'custom-property-pattern': null,
'custom-property-pattern': [
`^([a-z][a-z0-9]*)(-{1,2}[a-z0-9]+)*$`,
{
message: name => `Expected custom property name "${name}" to be kebab-case`,
},
],
},
}
39 changes: 39 additions & 0 deletions sources/@roots/bud-preset-wordpress/test/stylelint-config.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import * as stylelint from 'stylelint'
import {describe, expect, it} from 'vitest'

describe(`@roots/bud-preset-wordpress/stylelint`, () => {
it(`should error without rule`, async () => {
const result = await stylelint.lint({
code: `
.foo {
color: var(--wp--preset--color--primary);
}
`,
config: {
extends: [
`@roots/bud-sass/stylelint-config`,
],
},
})

expect(result.errored).toBe(true)
})

it(`should not error with rule`, async () => {
const result = await stylelint.lint({
code: `
.foo {
color: var(--wp--preset--color--primary);
}
`,
config: {
extends: [
`@roots/bud-sass/stylelint-config`,
`@roots/bud-preset-wordpress/stylelint`,
],
},
})

expect(result.errored).toBe(false)
})
})

0 comments on commit 07083aa

Please sign in to comment.