-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/other-languages' [skip ci]
Resolves #16.
- Loading branch information
Showing
15 changed files
with
343 additions
and
176 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 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,17 @@ | ||
/** | ||
* @file | ||
* Utilities relating to files. | ||
*/ | ||
|
||
const { workspace } = require('vscode'); | ||
|
||
/** | ||
* Returns the `extraFiles` configuration as an array of document filters. | ||
* | ||
* @return {import('vscode').DocumentFilter[]} | ||
* Document filters. | ||
*/ | ||
module.exports.getExtraFileSelectors = () => workspace | ||
.getConfiguration('phpSniffer') | ||
.get('extraFiles', []) | ||
.map((pattern) => ({ pattern, scheme: 'file' })); |
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 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 |
---|---|---|
@@ -1,6 +1,5 @@ | ||
{ | ||
"php.validate.enable": false, | ||
"[php]": { | ||
"editor.defaultFormatter": "wongjn.php-sniffer" | ||
} | ||
"css.validate": false, | ||
"editor.defaultFormatter": "wongjn.php-sniffer" | ||
} |
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,4 @@ | ||
<?xml version="1.0"?> | ||
<ruleset name="CSS"> | ||
<rule ref="Squiz.CSS.ColonSpacing"/> | ||
</ruleset> |
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,50 @@ | ||
const path = require('path'); | ||
const assert = require('assert'); | ||
const { commands, window, workspace, Uri } = require('vscode'); | ||
const { execPromise, FIXTURES_PATH } = require('../utils'); | ||
const { getNextDiagnostics } = require('./utils'); | ||
|
||
suite('`extraFiles` handling', function () { | ||
const fixtureUri = Uri.file(path.join(FIXTURES_PATH, 'style.css')); | ||
const textEncoder = new TextEncoder(); | ||
|
||
suiteSetup(function () { | ||
this.timeout(60000); | ||
|
||
const config = workspace.getConfiguration('phpSniffer', fixtureUri); | ||
return Promise.all([ | ||
execPromise('composer install --no-dev', { cwd: FIXTURES_PATH }), | ||
workspace.fs.writeFile(fixtureUri, textEncoder.encode('a{margin : 0}')), | ||
config.update('executablesFolder', `vendor${path.sep}bin${path.sep}`), | ||
config.update('standard', './css.xml'), | ||
config.update('extraFiles', ['**/*.css']), | ||
]); | ||
}); | ||
|
||
suiteTeardown(function () { | ||
const config = workspace.getConfiguration('phpSniffer', fixtureUri); | ||
return Promise.all([ | ||
workspace.fs.delete(fixtureUri), | ||
config.update('executablesFolder', undefined), | ||
config.update('standard', undefined), | ||
config.update('extraFiles', undefined), | ||
]); | ||
}); | ||
|
||
teardown(() => commands.executeCommand('workbench.action.closeAllEditors')); | ||
|
||
test('Validation errors reported', async function () { | ||
const diagnosticsWatch = getNextDiagnostics(fixtureUri); | ||
workspace.openTextDocument(fixtureUri); | ||
|
||
assert.strictEqual(1, (await diagnosticsWatch).length); | ||
}); | ||
|
||
test('Formatting is applied', async function () { | ||
const document = await workspace.openTextDocument(fixtureUri); | ||
await window.showTextDocument(document); | ||
await commands.executeCommand('editor.action.formatDocument'); | ||
|
||
assert.strictEqual(document.getText(), 'a{margin: 0}'); | ||
}); | ||
}); |
Oops, something went wrong.