项目作者: DmitryTsepelev

项目描述 :
Rubocop extension for enforcing graphql-ruby best practices
高级语言: Ruby
项目地址: git://github.com/DmitryTsepelev/rubocop-graphql.git
创建时间: 2020-05-18T14:57:41Z
项目社区:https://github.com/DmitryTsepelev/rubocop-graphql

开源协议:MIT License

下载


" class="reference-link">RuboCop::GraphQL

Rubocop extension for enforcing graphql-ruby best practices.

You can support my open–source work here.

Installation

Install the gem:

  1. gem install rubocop-graphql

If you use bundler put this in your Gemfile:

  1. gem 'rubocop-graphql', require: false

Usage

You need to tell RuboCop to load the GraphQL extension. There are three ways to do this:

RuboCop configuration file

Put this into your .rubocop.yml.

  1. plugins: rubocop-graphql

Alternatively, use the following array notation when specifying multiple extensions.

  1. plugins:
  2. - rubocop-other-extension
  3. - rubocop-graphql

Now you can run rubocop and it will automatically load the RuboCop GraphQL cops together with the standard cops.

[!NOTE]
The plugin system is supported in RuboCop 1.72+. In earlier versions, use require instead of plugins.

Command line

  1. rubocop --plugins rubocop-graphql

Rake task

  1. RuboCop::RakeTask.new do |task|
  2. task.plugins << 'rubocop-graphql'
  3. end

The Cops

All cops are located under lib/rubocop/cop/graphql, and contain examples and documentation.

In your .rubocop.yml, you may treat the GraphQL cops just like any other cop. For example:

  1. GraphQL/ResolverMethodLength:
  2. Max: 3

Credits

Initially sponsored by Evil Martians.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/DmitryTsepelev/rubocop-graphql.

License

The gem is available as open source under the terms of the MIT License.