gl_lint 0.2.1 → 0.3.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 +2 -12
- data/gl_lint.gemspec +4 -1
- data/lib/gl_lint/cli.rb +10 -6
- data/lib/gl_lint/export_rubocop.rb +6 -1
- data/lib/gl_lint/version.rb +1 -1
- data/lib/gl_lint.rb +19 -14
- metadata +2 -5
- data/Gemfile +0 -11
- data/Guardfile +0 -25
- data/bin/lint +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fe075647d55d0b39b011170299fe77b82c46fbca37be7e22187d9946ea76bff7
|
4
|
+
data.tar.gz: 960a6494ad564bdd40044fa69219b1a8a5b514dcb9c1922f4440fbe7f7dc603e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a881651be9f699133abd4964b31f2ac3420df486ba81d9946a145c2c4189c00aef384539bf6bdb1ea8a353880ce124952e7851521f240746d18e39b53e824c9a
|
7
|
+
data.tar.gz: f4f1a2874f0355664d0a1f9526cba3cc3eaa94c965a431f05c4ca0d97f4a142f391ed918f7758b5f5be05a95357ce442d5be7c7e376125d42db0d37a42e5a3a7
|
data/README.md
CHANGED
@@ -31,7 +31,7 @@ Then add this to the file:
|
|
31
31
|
require 'rubygems'
|
32
32
|
require 'gl_lint'
|
33
33
|
|
34
|
-
GlLint.
|
34
|
+
GlLint.call_cli(app_root: File.expand_path('..', __dir__))
|
35
35
|
```
|
36
36
|
|
37
37
|
Then run `bin/lint` to lint your changes
|
@@ -39,16 +39,6 @@ Then run `bin/lint` to lint your changes
|
|
39
39
|
Alternatively, if your project doesn't have JavaScript, add `linters: ['rubocop]`
|
40
40
|
|
41
41
|
```ruby
|
42
|
-
GlLint.
|
42
|
+
GlLint.call_cli(app_root: File.expand_path('..', __dir__),
|
43
43
|
linters: ['rubocop'])
|
44
44
|
```
|
45
|
-
|
46
|
-
## Publishing gem to rubygems!
|
47
|
-
|
48
|
-
[Build the gem](http://guides.rubygems.org/make-your-own-gem/)
|
49
|
-
|
50
|
-
gem build gl_lint.gemspec
|
51
|
-
|
52
|
-
[Push to rubygems](http://guides.rubygems.org/publishing/)
|
53
|
-
|
54
|
-
gem push gl_lint-0.2.0.gem
|
data/gl_lint.gemspec
CHANGED
@@ -5,6 +5,8 @@ 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
|
+
|
8
10
|
Gem::Specification.new do |spec|
|
9
11
|
spec.name = 'gl_lint'
|
10
12
|
spec.version = GlLint::VERSION
|
@@ -18,7 +20,8 @@ Gem::Specification.new do |spec|
|
|
18
20
|
|
19
21
|
spec.extra_rdoc_files = ['README.md']
|
20
22
|
|
21
|
-
spec.files = `git ls-files
|
23
|
+
spec.files = `git ls-files`
|
24
|
+
.split($INPUT_RECORD_SEPARATOR).grep_v(/^(spec|\.)/) - NON_GEM_FILES
|
22
25
|
spec.require_paths = ['lib']
|
23
26
|
|
24
27
|
spec.add_dependency 'optparse'
|
data/lib/gl_lint/cli.rb
CHANGED
@@ -15,9 +15,8 @@ module GlLint
|
|
15
15
|
class << self
|
16
16
|
# Disabling metrics, it doesn't make sense to deconstruct the CLI parser
|
17
17
|
# rubocop:disable Metrics
|
18
|
-
def parse(app_root:, linters: nil, default_target: nil)
|
19
|
-
options =
|
20
|
-
.merge(app_root:)
|
18
|
+
def parse(app_root:, linters: nil, default_target: nil, options: {})
|
19
|
+
options = default_options(linters:, app_root:, default_target:).merge(options)
|
21
20
|
|
22
21
|
OptionParser.new do |parser|
|
23
22
|
TARGET_FILE_OPTS.each do |args|
|
@@ -80,7 +79,6 @@ module GlLint
|
|
80
79
|
|
81
80
|
raise "Passed both 'filenames' and 'target files': #{options[:target_files]}" if options[:target_files]
|
82
81
|
end
|
83
|
-
|
84
82
|
options[:target_files] ||= options[:default_target]
|
85
83
|
options
|
86
84
|
end
|
@@ -88,11 +86,17 @@ module GlLint
|
|
88
86
|
|
89
87
|
private
|
90
88
|
|
91
|
-
def
|
89
|
+
def default_options(linters:, app_root:, default_target:)
|
92
90
|
{
|
91
|
+
app_root:,
|
92
|
+
default_target: default_target || DEFAULT_TARGET,
|
93
|
+
filenames: nil,
|
93
94
|
linters: linters || LINTERS,
|
95
|
+
list_only: false,
|
96
|
+
no_fix: false,
|
94
97
|
unsafe_fix: ENV['UNSAFE_LINT'] == 'true',
|
95
|
-
|
98
|
+
verbose: false,
|
99
|
+
write_rubocop_rules: false
|
96
100
|
}
|
97
101
|
end
|
98
102
|
end
|
@@ -9,7 +9,8 @@ module GlLint
|
|
9
9
|
def write_rules(app_root)
|
10
10
|
puts 'Updating .rubocop_rules.yml'
|
11
11
|
|
12
|
-
enabled_rules =
|
12
|
+
enabled_rules = [['RuboCop-version', rubocop_version]] +
|
13
|
+
rubocop_rules.map { |arr| stored_rule(app_root, arr) }.compact
|
13
14
|
|
14
15
|
File.write('.rubocop_rules.yml', YAML.dump(enabled_rules.to_h))
|
15
16
|
end
|
@@ -32,6 +33,10 @@ module GlLint
|
|
32
33
|
YAML.safe_load(`rubocop -c .rubocop.yml --show-cops`,
|
33
34
|
permitted_classes: [Regexp, Symbol]).to_a
|
34
35
|
end
|
36
|
+
|
37
|
+
def rubocop_version
|
38
|
+
`rubocop -V`.strip.split("\n").first.split('[').first.strip
|
39
|
+
end
|
35
40
|
end
|
36
41
|
end
|
37
42
|
end
|
data/lib/gl_lint/version.rb
CHANGED
data/lib/gl_lint.rb
CHANGED
@@ -5,28 +5,33 @@ require 'gl_lint/export_rubocop'
|
|
5
5
|
|
6
6
|
module GlLint
|
7
7
|
class << self
|
8
|
-
def
|
9
|
-
|
10
|
-
|
8
|
+
def call_cli(app_root:, linters: nil)
|
9
|
+
options = GlLint::CLI.parse(app_root:, linters:)
|
10
|
+
puts 'Options: ', options, '' if options[:verbose]
|
11
11
|
|
12
|
-
|
12
|
+
call(**options.except(:verbose, :default_target))
|
13
13
|
end
|
14
14
|
|
15
|
-
def
|
16
|
-
|
17
|
-
puts 'Options: ', options, '' if options[:verbose]
|
15
|
+
def call(app_root:, write_rubocop_rules: false, no_fix: false, list_only: false, unsafe_fix: false, linters: nil,
|
16
|
+
target_files: nil, filenames: nil)
|
18
17
|
|
19
|
-
Dir.chdir(
|
20
|
-
if
|
18
|
+
Dir.chdir(app_root) do
|
19
|
+
if write_rubocop_rules
|
21
20
|
GlLint::ExportRubocop.write_rules(app_root)
|
22
21
|
else
|
23
|
-
lint_strategy = lint_strategy_from_options(
|
24
|
-
|
25
|
-
linter_args = options.slice(:linters, :target_files, :filenames)
|
26
|
-
.merge(lint_strategy:)
|
27
|
-
GlLint::Linter.new.lint(**linter_args)
|
22
|
+
lint_strategy = lint_strategy_from_options(no_fix:, list_only:, unsafe_fix:)
|
23
|
+
GlLint::Linter.new.lint(linters:, target_files:, filenames:, lint_strategy:)
|
28
24
|
end
|
29
25
|
end
|
30
26
|
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def lint_strategy_from_options(no_fix: false, list_only: false, unsafe_fix: false)
|
31
|
+
return :list_only if list_only
|
32
|
+
return :no_fix if no_fix
|
33
|
+
|
34
|
+
unsafe_fix ? :unsafe_fix : :fix
|
35
|
+
end
|
31
36
|
end
|
32
37
|
end
|
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.3.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: 2024-03-
|
11
|
+
date: 2024-03-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: optparse
|
@@ -87,11 +87,8 @@ extensions: []
|
|
87
87
|
extra_rdoc_files:
|
88
88
|
- README.md
|
89
89
|
files:
|
90
|
-
- Gemfile
|
91
|
-
- Guardfile
|
92
90
|
- LICENSE
|
93
91
|
- README.md
|
94
|
-
- bin/lint
|
95
92
|
- gl_lint.gemspec
|
96
93
|
- lib/gl_lint.rb
|
97
94
|
- lib/gl_lint/cli.rb
|
data/Gemfile
DELETED
data/Guardfile
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
directories %w[lib spec]
|
2
|
-
|
3
|
-
rspec_options = {
|
4
|
-
cmd: 'bundle exec rspec',
|
5
|
-
all_after_pass: false,
|
6
|
-
all_on_start: false,
|
7
|
-
failed_mode: :focus
|
8
|
-
}
|
9
|
-
|
10
|
-
guard :rspec, rspec_options do
|
11
|
-
require 'guard/rspec/dsl'
|
12
|
-
dsl = Guard::RSpec::Dsl.new(self)
|
13
|
-
|
14
|
-
# Feel free to open issues for suggestions and improvements
|
15
|
-
|
16
|
-
# RSpec files
|
17
|
-
rspec = dsl.rspec
|
18
|
-
watch(rspec.spec_helper) { rspec.spec_dir }
|
19
|
-
watch(rspec.spec_support) { rspec.spec_dir }
|
20
|
-
watch(rspec.spec_files)
|
21
|
-
|
22
|
-
# Ruby files
|
23
|
-
ruby = dsl.ruby
|
24
|
-
dsl.watch_spec_files_for(ruby.lib_files)
|
25
|
-
end
|