Skip to content

Bulletproof ESLint config #61

@pdehaan

Description

@pdehaan

Reviewing PR #55 and noticed that I'm not seeing some ESLint errors/warnings locally, despite me injecting some sketchy JS. I think our config is slightly off. Maybe due to nested configs or something else.

Once PR55 lands, I'll take a peek and see if I can figure it out. This seems to give me closer to what I expected (after deleting nested /src/.eslintrc.json config):

/* eslint-env node */

"use strict";

// All Mozilla specific rules and environments at:
// http://firefox-source-docs.mozilla.org/tools/lint/linters/eslint-plugin-mozilla.html

module.exports = {
  env: {
    es6: true,
  },
  extends: [
    "eslint:recommended",
    // list of rules at: https://dxr.mozilla.org/mozilla-central/source/tools/lint/eslint/eslint-plugin-mozilla/lib/configs/recommended.js
    "plugin:mozilla/recommended",
  ],
  overrides: [
    {
      files: "src/**",
      env: {
        browser: true,
        webextensions: true,
      },
    },
  ],
  parserOptions: {
    ecmaVersion: 8,
    sourceType: "module",
    ecmaFeatures: {
      jsx: false,
      experimentalObjectRestSpread: true,
    },
  },
  plugins: [
    "json",
    "mozilla",
  ],
  root: true,
  rules: {
    "babel/new-cap": "off",
    "mozilla/no-aArgs": "warn",
    "mozilla/balanced-listeners": "off",
    "comma-dangle": ["error", "always-multiline"],
    "eqeqeq": "error",
    "indent": ["warn", 2, { SwitchCase: 1 }],
    "no-console": "warn",
    "no-var": "error",
    "no-shadow": "error",
    "no-unused-vars": "error",
    "prefer-const": "warn",
    "prefer-spread": "error",
    "semi": ["error", "always"],
    "valid-jsdoc": "warn",
  },
};

The "valid-jsdoc" rule adds about 40 warnings, so we can probably turn that off for now, unless I can come up with a special config that ignores "Missing JSDoc @returns for function" warnings. Conversely, we could switch to eslint-plugin-jsdoc plugin which exposes more options. But in reality, all I care about now is invalid JSDocs or missing/inaccurate parameters.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions