Skip to content

Commit

Permalink
Fix declaration-block-no-redundant-longhand-properties autofix for …
Browse files Browse the repository at this point in the history
…`grid-column` and `grid-row`
  • Loading branch information
mattxwang committed Jun 22, 2023
1 parent 16754b1 commit e16f562
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
Expand Up @@ -206,6 +206,18 @@ testRule({
description: 'autofixer should not mangle css functions with comma separated values',
message: messages.expected('transition'),
},
{
code: 'a { grid-column-start: 1; grid-column-end: 2; }',
fixed: 'a { grid-column: 1 / 2; }',
description: 'explicit grid-column test',
message: messages.expected('grid-column'),
},
{
code: 'a { grid-row-start: 1; grid-row-end: 2; }',
fixed: 'a { grid-row: 1 / 2; }',
description: 'explicit grid-row test',
message: messages.expected('grid-row'),
},
],
});

Expand Down
Expand Up @@ -28,6 +28,28 @@ const meta = {

/** @type {Map<string, (decls: Map<string, Declaration>) => (string | undefined)>} */
const customResolvers = new Map([
[
'grid-column',
(decls) => {
const start = decls.get('grid-column-start')?.value.trim();
const end = decls.get('grid-column-end')?.value.trim();

if (!start || !end) return;

return `${start} / ${end}`;
},
],
[
'grid-row',
(decls) => {
const start = decls.get('grid-row-start')?.value.trim();
const end = decls.get('grid-row-end')?.value.trim();

if (!start || !end) return;

return `${start} / ${end}`;
},
],
[
'grid-template',
(decls) => {
Expand Down

0 comments on commit e16f562

Please sign in to comment.