Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bulletproof ESLint config #61

Open
pdehaan opened this issue Mar 21, 2018 · 0 comments · Fixed by #73
Open

Bulletproof ESLint config #61

pdehaan opened this issue Mar 21, 2018 · 0 comments · Fixed by #73

Comments

@pdehaan
Copy link
Contributor

pdehaan commented Mar 21, 2018

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant