lintf 0.1.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 +7 -0
- data/CHANGELOG.md +11 -0
- data/LICENSE +21 -0
- data/README.md +74 -0
- data/bin/lintf +63 -0
- data/config/base.yml +6 -0
- data/config/erb_lint.yml +54 -0
- data/config/rubocop-performance.yml +154 -0
- data/config/rubocop-rails.yml +401 -0
- data/config/rubocop-rspec.yml +345 -0
- data/config/rubocop-rspec_rails.yml +22 -0
- data/config/rubocop.yml +1791 -0
- data/lib/lintf.rb +5 -0
- metadata +146 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 475858fee0d3177168e0dd9119c14a26e154d43da9d435970209f5d1efcb4927
|
4
|
+
data.tar.gz: e16ac31059c31675c89410e716a1b441ab1ad4639bce4e359f348f5dce1a0b52
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 9143f3a312a41e9dc58e98b4e0c5f1fd3f6957a2a88ffef9ce7a0f30b58df99be5a94bb2ff7fdb34ea1f080aa2e1a3d4d8d7639f0d9c95c0e0f0fa3e8acc8763
|
7
|
+
data.tar.gz: a5f55c6925bbadc4e1a2d22a0880401eaa7e96e6977cd3d2a4bc5990ccb1a9c6b409562d9b918547b80510222d161e76479381646f3bc6dba9efb8a351d3605a
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
## [0.1.0](https://rubygems.org/gems/lintf/versions/0.1.0) - 2024-12-21
|
4
|
+
|
5
|
+
- Add Lintf CLI
|
6
|
+
- Add RuboCop config
|
7
|
+
- Add RuboCop Performance config
|
8
|
+
- Add RuboCop Rails config
|
9
|
+
- Add RuboCop RSpec config
|
10
|
+
- Add RuboCop RSpecRails config
|
11
|
+
- Add ERB Lint config
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2024-present cdfzo
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Lintf
|
2
|
+
|
3
|
+
Linter and formatter collection for Ruby, including configuration for RuboCop
|
4
|
+
(Performance, Rails, RSpec, RSpecRails) and ERB Lint.
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
Run `bundle add lintf`.
|
9
|
+
|
10
|
+
## Configuration
|
11
|
+
|
12
|
+
### RuboCop
|
13
|
+
|
14
|
+
Edit `.rubocop.yml`:
|
15
|
+
|
16
|
+
```yml
|
17
|
+
inherit_gem:
|
18
|
+
lintf: config/base.yml
|
19
|
+
```
|
20
|
+
|
21
|
+
This will include all configured cops.
|
22
|
+
|
23
|
+
Alternatively, you can select the cops you want:
|
24
|
+
|
25
|
+
```yml
|
26
|
+
inherit_gem:
|
27
|
+
lintf:
|
28
|
+
- config/rubocop.yml
|
29
|
+
- config/rubocop-performance.yml
|
30
|
+
- config/rubocop-rails.yml
|
31
|
+
- config/rubocop-rspec.yml
|
32
|
+
- config/rubocop-rspec_rails.yml
|
33
|
+
```
|
34
|
+
|
35
|
+
### ERB Lint
|
36
|
+
|
37
|
+
Edit `.erb_lint.yml`:
|
38
|
+
|
39
|
+
```yml
|
40
|
+
inherit_gem:
|
41
|
+
lintf: config/erb_lint.yml
|
42
|
+
```
|
43
|
+
|
44
|
+
## Usage
|
45
|
+
|
46
|
+
By default, the CLI checks all touched files in the current branch using
|
47
|
+
`git diff origin/main`. You can change this behavior by passing the following
|
48
|
+
options:
|
49
|
+
|
50
|
+
- `-a`: All files tracked by Git (uses `git ls-files`)
|
51
|
+
- `-f`: Automatically fix problems (dangerous, e.g. `rubocop -A`)
|
52
|
+
|
53
|
+
### Available Linters
|
54
|
+
|
55
|
+
The following linters will be executed (in this order) if no arguments are given
|
56
|
+
and the linter's configuration file is present:
|
57
|
+
|
58
|
+
- `r`/`rubocop`: RuboCop
|
59
|
+
- `er`/`erblint`: ERB Lint
|
60
|
+
|
61
|
+
### Examples
|
62
|
+
|
63
|
+
Here are some examples of how to use the CLI:
|
64
|
+
|
65
|
+
- `bundle exec lintf`: Run all linters, but only on touched files
|
66
|
+
- `bundle exec lintf -f`: **Fix/format** touched files with all linters
|
67
|
+
- `bundle exec lintf er r`: Run **ERB Lint**, then **RuboCop**
|
68
|
+
- `bundle exec lintf -a rubocop`: Check **all** files with RuboCop
|
69
|
+
- `bundle exec lintf -fa r`: **Format all** files with RuboCop
|
70
|
+
|
71
|
+
## License
|
72
|
+
|
73
|
+
Lintf is released under the terms of the
|
74
|
+
[MIT License](https://codeberg.org/cdfzo/lintf-rb/src/branch/main/LICENSE).
|
data/bin/lintf
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
CONFIG = {
|
5
|
+
RuboCop: {
|
6
|
+
config: '.rubocop.yml',
|
7
|
+
run: 'bundle exec rubocop -c .rubocop.yml --force-exclusion db/schema.rb',
|
8
|
+
fix: '-A',
|
9
|
+
files: %w[rb rake gemspec],
|
10
|
+
},
|
11
|
+
'ERB Lint': {
|
12
|
+
config: '.erb_lint.yml',
|
13
|
+
run: 'bundle exec erb_lint',
|
14
|
+
fix: '-a',
|
15
|
+
files: %w[erb],
|
16
|
+
},
|
17
|
+
}.freeze
|
18
|
+
|
19
|
+
options = {}
|
20
|
+
runners = []
|
21
|
+
|
22
|
+
# Get runners and options
|
23
|
+
ARGV.each do |argument|
|
24
|
+
if argument.start_with? '-'
|
25
|
+
argument[1..].chars.each do |option|
|
26
|
+
case option
|
27
|
+
when 'a' then options[:all] = true
|
28
|
+
when 'f' then options[:fix] = true
|
29
|
+
else
|
30
|
+
puts "error: unknown option '#{argument}'"
|
31
|
+
exit 1
|
32
|
+
end
|
33
|
+
end
|
34
|
+
else
|
35
|
+
case argument
|
36
|
+
when 'er', 'erblint' then runners << :'ERB Lint'
|
37
|
+
when 'r', 'rubocop' then runners << :RuboCop
|
38
|
+
else
|
39
|
+
puts "error: unknown linter '#{argument}'"
|
40
|
+
exit 1
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
TRACKED_FILES = if options[:all] || `git branch --show-current`.strip == 'main'
|
46
|
+
`git ls-files`
|
47
|
+
else
|
48
|
+
`git diff origin/main --diff-filter=dxb --name-only`
|
49
|
+
end.split "\n"
|
50
|
+
|
51
|
+
# Execute runners
|
52
|
+
(runners.any? ? runners.uniq : CONFIG.keys).each do |name|
|
53
|
+
runner = CONFIG[name]
|
54
|
+
next unless File.file? runner[:config]
|
55
|
+
|
56
|
+
file_extensions = runner[:files].map { |extension| ".#{extension}" }
|
57
|
+
files = TRACKED_FILES.filter { |f| f.end_with?(*file_extensions) }.join ' '
|
58
|
+
next if files.empty?
|
59
|
+
|
60
|
+
puts "---- Executing #{name} ----"
|
61
|
+
option = runner[options[:fix] ? :fix : :check]
|
62
|
+
exit 1 unless system "#{runner[:run]} #{option} #{files}"
|
63
|
+
end
|
data/config/base.yml
ADDED
data/config/erb_lint.yml
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
glob: app/views/**/*.erb
|
2
|
+
|
3
|
+
linters:
|
4
|
+
AllowedScriptType:
|
5
|
+
enabled: true
|
6
|
+
ClosingErbTagIndent:
|
7
|
+
enabled: true
|
8
|
+
CommentSyntax:
|
9
|
+
enabled: true
|
10
|
+
ExtraNewline:
|
11
|
+
enabled: true
|
12
|
+
FinalNewline:
|
13
|
+
enabled: true
|
14
|
+
NoJavascriptTagHelper:
|
15
|
+
enabled: true
|
16
|
+
correction_style: plain
|
17
|
+
ParserErrors:
|
18
|
+
enabled: true
|
19
|
+
PartialInstanceVariable:
|
20
|
+
enabled: true
|
21
|
+
RequireInputAutocomplete:
|
22
|
+
enabled: true
|
23
|
+
RightTrim:
|
24
|
+
enabled: true
|
25
|
+
SelfClosingTag:
|
26
|
+
enabled: true
|
27
|
+
SpaceAroundErbTag:
|
28
|
+
enabled: true
|
29
|
+
SpaceIndentation:
|
30
|
+
enabled: true
|
31
|
+
SpaceInHtmlTag:
|
32
|
+
enabled: true
|
33
|
+
TrailingWhitespace:
|
34
|
+
enabled: true
|
35
|
+
DeprecatedClasses:
|
36
|
+
enabled: false
|
37
|
+
ErbSafety:
|
38
|
+
enabled: true
|
39
|
+
Rubocop:
|
40
|
+
enabled: true
|
41
|
+
rubocop_config:
|
42
|
+
inherit_from: .rubocop.yml
|
43
|
+
Layout/InitialIndentation:
|
44
|
+
Enabled: false
|
45
|
+
Layout/TrailingEmptyLines:
|
46
|
+
Enabled: false
|
47
|
+
Lint/UselessAssignment:
|
48
|
+
Enabled: false
|
49
|
+
Style/FrozenStringLiteralComment:
|
50
|
+
Enabled: false
|
51
|
+
RequireScriptNonce:
|
52
|
+
enabled: true
|
53
|
+
HardCodedString:
|
54
|
+
enabled: false
|
@@ -0,0 +1,154 @@
|
|
1
|
+
require: rubocop-performance
|
2
|
+
|
3
|
+
Performance/AncestorsInclude:
|
4
|
+
Enabled: true
|
5
|
+
|
6
|
+
Performance/ArraySemiInfiniteRangeSlice:
|
7
|
+
Enabled: false
|
8
|
+
|
9
|
+
Performance/BigDecimalWithNumericArgument:
|
10
|
+
Enabled: true
|
11
|
+
|
12
|
+
Performance/BindCall:
|
13
|
+
Enabled: true
|
14
|
+
|
15
|
+
Performance/BlockGivenWithExplicitBlock:
|
16
|
+
Enabled: false
|
17
|
+
|
18
|
+
Performance/Caller:
|
19
|
+
Enabled: true
|
20
|
+
|
21
|
+
Performance/CaseWhenSplat:
|
22
|
+
Enabled: false
|
23
|
+
|
24
|
+
Performance/Casecmp:
|
25
|
+
Enabled: true
|
26
|
+
|
27
|
+
Performance/ChainArrayAllocation:
|
28
|
+
Enabled: false
|
29
|
+
|
30
|
+
Performance/CollectionLiteralInLoop:
|
31
|
+
Enabled: true
|
32
|
+
|
33
|
+
Performance/CompareWithBlock:
|
34
|
+
Enabled: true
|
35
|
+
|
36
|
+
Performance/ConcurrentMonotonicTime:
|
37
|
+
Enabled: true
|
38
|
+
|
39
|
+
Performance/ConstantRegexp:
|
40
|
+
Enabled: true
|
41
|
+
|
42
|
+
Performance/Count:
|
43
|
+
Enabled: true
|
44
|
+
|
45
|
+
Performance/DeletePrefix:
|
46
|
+
Enabled: true
|
47
|
+
|
48
|
+
Performance/DeleteSuffix:
|
49
|
+
Enabled: true
|
50
|
+
|
51
|
+
Performance/Detect:
|
52
|
+
Enabled: true
|
53
|
+
|
54
|
+
Performance/DoubleStartEndWith:
|
55
|
+
Enabled: true
|
56
|
+
|
57
|
+
Performance/EndWith:
|
58
|
+
Enabled: true
|
59
|
+
|
60
|
+
Performance/FixedSize:
|
61
|
+
Enabled: true
|
62
|
+
|
63
|
+
Performance/FlatMap:
|
64
|
+
Enabled: true
|
65
|
+
|
66
|
+
Performance/InefficientHashSearch:
|
67
|
+
Enabled: true
|
68
|
+
|
69
|
+
Performance/IoReadlines:
|
70
|
+
Enabled: true
|
71
|
+
|
72
|
+
Performance/MapCompact:
|
73
|
+
Enabled: true
|
74
|
+
|
75
|
+
Performance/MapMethodChain:
|
76
|
+
Enabled: true
|
77
|
+
|
78
|
+
Performance/MethodObjectAsBlock:
|
79
|
+
Enabled: true
|
80
|
+
|
81
|
+
Performance/OpenStruct:
|
82
|
+
Enabled: false
|
83
|
+
|
84
|
+
Performance/RangeInclude:
|
85
|
+
Enabled: true
|
86
|
+
|
87
|
+
Performance/RedundantBlockCall:
|
88
|
+
Enabled: true
|
89
|
+
|
90
|
+
Performance/RedundantEqualityComparisonBlock:
|
91
|
+
Enabled: true
|
92
|
+
|
93
|
+
Performance/RedundantMatch:
|
94
|
+
Enabled: true
|
95
|
+
|
96
|
+
Performance/RedundantMerge:
|
97
|
+
Enabled: true
|
98
|
+
|
99
|
+
Performance/RedundantSortBlock:
|
100
|
+
Enabled: true
|
101
|
+
|
102
|
+
Performance/RedundantSplitRegexpArgument:
|
103
|
+
Enabled: true
|
104
|
+
|
105
|
+
Performance/RedundantStringChars:
|
106
|
+
Enabled: true
|
107
|
+
|
108
|
+
Performance/RegexpMatch:
|
109
|
+
Enabled: true
|
110
|
+
|
111
|
+
Performance/ReverseEach:
|
112
|
+
Enabled: true
|
113
|
+
|
114
|
+
Performance/ReverseFirst:
|
115
|
+
Enabled: true
|
116
|
+
|
117
|
+
Performance/SelectMap:
|
118
|
+
Enabled: true
|
119
|
+
|
120
|
+
Performance/Size:
|
121
|
+
Enabled: true
|
122
|
+
|
123
|
+
Performance/SortReverse:
|
124
|
+
Enabled: true
|
125
|
+
|
126
|
+
Performance/Squeeze:
|
127
|
+
Enabled: true
|
128
|
+
|
129
|
+
Performance/StartWith:
|
130
|
+
Enabled: true
|
131
|
+
|
132
|
+
Performance/StringBytesize:
|
133
|
+
Enabled: true
|
134
|
+
|
135
|
+
Performance/StringIdentifierArgument:
|
136
|
+
Enabled: true
|
137
|
+
|
138
|
+
Performance/StringInclude:
|
139
|
+
Enabled: true
|
140
|
+
|
141
|
+
Performance/StringReplacement:
|
142
|
+
Enabled: true
|
143
|
+
|
144
|
+
Performance/Sum:
|
145
|
+
Enabled: true
|
146
|
+
|
147
|
+
Performance/TimesMap:
|
148
|
+
Enabled: true
|
149
|
+
|
150
|
+
Performance/UnfreezeString:
|
151
|
+
Enabled: true
|
152
|
+
|
153
|
+
Performance/UriDefaultParser:
|
154
|
+
Enabled: true
|