diff options
-rw-r--r-- | README.md | 2 | ||||
-rw-r--r-- | lib/pronto/eslint_npm.rb | 10 | ||||
-rw-r--r-- | lib/pronto/eslint_npm/version.rb | 2 | ||||
-rw-r--r-- | spec/pronto/eslint_spec.rb | 19 |
4 files changed, 29 insertions, 4 deletions
@@ -34,6 +34,7 @@ Following options are available: | |||
34 | | ----------------- | ---------------------------------------------------------------------------------------- | ----------------------------------- | | 34 | | ----------------- | ---------------------------------------------------------------------------------------- | ----------------------------------- | |
35 | | eslint_executable | ESLint executable to call. | `eslint` (calls `eslint` in `PATH`) | | 35 | | eslint_executable | ESLint executable to call. | `eslint` (calls `eslint` in `PATH`) | |
36 | | files_to_lint | What files to lint. Absolute path of offending file will be matched against this Regexp. | `(\.js|\.es6)$` | | 36 | | files_to_lint | What files to lint. Absolute path of offending file will be matched against this Regexp. | `(\.js|\.es6)$` | |
37 | | cmd_line_opts | Command line options to pass to eslint when running | '' | | ||
37 | 38 | ||
38 | Example configuration to call custom eslint executable and only lint files ending with `.my_custom_extension`: | 39 | Example configuration to call custom eslint executable and only lint files ending with `.my_custom_extension`: |
39 | 40 | ||
@@ -41,4 +42,5 @@ Example configuration to call custom eslint executable and only lint files endin | |||
41 | # .pronto_eslint_npm.yml | 42 | # .pronto_eslint_npm.yml |
42 | eslint_executable: '/my/custom/node/path/.bin/eslint' | 43 | eslint_executable: '/my/custom/node/path/.bin/eslint' |
43 | files_to_lint: '\.my_custom_extension$' | 44 | files_to_lint: '\.my_custom_extension$' |
45 | cmd_line_opts: '--ext .html,.js,.es6' | ||
44 | ``` | 46 | ``` |
diff --git a/lib/pronto/eslint_npm.rb b/lib/pronto/eslint_npm.rb index 63a215b..6a9c00c 100644 --- a/lib/pronto/eslint_npm.rb +++ b/lib/pronto/eslint_npm.rb | |||
@@ -6,9 +6,9 @@ require 'shellwords' | |||
6 | module Pronto | 6 | module Pronto |
7 | class ESLintNpm < Runner | 7 | class ESLintNpm < Runner |
8 | CONFIG_FILE = '.pronto_eslint_npm.yml'.freeze | 8 | CONFIG_FILE = '.pronto_eslint_npm.yml'.freeze |
9 | CONFIG_KEYS = %w[eslint_executable files_to_lint].freeze | 9 | CONFIG_KEYS = %w[eslint_executable files_to_lint cmd_line_opts].freeze |
10 | 10 | ||
11 | attr_writer :eslint_executable | 11 | attr_writer :eslint_executable, :cmd_line_opts |
12 | 12 | ||
13 | def eslint_executable | 13 | def eslint_executable |
14 | @eslint_executable || 'eslint' | 14 | @eslint_executable || 'eslint' |
@@ -18,6 +18,10 @@ module Pronto | |||
18 | @files_to_lint || /(\.js|\.es6)$/ | 18 | @files_to_lint || /(\.js|\.es6)$/ |
19 | end | 19 | end |
20 | 20 | ||
21 | def cmd_line_opts | ||
22 | @cmd_line_opts || '' | ||
23 | end | ||
24 | |||
21 | def files_to_lint=(regexp) | 25 | def files_to_lint=(regexp) |
22 | @files_to_lint = regexp.is_a?(Regexp) && regexp || Regexp.new(regexp) | 26 | @files_to_lint = regexp.is_a?(Regexp) && regexp || Regexp.new(regexp) |
23 | end | 27 | end |
@@ -84,7 +88,7 @@ module Pronto | |||
84 | end | 88 | end |
85 | 89 | ||
86 | def eslint_command_line(path) | 90 | def eslint_command_line(path) |
87 | "#{eslint_executable} #{Shellwords.escape(path)} -f json" | 91 | "#{eslint_executable} #{cmd_line_opts} #{Shellwords.escape(path)} -f json" |
88 | end | 92 | end |
89 | 93 | ||
90 | def clean_up_eslint_output(output) | 94 | def clean_up_eslint_output(output) |
diff --git a/lib/pronto/eslint_npm/version.rb b/lib/pronto/eslint_npm/version.rb index 2d3f9d8..1fc96c9 100644 --- a/lib/pronto/eslint_npm/version.rb +++ b/lib/pronto/eslint_npm/version.rb | |||
@@ -2,6 +2,6 @@ | |||
2 | 2 | ||
3 | module Pronto | 3 | module Pronto |
4 | module ESLintNpmVersion | 4 | module ESLintNpmVersion |
5 | VERSION = '0.9.0'.freeze | 5 | VERSION = '0.9.1'.freeze |
6 | end | 6 | end |
7 | end | 7 | end |
diff --git a/spec/pronto/eslint_spec.rb b/spec/pronto/eslint_spec.rb index a00a05b..0924f30 100644 --- a/spec/pronto/eslint_spec.rb +++ b/spec/pronto/eslint_spec.rb | |||
@@ -58,6 +58,15 @@ module Pronto | |||
58 | end | 58 | end |
59 | 59 | ||
60 | context( | 60 | context( |
61 | 'with cmd_line_opts to include .html', | ||
62 | config: { 'cmd_line_opts' => '--ext .html' } | ||
63 | ) do | ||
64 | it 'returns correct number of errors' do | ||
65 | expect(run.count).to eql 5 | ||
66 | end | ||
67 | end | ||
68 | |||
69 | context( | ||
61 | 'with different eslint executable', | 70 | 'with different eslint executable', |
62 | config: { 'eslint_executable' => './custom_eslint.sh' } | 71 | config: { 'eslint_executable' => './custom_eslint.sh' } |
63 | ) do | 72 | ) do |
@@ -139,6 +148,16 @@ module Pronto | |||
139 | expect(eslint_command_line).not_to include(path) | 148 | expect(eslint_command_line).not_to include(path) |
140 | end | 149 | end |
141 | end | 150 | end |
151 | |||
152 | context( | ||
153 | 'with some command line options', | ||
154 | config: { 'cmd_line_opts' => '--my command --line opts' } | ||
155 | ) do | ||
156 | it 'includes the custom command line options' do | ||
157 | eslint.read_config | ||
158 | expect(eslint_command_line).to include('--my command --line opts') | ||
159 | end | ||
160 | end | ||
142 | end | 161 | end |
143 | end | 162 | end |
144 | end | 163 | end |