@thearenaproject/eslint-plugin

0.0.1 • Public • Published

@thearenaproject/eslint-plugin

Eslint rules for TheArenaProject

Installation

You'll first need to install ESLint:

npm i eslint --save-dev

Next, install @thearenaproject/eslint-plugin:

npm install @thearenaproject/eslint-plugin --save-dev

Usage

Add the eslint plugin to the plugins section of your .eslintrc.js configuration file.

{
  plugins: ["@thearenaproject/eslint-plugin"];
}

Then you can configure the rules globally or per file.

globally:

{
  rules: {
    '@thearenaproject/no-for-loops': 'error',
    '@thearenaproject/no-methods-or-properties': 'error',
  }
}

per file:

{
  overrides: [
    {
      files: ['round-00/*.ts'],
      excludedFiles: '*.test.js',
      rules: {
        '@thearenaproject/no-methods-or-properties': ['error', {
          allowed: [
            // allow ".log" only on the "console" object
            ['console', 'log'],
          ],
        }],
      },
    },
    {
      files: ['round-01/*.ts'],
      excludedFiles: '*.test.js',
      rules: {
        '@thearenaproject/no-methods-or-properties': ['error', {
          allowed: [
            ['process', 'stdout', 'write'], // allow "process.stdout.write"
            'log', // allow any ".log" in a file
          ],
        }],
      },
    },
    ...
  ],
}

Supported Rules

  • Fill in provided rules here

Creating new rules

Basics

Each rule is composed of 3 parts and only the 1st is mandatory:

  1. The rule file under ./lib/rules folder. (mandatory)
  2. The test file under ./tests/lib/rules folder.
  3. The doc file under ./docs/rules folder.

Adding new rules with the generator (no, false, faux, )

Do not use this https://github.com/eslint/generator-eslint because it doesn't generate a plugin or rule with our namespace (@thearenaproject). Even if this plugin and its rules were generated with the generator, multiple manual changes were required, so don't go this way and just read the section below ⬇️.

Adding new rules the right way (yes, true, vrai, )

For now just copy an existing rule/test/doc file, rename it and update its content.

Some reading material is here :

Package Sidebar

Install

npm i @thearenaproject/eslint-plugin

Weekly Downloads

2

Version

0.0.1

License

ISC

Unpacked Size

12 kB

Total Files

8

Last publish

Collaborators

  • thearenaproject