gl_lint 0.5.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +14 -7
- data/gl_lint.gemspec +0 -3
- data/lib/gl_lint/cli.rb +8 -6
- data/lib/gl_lint/export_rubocop.rb +3 -4
- data/lib/gl_lint/file_selector.rb +2 -2
- data/lib/gl_lint/linter.rb +6 -6
- data/lib/gl_lint/version.rb +1 -1
- data/lib/gl_lint.rb +2 -2
- metadata +2 -44
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 836ecbd9eb8d9a231c39ae7241b7070c1af7d146ba3c3228949e1cea281c8201
|
4
|
+
data.tar.gz: 373971c3b5a492c56afb983d1e53a44e354cb597ec9183d72dd8a5a15d2e077e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a80e065d4e61a72eac3ed35a9045e4ab993f13a8f1851187a7cfa98735b92ceae26255d4e466cd7764e9e05d1f919b39a280bc06d90775876825d0641a068683
|
7
|
+
data.tar.gz: a7520aac3a6a0a9ea9a131d1b42ecd52c08c77fd7ae00b4734eaf535cb5b8277fcbb9bd40633496f0fb04fd4425bbf87b4c2fab7322db4b05f2ba8d089d0c8a9
|
data/README.md
CHANGED
@@ -1,6 +1,13 @@
|
|
1
|
-
# Give Lively Lint
|
1
|
+
# Give Lively Lint runner
|
2
|
+
|
3
|
+
`GLLint` is a Ruby gem that handles running linters against specific files (e.g. just the changed files from a branch). It leverages `git`, `rubocop` and `eslint`
|
4
|
+
|
5
|
+
This is particularly useful for large projects where you don't want to lint all the files in the project.
|
6
|
+
|
7
|
+
At Give Lively, we add a file to `bin/lint` and have it call this gem to lint with autocorrect.
|
8
|
+
|
9
|
+
GLLint also adds a way to create a yaml file with all the currently configured rubocop rules (`.rubocop_rules.yml`). This is done via `bin/lint --write-rubocop-rules`. This file is useful to compare what changes when updating Rubocop rules, changing gems or Ruby versions.
|
2
10
|
|
3
|
-
Linting tool.
|
4
11
|
|
5
12
|
## Installation
|
6
13
|
|
@@ -18,11 +25,11 @@ Or install it yourself as:
|
|
18
25
|
|
19
26
|
$ gem install gl_lint
|
20
27
|
|
21
|
-
|
28
|
+
### bin/lint
|
22
29
|
|
23
30
|
Create a an executable `bin/lint` file with:
|
24
31
|
|
25
|
-
`touch bin/lint && chmod
|
32
|
+
`touch bin/lint && chmod +x bin/lint`
|
26
33
|
|
27
34
|
Then add this to the file:
|
28
35
|
|
@@ -34,11 +41,11 @@ require 'gl_lint'
|
|
34
41
|
GLLint.call_cli(app_root: File.expand_path('..', __dir__))
|
35
42
|
```
|
36
43
|
|
37
|
-
Then run `bin/lint` to lint your changes
|
44
|
+
Then run `bin/lint` to lint your changes.
|
38
45
|
|
39
|
-
Alternatively, if your project doesn't have JavaScript, add `linters: ['rubocop
|
46
|
+
Alternatively, if your project doesn't have JavaScript, add `linters: ['rubocop']`
|
40
47
|
|
41
48
|
```ruby
|
42
49
|
GLLint.call_cli(app_root: File.expand_path('..', __dir__),
|
43
|
-
|
50
|
+
linters: ['rubocop'])
|
44
51
|
```
|
data/gl_lint.gemspec
CHANGED
@@ -26,9 +26,6 @@ Gem::Specification.new do |spec|
|
|
26
26
|
|
27
27
|
spec.add_dependency 'optparse'
|
28
28
|
spec.add_dependency 'rubocop'
|
29
|
-
spec.add_dependency 'rubocop-performance'
|
30
|
-
spec.add_dependency 'rubocop-rake'
|
31
|
-
spec.add_dependency 'rubocop-rspec'
|
32
29
|
|
33
30
|
spec.metadata['rubygems_mfa_required'] = 'true'
|
34
31
|
end
|
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
|
5
|
+
LINTERS = %w[rubocop eslint].freeze
|
6
6
|
DEFAULT_TARGET = '--changed'.freeze
|
7
7
|
|
8
8
|
TARGET_FILE_OPTS = [
|
@@ -33,11 +33,11 @@ module GLLint
|
|
33
33
|
options[:linters] = ['rubocop']
|
34
34
|
end
|
35
35
|
|
36
|
-
parser.on('--
|
37
|
-
raise "This project doesn't support rubocop" unless LINTERS.include?('
|
38
|
-
raise "You can't pass both --rubocop and --
|
36
|
+
parser.on('--eslint', 'Lints only with eslint') do
|
37
|
+
raise "This project doesn't support rubocop" unless LINTERS.include?('eslint')
|
38
|
+
raise "You can't pass both --rubocop and --eslint" if options[:linters] == ['rubocop']
|
39
39
|
|
40
|
-
options[:linters] = ['
|
40
|
+
options[:linters] = ['eslint']
|
41
41
|
end
|
42
42
|
|
43
43
|
parser.on('--no-fix', 'Does not auto-fix') do
|
@@ -77,7 +77,9 @@ module GLLint
|
|
77
77
|
options[:filenames] = ARGV
|
78
78
|
puts "passed files: #{options[:filenames]}"
|
79
79
|
|
80
|
-
|
80
|
+
if options[:target_files]
|
81
|
+
raise "Passed both 'filenames' and 'target files': #{options[:target_files]}"
|
82
|
+
end
|
81
83
|
end
|
82
84
|
options[:target_files] ||= options[:default_target]
|
83
85
|
options
|
@@ -7,10 +7,9 @@ module GLLint
|
|
7
7
|
StyleGuide SupportedStyles].freeze
|
8
8
|
|
9
9
|
def write_rules(app_root)
|
10
|
-
puts
|
10
|
+
puts "Updating .rubocop_rules.yml - version: #{rubocop_version}"
|
11
11
|
|
12
|
-
enabled_rules =
|
13
|
-
rubocop_rules.map { |arr| stored_rule(app_root, arr) }.compact
|
12
|
+
enabled_rules = rubocop_rules.map { |arr| stored_rule(app_root, arr) }.compact
|
14
13
|
|
15
14
|
File.write('.rubocop_rules.yml', YAML.dump(enabled_rules.to_h))
|
16
15
|
end
|
@@ -35,7 +34,7 @@ module GLLint
|
|
35
34
|
end
|
36
35
|
|
37
36
|
def rubocop_version
|
38
|
-
`rubocop -V`.strip.split("\n").first.split('[').first.strip
|
37
|
+
`rubocop -V`.strip.split("\n").first.split('[').first.strip.gsub(' running on', '')
|
39
38
|
end
|
40
39
|
end
|
41
40
|
end
|
@@ -13,10 +13,10 @@ module GLLint
|
|
13
13
|
# Make certain that schemas are ignored
|
14
14
|
rubocop_files.reject! { |f| f.match?(%r{db/.*schema.rb}) }
|
15
15
|
|
16
|
-
|
16
|
+
eslint_files = selected_files.grep(/\.(js|jsx|css)\z/)
|
17
17
|
end
|
18
18
|
|
19
|
-
{ rubocop: rubocop_files,
|
19
|
+
{ rubocop: rubocop_files, eslint: eslint_files }
|
20
20
|
end
|
21
21
|
|
22
22
|
private
|
data/lib/gl_lint/linter.rb
CHANGED
@@ -8,7 +8,7 @@ module GLLint
|
|
8
8
|
|
9
9
|
lint_ruby_files(linters, target_files, files[:rubocop], lint_strategy)
|
10
10
|
|
11
|
-
|
11
|
+
lint_eslint_files(linters, target_files, files[:eslint], lint_strategy)
|
12
12
|
|
13
13
|
puts '' # Add some space after printing linting out
|
14
14
|
|
@@ -59,15 +59,15 @@ module GLLint
|
|
59
59
|
)
|
60
60
|
end
|
61
61
|
|
62
|
-
def
|
63
|
-
return unless linters.include?('
|
62
|
+
def lint_eslint_files(linters, target_files, files, strategy)
|
63
|
+
return unless linters.include?('eslint')
|
64
64
|
|
65
|
-
result = print_files(target_files, files, strategy, '
|
65
|
+
result = print_files(target_files, files, strategy, 'eslint')
|
66
66
|
return if result == :skip_lint
|
67
67
|
|
68
68
|
# Need to manually call eslint, the package.json script specifies the folders to lint
|
69
|
-
|
70
|
-
run_linter("yarn run #{
|
69
|
+
eslint_command = strategy == :no_fix ? 'eslint' : 'eslint --fix'
|
70
|
+
run_linter("yarn run #{eslint_command} #{files&.join(' ')}")
|
71
71
|
end
|
72
72
|
end
|
73
73
|
end
|
data/lib/gl_lint/version.rb
CHANGED
data/lib/gl_lint.rb
CHANGED
@@ -12,8 +12,8 @@ module GLLint
|
|
12
12
|
call(**options.except(:verbose, :default_target))
|
13
13
|
end
|
14
14
|
|
15
|
-
def call(app_root:, write_rubocop_rules: false, no_fix: false, list_only: false,
|
16
|
-
target_files: nil, filenames: nil)
|
15
|
+
def call(app_root:, write_rubocop_rules: false, no_fix: false, list_only: false,
|
16
|
+
unsafe_fix: false, linters: nil, target_files: nil, filenames: nil)
|
17
17
|
|
18
18
|
Dir.chdir(app_root) do
|
19
19
|
if write_rubocop_rules
|
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.6.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: 2025-01-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: optparse
|
@@ -38,48 +38,6 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: rubocop-performance
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - ">="
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '0'
|
48
|
-
type: :runtime
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - ">="
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '0'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: rubocop-rake
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - ">="
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
62
|
-
type: :runtime
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - ">="
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '0'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: rubocop-rspec
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - ">="
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '0'
|
76
|
-
type: :runtime
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - ">="
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '0'
|
83
41
|
description:
|
84
42
|
email:
|
85
43
|
executables: []
|