Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The ESLint fixer doesn't use linter options #1989

Closed
jpulec opened this issue Oct 11, 2018 · 1 comment
Closed

The ESLint fixer doesn't use linter options #1989

jpulec opened this issue Oct 11, 2018 · 1 comment
Labels

Comments

@jpulec
Copy link

jpulec commented Oct 11, 2018

Information

VIM version
NVIM v0.3.1
Build type: Release

Operating System: Arch Linux 4.18.10-arch1-1-ARCH

What went wrong

It seems that ALE isn't respected the linter options when linting via the run_on_save hook. I have an .eslintrc file that disallows debugger statements. However, I have set g:ale_javascript_eslint_options = "--rule 'no-debugger: 0'" which should disable the check. It definitely works, and a debugger statement doesn't generate an error in my vim gutter. However, whenever I save the file, it just removes the statement, presumably to auto fixing that isn't respecting my set eslint options.

Reproducing the bug

  1. Create an .eslintrc or config with no-debugger: "error".
  2. Turn off g:ale_fix_on_save
  3. Open a file, add a debugger and save. Note there is no error sign in the gutter.
  4. Close the file and go turn on g:ale_fix_on_save
  5. Open the file again. Still note that there is no error sign.
  6. Save the file and watch the debugger disappear.

:ALEInfo

 Current Filetype: javascript.jsx
Available Linters: ['eslint', 'flow', 'flow-language-server', 'jscs', 'jshint', 'standard', 'tsserver', 'xo']
  Enabled Linters: ['eslint']
 Suggested Fixers: 
  'eslint' - Apply eslint --fix to a file.
  'importjs' - automatic imports for javascript
  'prettier' - Apply prettier to a file.
  'prettier_eslint', 'prettier-eslint' - Apply prettier-eslint to a file.
  'prettier_standard', 'prettier-standard' - Apply prettier-standard to a file.
  'remove_trailing_lines' - Remove all blank lines at the end of a file.
  'standard' - Fix JavaScript files using standard --fix
  'trim_whitespace' - Remove all trailing whitespace characters at the end of every line.
  'xo' - Fix JavaScript files using xo --fix.
 Linter Variables:

let g:ale_javascript_eslint_executable = 'eslint'
let g:ale_javascript_eslint_options = '--rule "no-debugger: 0"'
let g:ale_javascript_eslint_suppress_eslintignore = 0
let g:ale_javascript_eslint_suppress_missing_config = 0
let g:ale_javascript_eslint_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 = 100
let g:ale_completion_enabled = 1
let g:ale_completion_max_suggestions = 50
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 = 1
let g:ale_fixers = {'*': ['remove_trailing_lines', 'trim_whitespace'], 'javascript': ['eslint']}
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_save = 1
let g:ale_lint_on_text_changed = 'always'
let g:ale_lint_on_insert_leave = 0
let g:ale_linter_aliases = {}
let g:ale_linters = {'javascript': ['prettier', 'eslint']}
let g:ale_linters_explicit = 0
let g:ale_list_window_size = 10
let g:ale_list_vertical = 0
let g:ale_loclist_msg_format = '%code: %%s'
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 = {'\.min\.css$': {'ale_linters': [], 'ale_fixers': []}, '\.min\.js$': {'ale_linters': [], 'ale_fixers': []}}
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 = 0
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_statusline_format = v:null
let g:ale_type_map = {}
let g:ale_use_global_executables = v:null
let g:ale_warn_about_trailing_blank_lines = 1
let g:ale_warn_about_trailing_whitespace = 1
  Command History:

(executable check - success) /home/james/Dev/Resource/resource-worktree/teammates/node_modules/eslint/bin/eslint.js
(started) ['/bin/bash', '-c', '''/home/james/Dev/Resource/resource-worktree/teammates/node_modules/eslint/bin/eslint.js'' --rule "no-debugger: 0" -f unix --stdin --stdin-filename ''/home/james/Dev/Resource/resource-worktree/teammates/api/src/resolvers/customer/actions.js'' < ''/tmp/nvimwNQxVX/4/actions.js''']
(finished - exit code 0) ['/bin/bash', '-c', '''/home/james/Dev/Resource/resource-worktree/teammates/node_modules/eslint/bin/eslint.js'' --rule "no-debugger: 0" -f unix --stdin --stdin-filename ''/home/james/Dev/Resource/resource-worktree/teammates/api/src/resolvers/customer/actions.js'' < ''/tmp/nvimwNQxVX/5/actions.js''']

<<<NO OUTPUT RETURNED>>>

(finished - exit code 0) ['/bin/bash', '-c', '''/home/james/Dev/Resource/resource-worktree/teammates/node_modules/eslint/bin/eslint.js'' --version']
(finished - exit code 0) ['/bin/bash', '-c', '''/home/james/Dev/Resource/resource-worktree/teammates/node_modules/eslint/bin/eslint.js'' --stdin-filename ''/home/james/Dev/Resource/resource-worktree/teammates/api/src/resolvers/customer/actions.js'' --stdin --fix-dry-run --format=json < ''/tmp/nvimwNQxVX/6/actions.js''']
(finished - exit code 0) ['/bin/bash', '-c', '''/home/james/Dev/Resource/resource-worktree/teammates/node_modules/eslint/bin/eslint.js'' --rule "no-debugger: 0" -f unix --stdin --stdin-filename ''/home/james/Dev/Resource/resource-worktree/teammates/api/src/resolvers/customer/actions.js'' < ''/tmp/nvimwNQxVX/7/actions.js''']

<<<NO OUTPUT RETURNED>>>

(finished - exit code 0) ['/bin/bash', '-c', '''/home/james/Dev/Resource/resource-worktree/teammates/node_modules/eslint/bin/eslint.js'' --rule "no-debugger: 0" -f unix --stdin --stdin-filename ''/home/james/Dev/Resource/resource-worktree/teammates/api/src/resolvers/customer/actions.js'' < ''/tmp/nvimwNQxVX/8/actions.js''']

<<<NO OUTPUT RETURNED>>>
@w0rp w0rp changed the title Fix on Save Not Respecting Linter Options The ESLint fixer doesn't use linter options Oct 11, 2018
@w0rp w0rp added the bug label Oct 11, 2018
@w0rp w0rp closed this as completed in e6745a3 May 17, 2019
@w0rp
Copy link
Member

w0rp commented May 17, 2019

ESLint options are now used for fixers too. ALE will detect the use of -c or --config in the options and use that instead of searching for the configuration file for old versions, or just let ESLint figure it out for newer versions, which nearly everyone should be using now. Whatever option you set for the config will override that.

It should hopefully just work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants