-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2660 from YPCrumble/master
Add StandardJS linter for TypeScript
- Loading branch information
Showing
8 changed files
with
114 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
" Author: Ahmed El Gabri <@ahmedelgabri> | ||
" Description: standardjs for typescript files | ||
|
||
call ale#Set('typescript_standard_executable', 'standard') | ||
call ale#Set('typescript_standard_use_global', get(g:, 'ale_use_global_executables', 0)) | ||
call ale#Set('typescript_standard_options', '') | ||
|
||
function! ale_linters#typescript#standard#GetExecutable(buffer) abort | ||
return ale#node#FindExecutable(a:buffer, 'typescript_standard', [ | ||
\ 'node_modules/standardx/bin/cmd.js', | ||
\ 'node_modules/standard/bin/cmd.js', | ||
\ 'node_modules/.bin/standard', | ||
\]) | ||
endfunction | ||
|
||
function! ale_linters#typescript#standard#GetCommand(buffer) abort | ||
let l:executable = ale_linters#typescript#standard#GetExecutable(a:buffer) | ||
let l:options = ale#Var(a:buffer, 'typescript_standard_options') | ||
|
||
return ale#node#Executable(a:buffer, l:executable) | ||
\ . (!empty(l:options) ? ' ' . l:options : '') | ||
\ . ' --stdin %s' | ||
endfunction | ||
|
||
" standard uses eslint and the output format is the same | ||
call ale#linter#Define('typescript', { | ||
\ 'name': 'standard', | ||
\ 'executable': function('ale_linters#typescript#standard#GetExecutable'), | ||
\ 'command': function('ale_linters#typescript#standard#GetCommand'), | ||
\ 'callback': 'ale#handlers#eslint#Handle', | ||
\}) |
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 |
---|---|---|
|
@@ -468,6 +468,7 @@ Notes: | |
* `eslint` | ||
* `fecs` | ||
* `prettier` | ||
* `standard` | ||
* `tslint` | ||
* `tsserver` | ||
* `typecheck` | ||
|
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
43 changes: 43 additions & 0 deletions
43
test/command_callback/test_standardts_command_callback.vader
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,43 @@ | ||
Before: | ||
call ale#assert#SetUpLinterTest('typescript', 'standard') | ||
call ale#test#SetFilename('testfile.js') | ||
unlet! b:executable | ||
|
||
After: | ||
call ale#assert#TearDownLinterTest() | ||
|
||
Execute(bin/cmd.js paths should be preferred): | ||
call ale#test#SetFilename('standard-test-files/with-cmd/testfile.js') | ||
|
||
let b:executable = ale#path#Simplify( | ||
\ g:dir | ||
\ . '/standard-test-files/with-cmd/node_modules/standard/bin/cmd.js' | ||
\) | ||
|
||
AssertLinter b:executable, | ||
\ (has('win32') ? 'node.exe ' : '') | ||
\ . ale#Escape(b:executable) | ||
\ . ' --stdin %s' | ||
|
||
Execute(.bin directories should be used too): | ||
call ale#test#SetFilename('standard-test-files/with-bin/testfile.js') | ||
|
||
let b:executable = ale#path#Simplify( | ||
\ g:dir | ||
\ . '/standard-test-files/with-bin/node_modules/.bin/standard' | ||
\) | ||
|
||
AssertLinter b:executable, ale#Escape(b:executable) . ' --stdin %s' | ||
|
||
Execute(The global executable should be used otherwise): | ||
AssertLinter 'standard', ale#Escape('standard') . ' --stdin %s' | ||
|
||
Execute(The global executable should be configurable): | ||
let b:ale_typescript_standard_executable = 'foobar' | ||
|
||
AssertLinter 'foobar', ale#Escape('foobar') . ' --stdin %s' | ||
|
||
Execute(The options should be configurable): | ||
let b:ale_typescript_standard_options = '--wat' | ||
|
||
AssertLinter 'standard', ale#Escape('standard') . ' --wat --stdin %s' |