gl_lint 0.7.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/gl_lint.gemspec +4 -4
- data/lib/gl_lint/cli.rb +15 -3
- data/lib/gl_lint/file_selector.rb +8 -6
- data/lib/gl_lint/linter.rb +13 -2
- data/lib/gl_lint/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 99f72c30fc5ab80f422a5a6911919739d695e8cd36a3067095b561bfc255dad5
|
|
4
|
+
data.tar.gz: 84144cee8bde61a10dc5a4250a1a8daafa71955f838e1fe21370ab40167aad69
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2df622db916252bc2be9f2e1616dbdf1243b76433d2a1959f880ab2b108d3afe19c224403a4fb7f24722db01a6cb9cb2d5d68f08af9d3fa00e00c169c186b95b
|
|
7
|
+
data.tar.gz: 3b0c24fcb6a5c84e863de3d78416585bb66496d5e5891d07a35cdca8dd9840b02732fa7fcac17ba3464e062799d8f57169751507126c7f8e4131f47a8e2c3aa6
|
data/gl_lint.gemspec
CHANGED
|
@@ -5,8 +5,6 @@ lib = File.expand_path('lib', __dir__)
|
|
|
5
5
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
6
6
|
require 'gl_lint/version'
|
|
7
7
|
|
|
8
|
-
NON_GEM_FILES = ['Gemfile', 'Gemfile.lock', 'Guardfile', 'bin/lint'].freeze
|
|
9
|
-
|
|
10
8
|
Gem::Specification.new do |spec|
|
|
11
9
|
spec.name = 'gl_lint'
|
|
12
10
|
spec.version = GLLint::VERSION
|
|
@@ -20,8 +18,10 @@ Gem::Specification.new do |spec|
|
|
|
20
18
|
|
|
21
19
|
spec.extra_rdoc_files = ['README.md']
|
|
22
20
|
|
|
23
|
-
spec.files =
|
|
24
|
-
|
|
21
|
+
spec.files =
|
|
22
|
+
`git ls-files`.split($INPUT_RECORD_SEPARATOR).grep_v(/^(spec|\.)/) -
|
|
23
|
+
%w[Gemfile Gemfile.lock Guardfile bin/lint]
|
|
24
|
+
|
|
25
25
|
spec.require_paths = ['lib']
|
|
26
26
|
|
|
27
27
|
spec.add_dependency 'optparse'
|
data/lib/gl_lint/cli.rb
CHANGED
|
@@ -2,7 +2,7 @@ require 'optparse'
|
|
|
2
2
|
|
|
3
3
|
module GLLint
|
|
4
4
|
class CLI
|
|
5
|
-
LINTERS = %w[rubocop eslint].freeze
|
|
5
|
+
LINTERS = %w[rubocop eslint herb].freeze
|
|
6
6
|
DEFAULT_TARGET = '--changed'.freeze
|
|
7
7
|
|
|
8
8
|
TARGET_FILE_OPTS = [
|
|
@@ -34,12 +34,24 @@ module GLLint
|
|
|
34
34
|
end
|
|
35
35
|
|
|
36
36
|
parser.on('--eslint', 'Lints only with eslint') do
|
|
37
|
-
raise "This project doesn't support
|
|
38
|
-
|
|
37
|
+
raise "This project doesn't support eslint" unless LINTERS.include?('eslint')
|
|
38
|
+
if options[:linters] == ['rubocop'] || options[:linters] == ['herb']
|
|
39
|
+
raise "You can't pass both --rubocop and --eslint"
|
|
40
|
+
end
|
|
39
41
|
|
|
40
42
|
options[:linters] = ['eslint']
|
|
41
43
|
end
|
|
42
44
|
|
|
45
|
+
parser.on('--herb', 'Lints only with herb') do
|
|
46
|
+
raise "This project doesn't support herb" unless LINTERS.include?('herb')
|
|
47
|
+
|
|
48
|
+
if options[:linters] == ['rubocop'] || options[:linters] == ['eslint']
|
|
49
|
+
raise "You can't pass --rubocop or --eslint and --herb"
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
options[:linters] = ['herb']
|
|
53
|
+
end
|
|
54
|
+
|
|
43
55
|
parser.on('--no-fix', 'Does not auto-fix') do
|
|
44
56
|
options[:no_fix] = true
|
|
45
57
|
end
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
module GLLint
|
|
2
2
|
class FileSelector
|
|
3
|
-
NON_RB_RUBY_FILES = %w[Gemfile Rakefile config.ru
|
|
3
|
+
NON_RB_RUBY_FILES = %w[Gemfile Rakefile config.ru .haml
|
|
4
4
|
bin/bundle bin/lint bin/rubocop bin/setup bin/update].freeze
|
|
5
5
|
|
|
6
6
|
class << self
|
|
@@ -8,15 +8,17 @@ module GLLint
|
|
|
8
8
|
selected_files = filenames || filenames_from_target_files(target_files)
|
|
9
9
|
|
|
10
10
|
if selected_files
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
rubocop = selected_files.grep(/\.(rb|rake|gemspec)\z/)
|
|
12
|
+
rubocop += selected_files.select { |f| f.end_with?(*NON_RB_RUBY_FILES) }
|
|
13
13
|
# Make certain that schemas are ignored
|
|
14
|
-
|
|
14
|
+
rubocop.reject! { |f| f.match?(%r{db/.*schema.rb}) }
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
eslint = selected_files.grep(/\.(js|jsx|css)\z/)
|
|
17
|
+
|
|
18
|
+
herb = selected_files.grep(/\.(erb|html|rhtml)\z/)
|
|
17
19
|
end
|
|
18
20
|
|
|
19
|
-
{ rubocop
|
|
21
|
+
{ rubocop:, eslint:, herb: }
|
|
20
22
|
end
|
|
21
23
|
|
|
22
24
|
private
|
data/lib/gl_lint/linter.rb
CHANGED
|
@@ -7,8 +7,8 @@ module GLLint
|
|
|
7
7
|
files = GLLint::FileSelector.files(filenames:, target_files:)
|
|
8
8
|
|
|
9
9
|
lint_ruby_files(linters, target_files, files[:rubocop], lint_strategy)
|
|
10
|
-
|
|
11
10
|
lint_eslint_files(linters, target_files, files[:eslint], lint_strategy)
|
|
11
|
+
lint_herb_files(linters, target_files, files[:herb], lint_strategy)
|
|
12
12
|
|
|
13
13
|
puts '' # Add some space after printing linting out
|
|
14
14
|
|
|
@@ -63,11 +63,22 @@ module GLLint
|
|
|
63
63
|
return unless linters.include?('eslint')
|
|
64
64
|
|
|
65
65
|
result = print_files(target_files, files, strategy, 'eslint')
|
|
66
|
-
return if result == :
|
|
66
|
+
return if result == :no_lint
|
|
67
67
|
|
|
68
68
|
# Need to manually call eslint, the package.json script specifies the folders to lint
|
|
69
69
|
eslint_command = strategy == :no_fix ? 'eslint' : 'eslint --fix'
|
|
70
70
|
run_linter("yarn run #{eslint_command} #{files&.join(' ')}")
|
|
71
71
|
end
|
|
72
|
+
|
|
73
|
+
def lint_herb_files(linters, target_files, files, strategy)
|
|
74
|
+
return unless linters.include?('herb')
|
|
75
|
+
|
|
76
|
+
result = print_files(target_files, files, strategy, 'herb')
|
|
77
|
+
return if result == :no_lint
|
|
78
|
+
|
|
79
|
+
# Need to manually call herb, the .herb.yml specifies the folders to lint,
|
|
80
|
+
herb_command = strategy == :no_fix ? 'herb-format --check' : 'herb-format'
|
|
81
|
+
run_linter("yarn run #{herb_command} #{files&.join(' ')}")
|
|
82
|
+
end
|
|
72
83
|
end
|
|
73
84
|
end
|
data/lib/gl_lint/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: gl_lint
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.9.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Give Lively
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2026-02-27 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: optparse
|
|
@@ -75,7 +75,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
75
75
|
- !ruby/object:Gem::Version
|
|
76
76
|
version: '0'
|
|
77
77
|
requirements: []
|
|
78
|
-
rubygems_version: 3.
|
|
78
|
+
rubygems_version: 3.5.22
|
|
79
79
|
signing_key:
|
|
80
80
|
specification_version: 4
|
|
81
81
|
summary: Give Lively linter tool
|