| ----------------- | ---------------------------------------------------------------------------------------- | ----------------------------------- |
| eslint_executable | ESLint executable to call. | `eslint` (calls `eslint` in `PATH`) |
| files_to_lint | What files to lint. Absolute path of offending file will be matched against this Regexp. | `(\.js|\.es6)$` |
+| cmd_line_opts | Command line options to pass to eslint when running | '' |
Example configuration to call custom eslint executable and only lint files ending with `.my_custom_extension`:
# .pronto_eslint_npm.yml
eslint_executable: '/my/custom/node/path/.bin/eslint'
files_to_lint: '\.my_custom_extension$'
+cmd_line_opts: '--ext .html,.js,.es6'
```
module Pronto
class ESLintNpm < Runner
CONFIG_FILE = '.pronto_eslint_npm.yml'.freeze
- CONFIG_KEYS = %w[eslint_executable files_to_lint].freeze
+ CONFIG_KEYS = %w[eslint_executable files_to_lint cmd_line_opts].freeze
- attr_writer :eslint_executable
+ attr_writer :eslint_executable, :cmd_line_opts
def eslint_executable
@eslint_executable || 'eslint'
@files_to_lint || /(\.js|\.es6)$/
end
+ def cmd_line_opts
+ @cmd_line_opts || ''
+ end
+
def files_to_lint=(regexp)
@files_to_lint = regexp.is_a?(Regexp) && regexp || Regexp.new(regexp)
end
end
def eslint_command_line(path)
- "#{eslint_executable} #{Shellwords.escape(path)} -f json"
+ "#{eslint_executable} #{cmd_line_opts} #{Shellwords.escape(path)} -f json"
end
def clean_up_eslint_output(output)
module Pronto
module ESLintNpmVersion
- VERSION = '0.9.0'.freeze
+ VERSION = '0.9.1'.freeze
end
end
end
end
+ context(
+ 'with cmd_line_opts to include .html',
+ config: { 'cmd_line_opts' => '--ext .html' }
+ ) do
+ it 'returns correct number of errors' do
+ expect(run.count).to eql 5
+ end
+ end
+
context(
'with different eslint executable',
config: { 'eslint_executable' => './custom_eslint.sh' }
expect(eslint_command_line).not_to include(path)
end
end
+
+ context(
+ 'with some command line options',
+ config: { 'cmd_line_opts' => '--my command --line opts' }
+ ) do
+ it 'includes the custom command line options' do
+ eslint.read_config
+ expect(eslint_command_line).to include('--my command --line opts')
+ end
+ end
end
end
end