1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-02-14 06:07:58 +08:00
SpaceVim/bundle/neomake/tests/ft_javascript.vader
2025-02-03 16:36:38 +08:00

111 lines
3.7 KiB
Plaintext
Vendored

Include: include/setup.vader
Execute (javascript: eslint: errorformat):
new
file fullOfProblems.js
let eslint = NeomakeTestsGetMakerWithOutput(neomake#makers#ft#javascript#eslint(),
\ 'tests/fixtures/javascript/eslint_example.json')
CallNeomake 1, [eslint]
AssertEqualQf getloclist(0), [{
\ 'lnum': 1, 'bufnr': bufnr('%'), 'col': 10, 'type': 'E',
\ 'text': "'addOne' is defined but never used.",
\ 'pattern': '', 'vcol': 0, 'nr': -1,
\ 'valid': 1,
\ },
\ {
\ 'lnum': 2, 'bufnr': bufnr('%'), 'col': 9, 'type': 'E',
\ 'text': "Use the isNaN function to compare with NaN.",
\ 'pattern': '', 'vcol': 0, 'nr': -1,
\ 'valid': 1,
\ },
\ {
\ 'lnum': 3, 'bufnr': bufnr('%'), 'col': 16, 'type': 'E',
\ 'text': "Unexpected space before unary operator '++'.",
\ 'pattern': '', 'vcol': 0, 'nr': -1,
\ 'valid': 1,
\ },
\ {
\ 'lnum': 3, 'bufnr': bufnr('%'), 'col': 20, 'type': 'W',
\ 'text': "Missing semicolon.",
\ 'pattern': '', 'vcol': 0, 'nr': -1,
\ 'valid': 1,
\ },
\ {
\ 'lnum': 4, 'bufnr': bufnr('%'), 'col': 12, 'type': 'W',
\ 'text': "Unnecessary 'else' after 'return'.",
\ 'pattern': '', 'vcol': 0, 'nr': -1,
\ 'valid': 1,
\ },
\ {
\ 'lnum': 5, 'bufnr': bufnr('%'), 'col': 1, 'type': 'W',
\ 'text': "Expected indentation of 8 spaces but found 6.",
\ 'pattern': '', 'vcol': 0, 'nr': -1,
\ 'valid': 1,
\ },
\ {
\ 'lnum': 5, 'bufnr': bufnr('%'), 'col': 7, 'type': 'E',
\ 'text': "Function 'addOne' expected a return value.",
\ 'pattern': '', 'vcol': 0, 'nr': -1,
\ 'valid': 1,
\ },
\ {
\ 'lnum': 5, 'bufnr': bufnr('%'), 'col': 13, 'type': 'W',
\ 'text': "Missing semicolon.",
\ 'pattern': '', 'vcol': 0, 'nr': -1,
\ 'valid': 1,
\ },
\ {
\ 'lnum': 7, 'bufnr': bufnr('%'), 'col': 2, 'type': 'E',
\ 'text': "Unnecessary semicolon.",
\ 'pattern': '', 'vcol': 0, 'nr': -1,
\ 'valid': 1,
\ }]
bwipe
Execute (javascript: standard: errorformat):
Save &errorformat
let &errorformat = neomake#makers#ft#javascript#standard().errorformat
new
file /path/to/file.js
let output = [
\ 'standard: Use JavaScript Standard Style (https://standardjs.com)',
\ 'standard: Run `standard --fix` to automatically fix some problems.',
\ ' /path/to/file.js:1:1: Expected an assignment or function call and instead saw an expression. (no-unused-expressions)',
\ ]
lgetexpr output
AssertEqualQf getloclist(0), [{
\ 'lnum': 1, 'bufnr': bufnr('%'), 'col': 1, 'valid': 1, 'vcol': 0,
\ 'nr': -1, 'type': 'W', 'pattern': '',
\ 'text': 'Expected an assignment or function call and instead saw an expression. (no-unused-expressions)'}]
bwipe
Execute (javascript: flow: no errors):
new
let flow_maker = NeomakeTestsGetMakerWithOutput(neomake#makers#ft#javascript#flow(), [
\ 'No errors!',
\ ])
CallNeomake 1, [flow_maker]
AssertEqual getloclist(0), []
bwipe
Execute (javascript: flow: no trailing newline):
new
file index.js
let flow_maker = NeomakeTestsGetMakerWithOutput(neomake#makers#ft#javascript#flow(), [
\ 'File "index.js", line 9, characters 10-11',
\ 'Error: Cannot call `list` because a callable signature is missing in exports [1].',
\ '',
\ ])
CallNeomake 1, [flow_maker]
AssertEqualQf getloclist(0), [
\ {'lnum': 9, 'bufnr': bufnr('%'), 'col': 10, 'valid': 1, 'vcol': 0, 'nr': -1,
\ 'type': 'E', 'pattern': '',
\ 'text': 'Error: Cannot call `list` because a callable signature is missing in exports [1].'},
\ ]
" Replaced newline in log message.
AssertNeomakeMessage "\\VModified list entry 1 (postprocess): {'changed': {'text': ['11\\\\nError: Cannot call `list` because a callable signature is missing in exports [1].', 'Error: Cannot call `list` because a callable signature is missing in exports [1].']}, 'added': {'length': 2}}."
bwipe