summaryrefslogtreecommitdiff
path: root/test/linter/test_eslint.vader
blob: 6c05fc6dc8259862fd62fd5474807749d02681ee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
Before:
  call ale#assert#SetUpLinterTest('javascript', 'eslint')
  runtime autoload/ale/handlers/eslint.vim

  let b:args = ' -f json --stdin --stdin-filename %s'

After:
  unlet! b:args
  unlet! b:executable

  call ale#assert#TearDownLinterTest()

Execute(The default command should be correct):
  AssertLinterCwd ''
  AssertLinter 'eslint', ale#Escape('eslint') . b:args

Execute(create-react-app directories should be detected correctly):
  call ale#test#SetFilename('../test-files/eslint/react-app/subdir/testfile.js')

  let b:executable = ale#path#Simplify(g:dir . '/../test-files/eslint/react-app/node_modules/eslint/bin/eslint.js')
  AssertLinterCwd ale#path#Simplify(g:dir . '/../test-files/eslint/react-app')
  AssertLinter b:executable,
  \ (has('win32') ? ale#Escape('node.exe') . ' ' : '')
  \ . ale#Escape(b:executable) . b:args

Execute(use-global should override create-react-app detection):
  call ale#test#SetFilename('../test-files/eslint/react-app/subdir/testfile.js')

  let g:ale_javascript_eslint_use_global = 1
  let g:ale_javascript_eslint_executable = 'eslint_d'

  let b:executable = 'eslint_d'
  AssertLinterCwd ale#path#Simplify(g:dir . '/../test-files/eslint/react-app')
  AssertLinter b:executable, ale#Escape(b:executable) . b:args

Execute(other app directories should be detected correctly):
  call ale#test#SetFilename('../test-files/eslint/other-app/subdir/testfile.js')

  let b:executable = ale#path#Simplify(g:dir . '/../test-files/eslint/node_modules/.bin/eslint')
  AssertLinterCwd ale#path#Simplify(g:dir . '/../test-files/eslint')
  AssertLinter b:executable, ale#Escape(b:executable) . b:args

Execute(use-global should override other app directories):
  call ale#test#SetFilename('../test-files/eslint/other-app/subdir/testfile.js')

  let g:ale_javascript_eslint_use_global = 1
  let g:ale_javascript_eslint_executable = 'eslint_d'

  let b:executable = 'eslint_d'
  AssertLinterCwd ale#path#Simplify(g:dir . '/../test-files/eslint')
  AssertLinter b:executable, ale#Escape(b:executable) . b:args

Execute(eslint.js executables should be run with node on Windows):
  call ale#test#SetFilename('../test-files/eslint/react-app/subdir/testfile.js')

  let b:executable = ale#path#Simplify(g:dir . '/../test-files/eslint/react-app/node_modules/eslint/bin/eslint.js')
  AssertLinterCwd ale#path#Simplify(g:dir . '/../test-files/eslint/react-app')
  AssertLinter b:executable,
  \ (has('win32') ? ale#Escape('node.exe') . ' ' : '')
  \ . ale#Escape(b:executable) . b:args

Execute(eslint.js should be run from a containing project with node_modules):
  call ale#test#SetFilename('../test-files/eslint/react-app/subdir-with-package-json/testfile.js')

  let b:executable = ale#path#Simplify(g:dir . '/../test-files/eslint/react-app/node_modules/eslint/bin/eslint.js')
  AssertLinterCwd ale#path#Simplify(g:dir . '/../test-files/eslint/react-app')
  AssertLinter b:executable,
  \ (has('win32') ? ale#Escape('node.exe') . ' ' : '')
  \ . ale#Escape(b:executable) . b:args

Execute(eslint.js should be run from a containing project with .yarn/sdks):
  call ale#test#SetFilename('../test-files/eslint/yarn2-app/subdir/testfile.js')

  let b:executable = ale#path#Simplify(g:dir . '/../test-files/eslint/yarn2-app/.yarn/sdks/eslint/bin/eslint.js')
  AssertLinterCwd ale#path#Simplify(g:dir . '/../test-files/eslint/yarn2-app')
  AssertLinter b:executable,
  \ (has('win32') ? ale#Escape('node.exe') . ' ' : '')
  \ . ale#Escape(b:executable) . b:args

Execute(astro directories should be detected correctly):
  call ale#test#SetFilename('../test-files/eslint/astro-app/src/pages/index.astro')

  let b:executable = ale#path#Simplify(g:dir . '/../test-files/eslint/astro-app/node_modules/eslint/bin/eslint.js')
  AssertLinterCwd ale#path#Simplify(g:dir . '/../test-files/eslint/astro-app')
  AssertLinter b:executable,
  \ (has('win32') ? ale#Escape('node.exe') . ' ' : '')
  \ . ale#Escape(b:executable) . b:args