dense-analysis / dense-analysis/ale

ember-template-lint fails because it can't find .template-lintrc.js

Open
#3,058 1 comment 0 reactions 0 assignees View on GitHub
bug
Dominant language
Vim Script
Stars
14k
Forks
1.5k
Avg merge
17h 49m
Merged PRs (30d)
1

Description

`ember-template-lint` looks for .template-lintrc.js in the project root, a la .tsconfig, .eslintrc.js, etc. It will search "up" relative to its own cwd. However, whatever cwd it takes when `ember-template-lint` is invoked from ale_linters/handlebars/embertemplatelint.vim is not conducive to this behavior.

The linter handler should be updated to work out the project root and either change the working directory or pass `--config-file /.template-lintrc.js` to `ember-template-lint`.

## Information

**VIM version**

```
macOS version
Included patches: 1-319
Compiled by Homebrew
Huge version with MacVim GUI.
```

Operating System:

```sh
$ sw_vers
ProductName: Mac OS X
ProductVersion: 10.15.3
BuildVersion: 19D76
```

## What went wrong

When I set ember-template-lint as the only linter for a html.handlebars file, it does not detect template errors. However, ember-template-lint detect errors just fine when run from the command line, i.e. within the project directory.

## Reproducing the bug

1. Install Ember CLI
```sh
$ yarn global add ember-cli
```
1. `ember new` yourself a simple project
1. Create a template with an error, e.g.:
```hbs
{{!-- app/templates/application.hbs --}}
{{outlet}}
{{each this.foo as |bar|}}
{{/each}}
```
1. Lint it from the command line: `yarn lint:hbs` (or `node_modules/.bin/ember-template-lint app/templates/application.hbs`)
N.B. The error is detected.
1. In ViM with ALE loaded, open your sample file
1. `:let b:ale_linters = ['ember-template-lint']`
1. Save the file (or otherwise proc ALE to re-check the file)
N.B. The error is not detected.

### :ALEInfo

```
Current Filetype: html.handlebars
Available Linters: ['alex', 'fecs', 'htmlhint', 'proselint', 'stylelint', 'tidy', 'writegood', 'ember-template-lint']
Linter Aliases:
'writegood' -> ['write-good']
Enabled Linters: ['ember-template-lint']
Suggested Fixers:
'fecs' - Apply fecs format to a file.
'html-beautify' - Fix HTML files with html-beautify.
'prettier' - Apply prettier to a file.
'remove_trailing_lines' - Remove all blank lines at the end of a file.
'tidy' - Fix HTML files with tidy.
'trim_whitespace' - Remove all trailing whitespace characters at the end of every line.
Linter Variables:
let g:ale_handlebars_embertemplatelint_executable = 'ember-template-lint'
let g:ale_handlebars_embertemplatelint_use_global = 0
Global Variables:
let g:ale_cache_executable_check_failures = v:null
let g:ale_change_sign_column_color = 0
let g:ale_command_wrapper = ''
let g:ale_completion_delay = v:null
let g:ale_completion_enabled = 0
let g:ale_completion_max_suggestions = v:null
let g:ale_echo_cursor = 1
let g:ale_echo_msg_error_str = 'Error'
let g:ale_echo_msg_format = '%code: %%s'
let g:ale_echo_msg_info_str = 'Info'
let g:ale_echo_msg_warning_str = 'Warning'
let g:ale_enabled = 1
let g:ale_fix_on_save = 0
let g:ale_fixers = {}
let g:ale_history_enabled = 1
let g:ale_history_log_output = 1
let g:ale_keep_list_window_open = 0
let g:ale_lint_delay = 200
let g:ale_lint_on_enter = 1
let g:ale_lint_on_filetype_changed = 1
let g:ale_lint_on_insert_leave = 1
let g:ale_lint_on_save = 1
let g:ale_lint_on_text_changed = 'normal'
let g:ale_linter_aliases = {}
let g:ale_linters = {'javascript': ['eslint']}
let b:ale_linters = ['ember-template-lint']
let g:ale_linters_explicit = 0
let g:ale_list_vertical = 0
let g:ale_list_window_size = 10
let g:ale_loclist_msg_format = '%code: %%s'
let g:ale_lsp_root = {}
let g:ale_max_buffer_history_size = 20
let g:ale_max_signs = -1
let g:ale_maximum_file_size = v:null
let g:ale_open_list = 0
let g:ale_pattern_options = v:null
let g:ale_pattern_options_enabled = v:null
let g:ale_set_balloons = 0
let g:ale_set_highlights = 1
let g:ale_set_loclist = 1
let g:ale_set_quickfix = 0
let g:ale_set_signs = 1
let g:ale_sign_column_always = 1
let g:ale_sign_error = '>>'
let g:ale_sign_info = '--'
let g:ale_sign_offset = 1000000
let g:ale_sign_style_error = '>>'
let g:ale_sign_style_warning = '--'
let g:ale_sign_warning = '--'
let g:ale_sign_highlight_linenrs = 0
let g:ale_statusline_format = v:null
let g:ale_type_map = {}
let g:ale_use_global_executables = v:null
let g:ale_virtualtext_cursor = 0
let g:ale_warn_about_trailing_blank_lines = 1
let g:ale_warn_about_trailing_whitespace = 1
Command History:

(executable check - failure) alex
(executable check - failure) fecs
(executable check - failure) htmlhint
(executable check - failure) proselint
(executable check - failure) stylelint
(executable check - success) tidy
(finished - exit code 1) ['/usr/local/bin/bash', '-c', 'tidy -q -e -language en -utf8 - < ''/var/folders/9c/tbkml33s1nl_43gbsclbk6
jc0000gn/T/voMM0jY/2/shop.hbs''']

<<>>
line 4 column 3 - Warning: missing declaration
line 4 column 3 - Warning: plain text isn't allowed in elements
line 4 column 3 - Warning: inserting implicit
line 4 column 3 - Warning: inserting missing 'title' element
<<>>

(executable check - failure) write-good
(executable check - success) /Users/mwp/Code/pow/juliette/node_modules/.bin/ember-template-lint
(finished - exit code 1) ['/usr/local/bin/bash', '-c', '''/Users/mwp/Code/pow/juliette/node_modules/.bin/ember-template-lint'' ''/
var/folders/9c/tbkml33s1nl_43gbsclbk6jc0000gn/T/voMM0jY/3/shop.hbs'' --json']

<<>>

(finished - exit code 1) ['/usr/local/bin/bash', '-c', '''/Users/mwp/Code/pow/juliette/node_modules/.bin/ember-template-lint'' ''/
var/folders/9c/tbkml33s1nl_43gbsclbk6jc0000gn/T/voMM0jY/8/shop.hbs'' --json']

<<>>

```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.