-
-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Support Format Document action (#200)
fixes #25
- Loading branch information
1 parent
331646b
commit 39d8569
Showing
6 changed files
with
178 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"[css]": { | ||
"editor.defaultFormatter": "stylelint.vscode-stylelint" | ||
} | ||
} |
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,41 @@ | ||
'use strict'; | ||
|
||
const fs = require('fs/promises'); | ||
const path = require('path'); | ||
|
||
const pWaitFor = require('p-wait-for'); | ||
const test = require('tape'); | ||
const { extensions, workspace, Uri, commands, window } = require('vscode'); | ||
|
||
const run = () => | ||
test('vscode-stylelint', async (t) => { | ||
const expectedCss = await fs.readFile(path.resolve(__dirname, 'test.expected.css'), 'utf8'); | ||
|
||
await commands.executeCommand('vscode.openFolder', Uri.file(__dirname)); | ||
|
||
const vscodeStylelint = extensions.getExtension('stylelint.vscode-stylelint'); | ||
|
||
// Open the './test.input.css' file. | ||
const cssDocument = await workspace.openTextDocument(path.resolve(__dirname, 'test.input.css')); | ||
|
||
await window.showTextDocument(cssDocument); | ||
|
||
await commands.executeCommand('editor.action.indentUsingTabs', { | ||
tabSize: 4, | ||
indentSize: 4, | ||
insertSpaces: false, | ||
}); | ||
|
||
await pWaitFor(() => vscodeStylelint.isActive, { timeout: 2000 }); | ||
|
||
await commands.executeCommand('editor.action.formatDocument'); | ||
|
||
t.equal(cssDocument.getText(), expectedCss, 'should format document using formatting options.'); | ||
|
||
t.end(); | ||
}); | ||
|
||
exports.run = (root, done) => { | ||
test.onFinish(done); | ||
run(); | ||
}; |
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,3 @@ | ||
a { | ||
color: red; | ||
} |
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,3 @@ | ||
a { | ||
color: red; | ||
} |