syntax_tree-no_alignment 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/.rubocop.yml +21 -0
- data/LICENSE.txt +21 -0
- data/README.md +61 -0
- data/Rakefile +30 -0
- data/lib/syntax_tree/no_alignment/version.rb +7 -0
- data/lib/syntax_tree/no_alignment.rb +34 -0
- metadata +67 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: ccb7bc65e859b8f3b9af38319dd3f72c844e2032e44f63c3139e36fdcb0803d6
|
4
|
+
data.tar.gz: 942fb4860eda08e30f7319e908a6f2d5413ccb5c0d3c5591fbc24907992ec71f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 45bd358fdb78066412eac2f4e12e8de09da191cc3796342645759d40fda809df44a45b41a90bac50f80b3818b894289fe5ffd272126c10ba5f0f72e59ad3f87e
|
7
|
+
data.tar.gz: f5f5c0059f2848557e95f792e21577518b979f68cc17c8ffc0366ac1531e5aad904f250fbd4219ea72aef6297c98c3276f6dc6266953af3757d4164dbb314005
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
inherit_gem:
|
2
|
+
syntax_tree: config/rubocop.yml
|
3
|
+
|
4
|
+
AllCops:
|
5
|
+
DisplayCopNames: true
|
6
|
+
DisplayStyleGuide: true
|
7
|
+
NewCops: enable
|
8
|
+
SuggestExtensions: false
|
9
|
+
TargetRubyVersion: 2.7
|
10
|
+
|
11
|
+
Metrics:
|
12
|
+
Enabled: false
|
13
|
+
|
14
|
+
Style/Documentation:
|
15
|
+
Enabled: false
|
16
|
+
|
17
|
+
Naming/MethodName:
|
18
|
+
Enabled: false
|
19
|
+
|
20
|
+
Naming/MethodParameterName:
|
21
|
+
Enabled: false
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2024 Tomasz Szczęśniak-Szlagowski
|
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
|
13
|
+
all 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
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
# SyntaxTree plugin: no_alignment
|
2
|
+
|
3
|
+
SyntaxTree gem can format your Ruby code and I think it's pretty good at that!
|
4
|
+
Despite not having many configuration options, it does have a plugin system
|
5
|
+
for people who want to change a thing or two in its behavior.
|
6
|
+
|
7
|
+
There are 2 common ways to [align arguments in a multiline method call](rubocop_rule):
|
8
|
+
|
9
|
+
- align them to the first argument
|
10
|
+
- use fixed indentation
|
11
|
+
|
12
|
+
SyntaxTree uses both, depending on whether you use parentheses or not:
|
13
|
+
|
14
|
+
```ruby
|
15
|
+
with_parens(
|
16
|
+
"lorem ipsum",
|
17
|
+
"dolor sit amet",
|
18
|
+
"consectetur adipiscing elit"
|
19
|
+
)
|
20
|
+
|
21
|
+
without_parens "lorem ipsum",
|
22
|
+
"dolor sit amet",
|
23
|
+
"consectetur adipiscing elit"
|
24
|
+
```
|
25
|
+
|
26
|
+
Parens-less syntax is often used for DSLs, which is probably why it gets this special treatment.
|
27
|
+
|
28
|
+
This plugin will remove this exception and make all indentation fixed:
|
29
|
+
|
30
|
+
```ruby
|
31
|
+
with_this_plugin "lorem ipsum",
|
32
|
+
"dolor sit amet",
|
33
|
+
"consectetur adipiscing elit"
|
34
|
+
```
|
35
|
+
|
36
|
+
[rubocop_rule]: https://docs.rubocop.org/rubocop/cops_layout.html#layoutargumentalignment
|
37
|
+
|
38
|
+
## Installation
|
39
|
+
|
40
|
+
Install the gem and add to the application's Gemfile by executing:
|
41
|
+
|
42
|
+
$ bundle add syntax_tree-no_alignment
|
43
|
+
|
44
|
+
If bundler is not being used to manage dependencies, install the gem by executing:
|
45
|
+
|
46
|
+
$ gem install syntax_tree-no_alignment
|
47
|
+
|
48
|
+
## Usage
|
49
|
+
|
50
|
+
Example:
|
51
|
+
```
|
52
|
+
stree write --plugins=no_alignment lib/**/*.rb
|
53
|
+
```
|
54
|
+
|
55
|
+
## Contributing
|
56
|
+
|
57
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/spect88/syntax_tree-no_alignment.
|
58
|
+
|
59
|
+
## License
|
60
|
+
|
61
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "bundler/gem_tasks"
|
4
|
+
|
5
|
+
require "rake/testtask"
|
6
|
+
Rake::TestTask.new do |t|
|
7
|
+
t.libs << "test"
|
8
|
+
t.test_files = FileList["test/**/*_test.rb"]
|
9
|
+
t.verbose = true
|
10
|
+
end
|
11
|
+
|
12
|
+
require "syntax_tree/rake_tasks"
|
13
|
+
stree_config =
|
14
|
+
proc do |t|
|
15
|
+
t.source_files =
|
16
|
+
FileList[%w[Gemfile Rakefile lib/**/*.rb test/**/*.rb *.gemspec]]
|
17
|
+
end
|
18
|
+
SyntaxTree::Rake::CheckTask.new(&stree_config)
|
19
|
+
SyntaxTree::Rake::WriteTask.new(&stree_config)
|
20
|
+
|
21
|
+
require "rubocop/rake_task"
|
22
|
+
RuboCop::RakeTask.new
|
23
|
+
|
24
|
+
desc "Run all code checks"
|
25
|
+
task check: %i[rubocop stree:check test]
|
26
|
+
|
27
|
+
desc "Run all automated fixes"
|
28
|
+
task fix: %i[stree:write rubocop:autocorrect_all]
|
29
|
+
|
30
|
+
task default: :check
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require_relative "no_alignment/version"
|
3
|
+
|
4
|
+
module SyntaxTree
|
5
|
+
module NoAlignment
|
6
|
+
module CommandPatch
|
7
|
+
def align(q, node, &block)
|
8
|
+
q.text(" ")
|
9
|
+
|
10
|
+
if node.arguments.is_a?(Args) && node.arguments.parts.size == 1 &&
|
11
|
+
skip_indent?(arguments.parts.first)
|
12
|
+
block.call
|
13
|
+
return
|
14
|
+
end
|
15
|
+
|
16
|
+
q.indent(&block)
|
17
|
+
end
|
18
|
+
|
19
|
+
def skip_indent?(argument)
|
20
|
+
(argument.is_a?(BareAssocHash) && argument.assocs.size == 1) ||
|
21
|
+
argument.is_a?(CallNode) || AssignFormatting.skip_indent?(argument)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
module CommandCallPatch
|
26
|
+
def argument_alignment(_q, _doc)
|
27
|
+
%w[to not_to to_not].include?(message.value) ? 0 : 2
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
SyntaxTree::Command.prepend(SyntaxTree::NoAlignment::CommandPatch)
|
34
|
+
SyntaxTree::CommandCall.prepend(SyntaxTree::NoAlignment::CommandCallPatch)
|
metadata
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: syntax_tree-no_alignment
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Tomasz Szczęśniak-Szlagowski
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2024-07-13 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: syntax_tree
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
description: Syntax Tree aligns arguments of parens-less method calls. This plugin
|
28
|
+
disables that behavior.
|
29
|
+
email:
|
30
|
+
- spect88@gmail.com
|
31
|
+
executables: []
|
32
|
+
extensions: []
|
33
|
+
extra_rdoc_files: []
|
34
|
+
files:
|
35
|
+
- ".rubocop.yml"
|
36
|
+
- LICENSE.txt
|
37
|
+
- README.md
|
38
|
+
- Rakefile
|
39
|
+
- lib/syntax_tree/no_alignment.rb
|
40
|
+
- lib/syntax_tree/no_alignment/version.rb
|
41
|
+
homepage: https://github.com/spect88/syntax_tree-no_alignment
|
42
|
+
licenses:
|
43
|
+
- MIT
|
44
|
+
metadata:
|
45
|
+
homepage_uri: https://github.com/spect88/syntax_tree-no_alignment
|
46
|
+
source_code_uri: https://github.com/spect88/syntax_tree-no_alignment
|
47
|
+
rubygems_mfa_required: 'true'
|
48
|
+
post_install_message:
|
49
|
+
rdoc_options: []
|
50
|
+
require_paths:
|
51
|
+
- lib
|
52
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
53
|
+
requirements:
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: 2.7.0
|
57
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
requirements: []
|
63
|
+
rubygems_version: 3.3.7
|
64
|
+
signing_key:
|
65
|
+
specification_version: 4
|
66
|
+
summary: A Syntax Tree plugin disabling argument alignment
|
67
|
+
test_files: []
|