0.0.1 • Published 3 years ago
@thearenaproject/eslint-plugin-julius v0.0.1
@thearenaproject/eslint-plugin-julius
Eslint rules for TheArenaProject
Installation
You'll first need to install ESLint:
npm i eslint --save-devNext, install @thearenaproject/eslint-plugin-julius:
npm install @thearenaproject/eslint-plugin-julius --save-devUsage
Add the eslint plugin to the plugins section of your .eslintrc.js configuration file.
{
  plugins: ["@thearenaproject/eslint-plugin-julius"];
}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:
- The rule file under ./lib/rulesfolder. (mandatory)
- The test file under ./tests/lib/rulesfolder.
- The doc file under ./docs/rulesfolder.
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 :
- https://eslint.org/docs/latest/developer-guide/working-with-rules
- https://eslint.org/docs/latest/developer-guide use the search to find existing eslint rules and get inspired :P
- https://insideops.wordpress.com/2015/12/08/creating-custom-rules-for-eslint/
- https://astexplorer.net (don't forget to switch to Javascript from the top menu)
- ... and many other pages, but I already closed their browser tabs, so you'll have to google it, sorry 🫠