1.0.33 • Published 2 years ago

eslint-plugin-gather v1.0.33

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

gather eslint plugin

An ESLint Plugin for custom rules at Gather 🌈

This plugin is the basis for custom rules across our repo. It allows us to create custom linting on a repo or individual module level for better coding standards and consistency across teams.

Setup

From this directory, install the dependencies for this module:

npm i

To compile the Typescript files, simply run:

npm run build

To test your ESLint engine is recognizing the custom plugin locally, navigate to a .ts or .js file and execute ESLint: Show Output Channel from your IDE (⌘cmd + ⇧shift + P in VSCode, on MacOS. Feel free to edit this to add other IDEs and OSs) ESLint should be running with no errors.

Usage

After creating your rule, ensure it is being exported from lib/index.ts under the rules object, following the existing example.

To enable custom rules across the entire repo, add your custom rule name in the main .eslintrc.json file in the following format, under the rules key:

rules: {
  ...,
  "gather/your-rule-name": "off" | "warn" | "error"
}

More on ESLint rules config

To enable a custom rule within a specific module, ensure the .eslintrc.json in that module is extending the base (which will enable access to rules from this plugin) and follow the format above.

Contributing

This is the fun part! To create a custom rule within this plugin, simply create a new file under /lib/rules/ and a new test file under /tests/lib/rules/. To test and create the logic for the rule, I highly recommend using AST Explorer. This nifty tool will allow you to run the rule defs you come up with against custom code, while also breaking down the structure of your test code.

Testing

Unfortunately, ESLint is a very opinionated framework, relying on mocha for testing rules. Fortunately, it also has an easy to use extension built on top of mocha to help test rules.

ESLint's Rule Tester provides a simple API to test your rules with.

To execute your tests, run:

npm run test
1.0.33

2 years ago

1.0.1

2 years ago

1.0.11

2 years ago

1.0.10

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.0

2 years ago

0.0.1

2 years ago