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

Require alignment of grid area names #2

Merged
merged 1 commit into from
May 17, 2024
Merged
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com), and 
### Changed

- The custom media queries should now be defined within the same source.
- The grid area names in the `grid-template-areas` property values should now be aligned.

### Fixed

Expand Down
7 changes: 7 additions & 0 deletions stylelint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,13 @@ export default {
"@stylistic/media-query-list-comma-newline-before": `never-multi-line`,
"@stylistic/media-query-list-comma-space-after": `always-single-line`,
"@stylistic/media-query-list-comma-space-before": `never-single-line`,
"@stylistic/named-grid-areas-alignment": [
true,
{
gap: 2,
alignQuotes: true,
},
],
"@stylistic/no-eol-whitespace": true,
"@stylistic/no-extra-semicolons": true,
"@stylistic/no-missing-end-of-source-newline": true,
Expand Down
106 changes: 106 additions & 0 deletions test/@stylistic/named-grid-areas-alignment.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
import { testRule } from "../../utils/testRule.js"

let plugin = {
name: `@stylistic/stylelint-plugin`,
prefix: `@stylistic/`,
}

let rule = `${plugin.prefix}named-grid-areas-alignment`

let code = `
.valid {
grid-template-areas:
"a a "
"foo foo "
"long-one long-one";
}

.invalid-1 {
grid-template-areas:
"a a"
"foo foo"
"long-one long-one";
}

.invalid-2 {
grid-template-areas:
"a a "
"foo foo "
"long-one long-one";
}

.invalid-3 {
grid-template-areas:
"a a"
"foo foo"
"long-one long-one";
}

.invalid-4 {
grid-template-areas:
"a a "
"foo foo "
"long-one long-one";
}

.invalid-5 {
grid-template-areas:
"a a "
"foo foo "
"long-one long-one";
}
`

testRule({
description: `Grid template areas should be aligned`,
rule,
plugin,
code,
expectedWarnings: [
{
line: 11,
column: 3,
endLine: 13,
endColumn: 22,
rule,
severity: `error`,
text: `Expected \`grid-template-areas\` value to be aligned (${rule})`,
},
{
line: 18,
column: 3,
endLine: 20,
endColumn: 22,
rule,
severity: `error`,
text: `Expected \`grid-template-areas\` value to be aligned (${rule})`,
},
{
line: 25,
column: 3,
endLine: 27,
endColumn: 23,
rule,
severity: `error`,
text: `Expected \`grid-template-areas\` value to be aligned (${rule})`,
},
{
line: 32,
column: 3,
endLine: 34,
endColumn: 24,
rule,
severity: `error`,
text: `Expected \`grid-template-areas\` value to be aligned (${rule})`,
},
{
line: 39,
column: 3,
endLine: 41,
endColumn: 23,
rule,
severity: `error`,
text: `Expected \`grid-template-areas\` value to be aligned (${rule})`,
},
],
})