pronto-eslint_npm 0.8.1 → 0.11.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: d6a595ca8ffd8706d4a0682219cee87760e0806c
4
- data.tar.gz: 333e9e084c8ba2be9a4778b5b34f8aac663dbf28
2
+ SHA256:
3
+ metadata.gz: fd8169a6b57fa0d02abb4ad5982083602d09ad1fae1062e5f62c9e945687e992
4
+ data.tar.gz: 33b07b0284e78d6b766aca7bd9a3dbb4228be7159d82a894d37dbfdf9b1f51b6
5
5
  SHA512:
6
- metadata.gz: 718a48e9708744aa380b5cdda64179db3a27df5f4a41784fc008ab8aee81bf5353d57c1c59eff4b5df4838b867f3622ad120e773bcf2a9d284c8b848937994b9
7
- data.tar.gz: e9a9f52ac029c16a4e46ef9da63131eaae5049c8eac1497e8143609ad9687d1e5f6d2317efc2cd15c2b37b9f835c948188a820041e82b38b0f81afc9d78ba2b7
6
+ metadata.gz: ebb5734cc56973eba83666cec7a4ff2664327609aa1716a67d880aa2f0e1e30a98cbe43558f2198a3f35b1e95df7da39e9eec8907dbb71ef653bf24522aa22ef
7
+ data.tar.gz: 5f1be9eaef644cce6e06f60e3d36459ccb84d1fd1f8346b6b2d25a3afd8d6aeb678a555e17c985193ba76bf11649f7703153b28fe4572d321895e68ce3a4342a
data/README.md CHANGED
@@ -3,12 +3,13 @@
3
3
  [![Code Climate](https://codeclimate.com/github/doits/pronto-eslint_npm.svg)](https://codeclimate.com/github/doits/pronto-eslint_npm)
4
4
  [![Build Status](https://travis-ci.org/doits/pronto-eslint_npm.svg?branch=master)](https://travis-ci.org/doits/pronto-eslint_npm)
5
5
  [![Gem Version](https://badge.fury.io/rb/pronto-eslint_npm.svg)](http://badge.fury.io/rb/pronto-eslint_npm)
6
- [![Dependency Status](https://gemnasium.com/doits/pronto-eslint_npm.svg)](https://gemnasium.com/doits/pronto-eslint_npm)
7
6
 
8
7
  Pronto runner for [ESlint](http://eslint.org), pluggable linting utility for JavaScript and JSX. [What is Pronto?](https://github.com/mmozuras/pronto)
9
8
 
10
9
  Uses official eslint executable installed by `npm` in contrast to [pronto-eslint][pronto-eslint].
11
10
 
11
+ :exclamation:**Not maintained anymore**:exclamation:: This gem is not maintened anymore and will receive no updates. If you want to step in as a maintainer, please open an issue to discuss it.
12
+
12
13
  [pronto-eslint]: https://github.com/mmozuras/pronto-eslint
13
14
 
14
15
  ## Prerequisites
@@ -34,12 +35,14 @@ Following options are available:
34
35
  | Option | Meaning | Default |
35
36
  | ----------------- | ---------------------------------------------------------------------------------------- | ----------------------------------- |
36
37
  | eslint_executable | ESLint executable to call. | `eslint` (calls `eslint` in `PATH`) |
37
- | files_to_lint | What files to lint. Absolute path of offending file will be matched against this Regexp. | `(\.js|\.es6)$` |
38
+ | files_to_lint | What files to lint. Absolute path of offending file will be matched against this Regexp. | `(\.js\|\.es6)$` |
39
+ | cmd_line_opts | Command line options to pass to eslint when running | '' |
38
40
 
39
41
  Example configuration to call custom eslint executable and only lint files ending with `.my_custom_extension`:
40
42
 
41
43
  ```yaml
42
- # .pronto_eslint_npm.yaml
44
+ # .pronto_eslint_npm.yml
43
45
  eslint_executable: '/my/custom/node/path/.bin/eslint'
44
46
  files_to_lint: '\.my_custom_extension$'
47
+ cmd_line_opts: '--ext .html,.js,.es6'
45
48
  ```
@@ -1,33 +1,44 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'pronto'
2
4
  require 'shellwords'
3
5
 
4
6
  module Pronto
5
7
  class ESLintNpm < Runner
6
8
  CONFIG_FILE = '.pronto_eslint_npm.yml'.freeze
7
- CONFIG_KEYS = %w(eslint_executable files_to_lint).freeze
9
+ CONFIG_KEYS = %w[eslint_executable files_to_lint cmd_line_opts].freeze
10
+ SEVERITY_LEVELS = [nil, :warning, :error].freeze
8
11
 
9
- attr_writer :eslint_executable
12
+ attr_writer :eslint_executable, :cmd_line_opts
10
13
 
11
14
  def eslint_executable
12
- @eslint_executable || 'eslint'.freeze
15
+ @eslint_executable || 'eslint'
13
16
  end
14
17
 
15
18
  def files_to_lint
16
19
  @files_to_lint || /(\.js|\.es6)$/
17
20
  end
18
21
 
22
+ def cmd_line_opts
23
+ @cmd_line_opts || ''
24
+ end
25
+
19
26
  def files_to_lint=(regexp)
20
27
  @files_to_lint = regexp.is_a?(Regexp) && regexp || Regexp.new(regexp)
21
28
  end
22
29
 
23
- def read_config
24
- config_file = File.join(repo_path, CONFIG_FILE)
25
- return unless File.exist?(config_file)
26
- config = YAML.load_file(config_file)
30
+ def config_options
31
+ @config_options ||=
32
+ begin
33
+ config_file = File.join(repo_path, CONFIG_FILE)
34
+ File.exist?(config_file) && YAML.load_file(config_file) || {}
35
+ end
36
+ end
27
37
 
28
- CONFIG_KEYS.each do |config_key|
29
- next unless config[config_key]
30
- send("#{config_key}=", config[config_key])
38
+ def read_config
39
+ config_options.each do |key, val|
40
+ next unless CONFIG_KEYS.include?(key.to_s)
41
+ send("#{key}=", val)
31
42
  end
32
43
  end
33
44
 
@@ -46,23 +57,23 @@ module Pronto
46
57
  private
47
58
 
48
59
  def repo_path
49
- @_repo_path ||= @patches.first.repo.path
60
+ @repo_path ||= @patches.first.repo.path
50
61
  end
51
62
 
52
63
  def inspect(patch)
64
+ lines = patch.added_lines
53
65
  offences = run_eslint(patch)
54
66
  clean_up_eslint_output(offences)
55
67
  .map do |offence|
56
- patch
57
- .added_lines
58
- .select { |line| line.new_lineno == offence['line'] }
59
- .map { |line| new_message(offence, line) }
68
+ range = offence['line']..(offence['endLine'] || offence['line'])
69
+ line = lines.select { |line| range.cover?(line.new_lineno) }.last
70
+ new_message(offence, line) if line
60
71
  end
61
72
  end
62
73
 
63
74
  def new_message(offence, line)
64
- path = line.patch.delta.new_file[:path]
65
- level = :warning
75
+ path = line.patch.delta.new_file[:path]
76
+ level = SEVERITY_LEVELS.fetch(offence['severity'], :warning)
66
77
 
67
78
  Message.new(path, line, level, offence['message'], nil, self.class)
68
79
  end
@@ -73,13 +84,14 @@ module Pronto
73
84
 
74
85
  def run_eslint(patch)
75
86
  Dir.chdir(repo_path) do
76
- escaped_file_path = Shellwords.escape(patch.new_file_full_path.to_s)
77
- JSON.parse(
78
- `#{eslint_executable} #{escaped_file_path} -f json`
79
- )
87
+ JSON.parse `#{eslint_command_line(patch.new_file_full_path.to_s)}`
80
88
  end
81
89
  end
82
90
 
91
+ def eslint_command_line(path)
92
+ "#{eslint_executable} #{cmd_line_opts} #{Shellwords.escape(path)} -f json"
93
+ end
94
+
83
95
  def clean_up_eslint_output(output)
84
96
  # 1. Filter out offences without a warning or error
85
97
  # 2. Get the messages for that file
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Pronto
2
4
  module ESLintNpmVersion
3
- VERSION = '0.8.1'.freeze
5
+ VERSION = '0.11.0'.freeze
4
6
  end
5
7
  end
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pronto-eslint_npm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.1
4
+ version: 0.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Markus Doits
8
8
  - Mindaugas Mozūras
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-02-16 00:00:00.000000000 Z
12
+ date: 2021-05-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: pronto
@@ -17,14 +17,14 @@ dependencies:
17
17
  requirements:
18
18
  - - "~>"
19
19
  - !ruby/object:Gem::Version
20
- version: 0.8.0
20
+ version: 0.11.0
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - "~>"
26
26
  - !ruby/object:Gem::Version
27
- version: 0.8.0
27
+ version: 0.11.0
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: rake
30
30
  requirement: !ruby/object:Gem::Requirement
@@ -59,7 +59,7 @@ dependencies:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
61
  version: '3.4'
62
- description:
62
+ description:
63
63
  email: markus.doits@gmail.com
64
64
  executables: []
65
65
  extensions: []
@@ -71,11 +71,11 @@ files:
71
71
  - README.md
72
72
  - lib/pronto/eslint_npm.rb
73
73
  - lib/pronto/eslint_npm/version.rb
74
- homepage: http://github.org/doits/pronto-eslint_npm
74
+ homepage: https://github.com/doits/pronto-eslint_npm
75
75
  licenses:
76
76
  - MIT
77
77
  metadata: {}
78
- post_install_message:
78
+ post_install_message:
79
79
  rdoc_options: []
80
80
  require_paths:
81
81
  - lib
@@ -83,7 +83,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
83
83
  requirements:
84
84
  - - ">="
85
85
  - !ruby/object:Gem::Version
86
- version: 2.0.0
86
+ version: 2.3.0
87
87
  required_rubygems_version: !ruby/object:Gem::Requirement
88
88
  requirements:
89
89
  - - ">="
@@ -91,9 +91,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
91
91
  version: '0'
92
92
  requirements:
93
93
  - eslint (in PATH)
94
- rubyforge_project:
95
- rubygems_version: 2.6.10
96
- signing_key:
94
+ rubygems_version: 3.2.15
95
+ signing_key:
97
96
  specification_version: 4
98
97
  summary: Pronto runner for ESLint, pluggable linting utility for JavaScript and JSX
99
98
  test_files: []