rubocop-oneoff_codemod 0.0.7 → 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 +4 -4
- data/README.md +49 -3
- data/lib/rubocop/oneoff_codemod/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6e7fa1b4623ac56f647fc7e9d77ddac8e1b8b678fac0d944395475abae0ed7dc
|
4
|
+
data.tar.gz: 972a11490e731f8d5919640822c66ba7fd8bf3fd20141ce53d185a216ceb578b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c110b18f1c259d1083c17e1c9539c9f453317691d2720f1a18d46f8add0dc8e342ce91cd42ff9c927cd82bba9ec459ca285039f4955698b11130f2d46500d1f8
|
7
|
+
data.tar.gz: b9b940027490fcd74fff864f8a704be2df4998363b94e656f77e8e0eb427aa5bb05e6c983d30684513f79032b48394f8affc60ca11cb1f811f857451fcd8aba9
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# RuboCop::OneoffCodemod
|
2
2
|
|
3
|
-
A RuboCop plugin implementing comment-as-command for one-off codemod, inspired by eslint-plugin-command.
|
3
|
+
A RuboCop plugin implementing comment-as-command for one-off codemod, inspired by [eslint-plugin-command](https://eslint-plugin-command.antfu.me/).
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
@@ -16,6 +16,52 @@ If bundler is not being used to manage dependencies, install the gem by executin
|
|
16
16
|
gem install rubocop-oneoff_codemod
|
17
17
|
```
|
18
18
|
|
19
|
+
## Loading the plugin
|
20
|
+
|
21
|
+
To use this plugin, tell RuboCop to load it by adding the following to your `.rubocop.yml`:
|
22
|
+
|
23
|
+
```yml
|
24
|
+
plugins: rubocop-oneoff_codemod
|
25
|
+
```
|
26
|
+
|
27
|
+
If you're using multiple plugins, use the array notation:
|
28
|
+
|
29
|
+
```yml
|
30
|
+
plugins:
|
31
|
+
- rubocop-other-plugin
|
32
|
+
- rubocop-oneoff_codemod
|
33
|
+
```
|
34
|
+
|
35
|
+
RuboCop will now automatically load this plugin when you run it.
|
36
|
+
|
37
|
+
> [!NOTE]
|
38
|
+
> The plugin system is supported in RuboCop 1.72+.
|
39
|
+
|
40
|
+
## Usage
|
41
|
+
|
42
|
+
The `OneoffCodemod` cop is a special kind of RuboCop plugin. By default, does nothing.
|
43
|
+
Rather than checking code quality, it acts as a micro-codemod tool that is triggered by special comments.
|
44
|
+
It reuses RuboCop’s infrastructure to perform transformations on demand.
|
45
|
+
|
46
|
+
For example, the comment `# @keep-unique` transforms an array by removing duplicate elements:
|
47
|
+
|
48
|
+
```rb
|
49
|
+
# @keep-unique
|
50
|
+
ary = [1, 2, 3, 2, 4]
|
51
|
+
```
|
52
|
+
|
53
|
+
After running `rubocop -a` or saving the file in your editor, the array will be transformed and the comment will be removed:
|
54
|
+
|
55
|
+
```rb
|
56
|
+
#
|
57
|
+
ary = [1, 2, 3, 4]
|
58
|
+
```
|
59
|
+
|
60
|
+
## Available Commands
|
61
|
+
|
62
|
+
- `# @keep-unique` - Keep array items unique, removing duplicates.
|
63
|
+
- `# @rbs-prototype` - Run rbs prototype and generates boilerplate signature declaration.
|
64
|
+
|
19
65
|
## Development
|
20
66
|
|
21
67
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
@@ -24,7 +70,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
24
70
|
|
25
71
|
## Contributing
|
26
72
|
|
27
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
73
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/kozy4324/rubocop-oneoff_codemod. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/rubocop-oneoff_codemod/blob/master/CODE_OF_CONDUCT.md).
|
28
74
|
|
29
75
|
## License
|
30
76
|
|
@@ -32,4 +78,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
|
|
32
78
|
|
33
79
|
## Code of Conduct
|
34
80
|
|
35
|
-
Everyone interacting in the RuboCop::OneoffCodemod project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/
|
81
|
+
Everyone interacting in the RuboCop::OneoffCodemod project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/kozy4324/rubocop-oneoff_codemod/blob/master/CODE_OF_CONDUCT.md).
|