tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

.eslintrc.mjs (4989B)


      1 /* This Source Code Form is subject to the terms of the Mozilla Public
      2 * License, v. 2.0. If a copy of the MPL was not distributed with this
      3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      4 
      5 import importPlugin from "eslint-plugin-import";
      6 import jsxA11y from "eslint-plugin-jsx-a11y";
      7 import react from "eslint-plugin-react";
      8 import globals from "globals";
      9 
     10 export default [
     11  {
     12    ...jsxA11y.flatConfigs.recommended,
     13    // When adding items to this file please check for effects on sub-directories.
     14    plugins: { import: importPlugin, react, "jsx-a11y": jsxA11y },
     15    settings: {
     16      react: {
     17        version: "16.2.0",
     18      },
     19    },
     20    rules: {
     21      "react/jsx-boolean-value": ["error", "always"],
     22      "react/jsx-key": "error",
     23      "react/jsx-no-bind": [
     24        "error",
     25        { allowArrowFunctions: true, allowFunctions: true },
     26      ],
     27      "react/jsx-no-comment-textnodes": "error",
     28      "react/jsx-no-duplicate-props": "error",
     29      "react/jsx-no-target-blank": "error",
     30      "react/jsx-no-undef": "error",
     31      "react/jsx-pascal-case": "error",
     32      "react/jsx-uses-react": "error",
     33      "react/jsx-uses-vars": "error",
     34      "react/no-access-state-in-setstate": "error",
     35      "react/no-danger": "error",
     36      "react/no-deprecated": "error",
     37      "react/no-did-mount-set-state": "error",
     38      "react/no-did-update-set-state": "error",
     39      "react/no-direct-mutation-state": "error",
     40      "react/no-is-mounted": "error",
     41      "react/no-unknown-property": "error",
     42      "react/require-render-return": "error",
     43 
     44      "accessor-pairs": [
     45        "error",
     46        { setWithoutGet: true, getWithoutSet: false },
     47      ],
     48      "array-callback-return": "error",
     49      "block-scoped-var": "error",
     50      "consistent-this": ["error", "use-bind"],
     51      eqeqeq: "error",
     52      "func-name-matching": "error",
     53      "guard-for-in": "error",
     54      "max-nested-callbacks": ["error", 4],
     55      "max-params": ["error", 6],
     56      "max-statements": ["error", 50],
     57      "new-cap": ["error", { newIsCap: true, capIsNew: false }],
     58      "no-alert": "error",
     59      "no-div-regex": "error",
     60      "no-duplicate-imports": "error",
     61      "no-eq-null": "error",
     62      "no-extend-native": "error",
     63      "no-extra-label": "error",
     64      "no-implicit-coercion": ["error", { allow: ["!!"] }],
     65      "no-implicit-globals": "error",
     66      "no-loop-func": "error",
     67      "no-multi-assign": "error",
     68      "no-multi-str": "error",
     69      "no-new": "error",
     70      "no-new-func": "error",
     71      "no-octal-escape": "error",
     72      "no-param-reassign": "error",
     73      "no-proto": "error",
     74      "no-prototype-builtins": "error",
     75      "no-return-assign": ["error", "except-parens"],
     76      "no-script-url": "error",
     77      "no-template-curly-in-string": "error",
     78      "no-undef-init": "error",
     79      "no-unmodified-loop-condition": "error",
     80      "no-unused-expressions": "error",
     81      "no-use-before-define": "error",
     82      "no-useless-computed-key": "error",
     83      "no-useless-constructor": "error",
     84      "no-useless-rename": "error",
     85      "no-var": "error",
     86      "no-void": ["error", { allowAsStatement: true }],
     87      "one-var": ["error", "never"],
     88      "operator-assignment": ["error", "always"],
     89      "prefer-destructuring": [
     90        "error",
     91        {
     92          AssignmentExpression: { array: true },
     93          VariableDeclarator: { array: true, object: true },
     94        },
     95      ],
     96      "prefer-numeric-literals": "error",
     97      "prefer-promise-reject-errors": "error",
     98      "prefer-rest-params": "error",
     99      "prefer-spread": "error",
    100      "prefer-template": "error",
    101      radix: ["error", "always"],
    102      "sort-vars": "error",
    103      "symbol-description": "error",
    104      "vars-on-top": "error",
    105      yoda: ["error", "never"],
    106    },
    107  },
    108  {
    109    // TODO: Bug 1773467 - Move these to .mjs or figure out a generic way
    110    // to identify these as modules.
    111    files: ["tests/unit/*.js"],
    112    languageOptions: {
    113      sourceType: "module",
    114    },
    115  },
    116  {
    117    files: ["bin/**", "content-src/**", "tests/unit/**"],
    118    languageOptions: { globals: globals.node },
    119  },
    120  {
    121    // Use a configuration that's appropriate for modules, workers and
    122    // non-production files.
    123    files: [
    124      "bin/*.js",
    125      "content-src/schemas/extract-test-corpus.js",
    126      "tests/**",
    127      "modules/**",
    128    ],
    129    rules: {
    130      "no-implicit-globals": "off",
    131    },
    132  },
    133  {
    134    files: ["content-src/**", "tests/unit/**"],
    135    rules: {
    136      // Disallow commonjs in these directories.
    137      "import/no-commonjs": 2,
    138    },
    139  },
    140  {
    141    // These tests simulate the browser environment.
    142    files: "tests/unit/**",
    143    languageOptions: {
    144      globals: {
    145        ...globals.browser,
    146        ...globals.mocha,
    147        assert: "readonly",
    148        expect: "readonly",
    149        chai: "readonly",
    150        sinon: "readonly",
    151      },
    152    },
    153  },
    154  {
    155    files: "tests/**",
    156    rules: {
    157      "func-name-matching": 0,
    158      "lines-between-class-members": 0,
    159    },
    160  },
    161 ];