-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
31f241f
commit 6596ccd
Showing
9 changed files
with
308 additions
and
154 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
66 changes: 66 additions & 0 deletions
66
packages/stylelint/src/plugins/no-px-values/index.vitest.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import { test, expect } from 'vitest' | ||
|
||
const plugin = require('.') | ||
|
||
const { ruleName, messages } = plugin | ||
|
||
const stylelint = require('stylelint') | ||
|
||
test('it allows the use of valid space values on space properties', async () => { | ||
const code = ` | ||
margin: 1rem; | ||
padding: 1rem 0.5rem; | ||
padding-left: 1rem; | ||
top: 16px; | ||
` | ||
|
||
const result = await stylelint.lint({ | ||
code, | ||
config: { plugins: [plugin], rules: { [ruleName]: true } }, | ||
}) | ||
|
||
expect(result.results[0].warnings).toHaveLength(0) | ||
}) | ||
|
||
test('it disallows the use of px values on space properties', async () => { | ||
const code = ` | ||
margin: 16px; | ||
` | ||
|
||
const result = await stylelint.lint({ | ||
code, | ||
config: { | ||
plugins: [plugin], | ||
rules: { [ruleName]: true }, | ||
}, | ||
}) | ||
|
||
expect(result.results[0].warnings).toHaveLength(1) | ||
|
||
const warning = result.results[0].warnings[0] | ||
|
||
expect(warning.rule).toBe(ruleName) | ||
expect(warning.severity).toBe('error') | ||
expect(warning.text).toBe(messages.expected('margin', '16px', '1rem')) | ||
}) | ||
|
||
test('it fix the error of invalid space property value to a valid one', async () => { | ||
const code = ` | ||
padding: 22px 8px; | ||
` | ||
|
||
const result = await stylelint.lint({ | ||
code, | ||
config: { | ||
fix: true, | ||
plugins: [plugin], | ||
rules: { [ruleName]: true }, | ||
}, | ||
}) | ||
|
||
expect(result.results[0].warnings).toHaveLength(0) | ||
|
||
expect(result.output).toBe(` | ||
padding: 1.375rem 0.5rem; | ||
`) | ||
}) |
39 changes: 0 additions & 39 deletions
39
packages/stylelint/src/plugins/no-text-property/index.test.js
This file was deleted.
Oops, something went wrong.
63 changes: 63 additions & 0 deletions
63
packages/stylelint/src/plugins/no-text-property/index.vitest.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import { test, expect } from 'vitest' | ||
|
||
const plugin = require('.') | ||
|
||
const { ruleName, messages } = plugin | ||
|
||
const stylelint = require('stylelint') | ||
|
||
test('it allows the use of valid typography properties and values', async () => { | ||
const code = ` | ||
font: var(--sl-text-body-font); | ||
` | ||
|
||
const result = await stylelint.lint({ | ||
code, | ||
config: { plugins: [plugin], rules: { [ruleName]: true } }, | ||
}) | ||
|
||
expect(result.results[0].warnings).toHaveLength(0) | ||
}) | ||
|
||
test('it disallows the use of invalid typography properties', async () => { | ||
const code = ` | ||
text: var(--sl-text-body); | ||
` | ||
|
||
const result = await stylelint.lint({ | ||
code, | ||
config: { plugins: [plugin], rules: { [ruleName]: true } }, | ||
}) | ||
|
||
expect(result.results[0].warnings).toHaveLength(1) | ||
|
||
const warning = result.results[0].warnings[0] | ||
|
||
expect(warning.rule).toBe(ruleName) | ||
expect(warning.severity).toBe('error') | ||
expect(warning.text).toBe(messages.expected) | ||
}) | ||
|
||
test('it fix the error of invalid typography property usage to a valid one', async () => { | ||
const code = ` | ||
text: var(--sl-text-body); | ||
` | ||
|
||
const result = await stylelint.lint({ | ||
code, | ||
config: { | ||
fix: true, | ||
plugins: [plugin], | ||
rules: { [ruleName]: true }, | ||
}, | ||
}) | ||
|
||
expect(result.results[0].warnings).toHaveLength(0) | ||
|
||
expect(result.results[0].warnings).toHaveLength(0) | ||
|
||
expect(result.output).toBe(` | ||
font: var(--sl-text-body-font); | ||
letter-spacing: var(--sl-text-body-letter-spacing); | ||
`) | ||
}) |
Oops, something went wrong.