Skip to content

Mavenlink RuboCop and ESLint configuration

Notifications You must be signed in to change notification settings

mavenlink/mavenlint

Repository files navigation

Mavenlint

Mavenlink Ruby and Javascript linting rules.

npm version Gem Build Status

  1. Usage
  2. Developing

Usage

How to use the Mavenlint lint rules for Javascript or Ruby projects.

Javascript

Install one of the Mavenlint ESLint configurations as a dev dependency.

yarn add eslint-config-mavenlint --dev

Then, extend mavenlint in your .eslintrc file.

{
  "extends": "mavenlint"
}

For React linting use eslint-config-mavenlint-react and mavenlint-react instead.

Ruby

Add Mavenlint to your Gemfile. For a Rails project, it may make sense to add it to the development group.

gem "mavenlint", git: "https://github.com/mavenlink/mavenlint"

Then, inherit from this gem in your .rubocop.yml.

inherit_gem:
  mavenlint: rubocop.yml

If you also want the custom lint rules, require the gem again from your .rubocop.yml:

require:
  - mavenlint

Developing

ESLint Packages

For our NPM packages, we use yarn workspaces to publish multiple packages.

Install dependencies for all packages by running the following from the root of the project:

yarn install

Run the tests with:

yarn test

To publish changed packages, first login:

npm login

To publish alpha versions for testing in other applications, run:

yarn publish-canary

To publish release versions, run:

yarn publish-packages

You will be prompted to select new versions for each changed package. Commits and tags will be generated for each and their version numbers will be updated.

Ruby Gem

Install dependencies by running the following from the root of the project:

bundle install

Run the tests with:

rspec

Run your linter against BigMaven:

cd ~/workspace/mavenlink
bundle exec rubocop --require ~/workspace/mavenlint/lib/rubocop/cop/mavenlint/bigint_for_migration_keys.rb

(DEPRECATED, we install from GitHub now) To publish a new version, first update the mavenlint.gemspec file with the new version. And then build and publish the gem with:

gem build mavenlint.gemspec
gem push mavenlint-<VERSION NUMBER>.gem

Note that <VERSION NUMBER> above has to be replaced with the actual version number that you're releasing.