Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 04572a7
Showing
17 changed files
with
2,556 additions
and
0 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,15 @@ | ||
root = true | ||
|
||
[*] | ||
indent_style = tab | ||
end_of_line = lf | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
|
||
[{*.json,*.yml}] | ||
indent_style = space | ||
indent_size = 2 | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false |
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 @@ | ||
* text=auto |
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 @@ | ||
node_modules/ |
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 @@ | ||
{ | ||
"version": "0.1.0", | ||
// List of configurations. Add new configurations or edit existing ones. | ||
"configurations": [ | ||
{ | ||
"name": "Attach to Language Worker", | ||
"type": "node", | ||
"request": "attach", | ||
// TCP/IP address. Default is "localhost". | ||
"address": "localhost", | ||
// Port to attach to. | ||
"port": 5871, | ||
"outDir": "out", | ||
"sourceMaps": true | ||
} | ||
] | ||
} |
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,9 @@ | ||
// Place your settings in this file to overwrite default and user settings. | ||
{ | ||
"files.exclude": { | ||
"out": false // set this to true to hide the "out" folder with the compiled JS files | ||
}, | ||
"search.exclude": { | ||
"out": true | ||
} | ||
} |
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,30 @@ | ||
// Available variables which can be used inside of strings. | ||
// ${workspaceRoot}: the root folder of the team | ||
// ${file}: the current opened file | ||
// ${fileBasename}: the current opened file's basename | ||
// ${fileDirname}: the current opened file's dirname | ||
// ${fileExtname}: the current opened file's extension | ||
// ${cwd}: the current working directory of the spawned process | ||
|
||
// A task runner that calls a custom npm script that compiles the extension. | ||
{ | ||
"version": "0.1.0", | ||
|
||
// we want to run npm | ||
"command": "npm", | ||
|
||
// the command is a shell script | ||
"isShellCommand": true, | ||
|
||
// show the output window only if unrecognized errors occur. | ||
"showOutput": "silent", | ||
|
||
// we run the custom script "compile" as defined in package.json | ||
"args": ["run", "compile"], | ||
|
||
// The tsc compiler is started in watching mode | ||
"isWatching": true, | ||
|
||
// use the standard tsc in watch mode problem matcher to find compile problems in the output. | ||
"problemMatcher": "$tsc-watch" | ||
} |
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,7 @@ | ||
.vscode/** | ||
typings/** | ||
**/*.ts | ||
**/*.map | ||
.gitignore | ||
tsconfig.json | ||
screenshot.png |
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,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) Sam Verschueren <sam.verschueren@gmail.com> | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
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,48 @@ | ||
# vscode-linter-xo | ||
|
||
> Linter for [XO](https://github.com/sindresorhus/xo) | ||
|
||
## Install | ||
|
||
Press <kbd>F1</kbd> and narrow down the list commands by typing `extension`. Pick `Extensions: Install Extension`. | ||
|
||
![](https://github.com/SamVerschueren/vscode-linter-xo/raw/master/screenshot.png) | ||
|
||
Simply pick the `linter-xo` extension from the list | ||
|
||
## Usage | ||
|
||
Enable the linter in the VS Code Settings. | ||
|
||
```json | ||
{ | ||
"xo.enable": true | ||
} | ||
``` | ||
|
||
You can also pass in extra options via the settings file. | ||
|
||
```json | ||
{ | ||
"xo.enable": true, | ||
"xo.options": { | ||
"semicolon": false | ||
} | ||
} | ||
``` | ||
|
||
Settings can also be set in the `package.json` file. | ||
|
||
```json | ||
{ | ||
"name": "my-pkg", | ||
"xo": { | ||
"semicolon": false | ||
} | ||
} | ||
``` | ||
|
||
## License | ||
|
||
MIT © [Sam Verschueren](http://github.com/SamVerschueren) |
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,78 @@ | ||
'use strict'; | ||
|
||
import { runSingleFileValidator, SingleFileValidator, InitializeResponse, IValidationRequestor, IDocument, Diagnostic, Severity, Files } from 'vscode-languageworker'; | ||
|
||
import path = require('path'); | ||
import fs = require('fs'); | ||
import objectAssign = require('object-assign'); | ||
|
||
let lintText: any = null; | ||
let lintConfig: Object = null; | ||
|
||
function makeDiagnostic(problem: any): Diagnostic { | ||
return { | ||
message: `${problem.message} (${problem.ruleId})`, | ||
severity: problem.severity === 2 ? Severity.Error : Severity.Warning, | ||
start: { | ||
line: problem.line, | ||
character: problem.column | ||
}, | ||
end: { | ||
line: problem.line, | ||
character: problem.column | ||
} | ||
}; | ||
} | ||
|
||
let validator : SingleFileValidator = { | ||
initialize: (rootFolder: string): Thenable<InitializeResponse> => { | ||
return Files.resolveModule(rootFolder, 'xo').then(xo => { | ||
lintText = xo.lintText; | ||
return null; | ||
}, (error) => { | ||
return Promise.reject({ | ||
success: false, | ||
message: 'Failed to load xo library. Please install xo in your workspace folder using \'npm install xo\' and then press Retry.', | ||
retry: true | ||
}); | ||
}); | ||
}, | ||
onConfigurationChange(settings: any, requestor: IValidationRequestor): void { | ||
// VSCode settings have changed and the requested settings changes | ||
// have been synced over to the language worker | ||
if (settings.xo) { | ||
lintConfig = settings.xo.options; | ||
} | ||
|
||
// Request re-validation of all open documents | ||
requestor.all(); | ||
}, | ||
validate: (document: IDocument): Diagnostic[] => { | ||
try { | ||
const uri = document.uri; | ||
const fsPath = Files.uriToFilePath(uri); | ||
const contents = document.getText(); | ||
|
||
const report = lintText(contents, objectAssign({cwd: path.dirname(fsPath)}, lintConfig)); | ||
|
||
let diagnostics: Diagnostic[] = []; | ||
|
||
report.results.forEach(result => { | ||
result.messages.forEach(message => { | ||
diagnostics.push(makeDiagnostic(message)); | ||
}); | ||
}); | ||
|
||
return diagnostics; | ||
} catch (err) { | ||
let message: string = null; | ||
if (typeof err.message === 'string' || err.message instanceof String) { | ||
message = <string>err.message; | ||
throw new Error(message); | ||
} | ||
throw err; | ||
} | ||
} | ||
}; | ||
|
||
runSingleFileValidator(process.stdin, process.stdout, validator); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,60 @@ | ||
{ | ||
"name": "linter-xo", | ||
"version": "0.1.0", | ||
"publisher": "SamVerschueren", | ||
"engines": { | ||
"vscode": "*" | ||
}, | ||
"dependencies": { | ||
"object-assign": "^4.0.1", | ||
"vscode-languageworker": "*", | ||
"xo": "^0.9.0" | ||
}, | ||
"devDependencies": { | ||
"typescript": "^1.6.2" | ||
}, | ||
"contributes": { | ||
"configuration": { | ||
"type": "object", | ||
"title": "xo configuration", | ||
"properties": { | ||
"xo.enable": { | ||
"type": "boolean", | ||
"default": false, | ||
"description": "Control whether xo is enabled or not." | ||
}, | ||
"xo.options": { | ||
"type": "object", | ||
"default": {}, | ||
"description": "The xo options object to provide args to the xo command." | ||
} | ||
} | ||
}, | ||
"languageWorkers": { | ||
"activate": [ | ||
"onLanguage:javascript", | ||
"onLanguage:javascriptreact" | ||
], | ||
"executable": { | ||
"run": { | ||
"nodeModule": "out/extension.js" | ||
}, | ||
"debug": { | ||
"nodeModule": "out/extension.js", | ||
"execArgv": [ | ||
"--nolazy", | ||
"--debug=5871" | ||
] | ||
} | ||
}, | ||
"watchFiles": [ | ||
"**/*.js" | ||
], | ||
"settings": "xo" | ||
} | ||
}, | ||
"scripts": { | ||
"vscode:prepublish": "tsc", | ||
"compile": "tsc -watch -p ./" | ||
} | ||
} |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,11 @@ | ||
{ | ||
"compilerOptions": { | ||
"module": "commonjs", | ||
"moduleResolution": "node", | ||
"outDir": "out", | ||
"sourceMap": true | ||
}, | ||
"exclude": [ | ||
"node_modules" | ||
] | ||
} |
Oops, something went wrong.