Introduce an ESLint plugin to standardize Beanbag JavaScript development.

Review Request #12759 — Created Jan. 2, 2023 and submitted — Latest diff uploaded

Information

beanbag-eslint-plugin
main

Reviewers

This introduces a new plugin for ESLint that provides standardized,
documented configurations that ensure code consistency in ES5, ES6, and
TypeScript code.

These build upon the recommended sets for ESLint and TypeScript,
tweaking them to codify the rules we aim for when writing code.

To use this, our codebases will load in the @beanbag plugin
(corresponding to @beanbag/eslint-plugin in NPM) and extend the
plugin:@beanbag/recommended configuration. This will add some rules
that apply ES5-safe rules to *.js files, ES6-safe rules to *.es6.js
files, and TypeScript rules to *.ts files.

We can also pull in "environments" for Backbone, Django, Djblets,
jasmine-suites, and Review Board to declare certain variables as known
globals with read-only behavior, for codebases consuming those.

There's a special ruleset included for test suites, where we enable
Jasmine support, pull in a plugin to check for some common issues, and
configure it appropriately for our needs. This is enabled by default for
*Tests.{js,es6.js,ts} files.

A lot of this will still need tweaking as we go. Some rules were good in
theory but bad in practice, and others (especially for TypeScript) will
need further changes made as we continue development. There's one rule
that is currently disabled, but left in with the hope that we can later
get it working right.

Going forward, we'll be able to pull in additional rules or even craft
custom ones to ensure consistency in our code, all without needing to
configure things on a repository-by-repository basis.

Tested many of the rules out in the ESLint Playground at
https://eslint.org/play/.

Tested these in the Djblets tree. Found many errors (some minor, some
that need to be fixed), and used the results to tweak the rules here.

Ran the plugin's lint rules on itself.

Commits

Files