Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix TypeError for syntaxes that use Document node type in indentation (…
- Loading branch information
Showing
2 changed files
with
42 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
'use strict'; | ||
|
||
const { parse: postcssParse, stringify, Document, Input } = require('postcss'); | ||
const { ruleName } = require('..'); | ||
|
||
const parse = (source, opts) => { | ||
const doc = new Document(); | ||
const root = postcssParse(source, opts); | ||
|
||
root.parent = doc; | ||
root.document = doc; | ||
doc.nodes.push(root); | ||
doc.source = { | ||
input: new Input(source, opts), | ||
start: { line: 1, column: 1, offset: 0 }, | ||
}; | ||
|
||
return doc; | ||
}; | ||
|
||
testRule({ | ||
ruleName, | ||
config: [2], | ||
fix: true, | ||
customSyntax: { | ||
parse, | ||
stringify, | ||
}, | ||
|
||
accept: [ | ||
{ | ||
code: '.foo {\n' + ' color: hotpink;\n' + '}', | ||
}, | ||
], | ||
|
||
reject: [], | ||
}); |
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