tor-browser

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

.eslintrc.mjs (6189B)


      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      // XXX Bug 1326071 - This should be reduced down - probably to 20 or to
     51      // be removed & synced with the mozilla/recommended value.
     52      complexity: ["error", 61],
     53      "consistent-this": ["error", "use-bind"],
     54      eqeqeq: "error",
     55      "func-name-matching": "error",
     56      "guard-for-in": "error",
     57      "max-nested-callbacks": ["error", 4],
     58      "max-params": ["error", 6],
     59      "max-statements": ["error", 50],
     60      "new-cap": ["error", { newIsCap: true, capIsNew: false }],
     61      "no-alert": "error",
     62      "no-div-regex": "error",
     63      "no-duplicate-imports": "error",
     64      "no-eq-null": "error",
     65      "no-extend-native": "error",
     66      "no-extra-label": "error",
     67      "no-implicit-coercion": ["error", { allow: ["!!"] }],
     68      "no-implicit-globals": "error",
     69      "no-loop-func": "error",
     70      "no-multi-assign": "error",
     71      "no-multi-str": "error",
     72      "no-new": "error",
     73      "no-new-func": "error",
     74      "no-octal-escape": "error",
     75      "no-param-reassign": "error",
     76      "no-proto": "error",
     77      "no-prototype-builtins": "error",
     78      "no-return-assign": ["error", "except-parens"],
     79      "no-script-url": "error",
     80      "no-template-curly-in-string": "error",
     81      "no-undef-init": "error",
     82      "no-unmodified-loop-condition": "error",
     83      "no-unused-expressions": "error",
     84      "no-use-before-define": "error",
     85      "no-useless-computed-key": "error",
     86      "no-useless-constructor": "error",
     87      "no-useless-rename": "error",
     88      "no-var": "error",
     89      "no-void": ["error", { allowAsStatement: true }],
     90      "one-var": ["error", "never"],
     91      "operator-assignment": ["error", "always"],
     92      "prefer-destructuring": [
     93        "error",
     94        {
     95          AssignmentExpression: { array: true },
     96          VariableDeclarator: { array: true, object: true },
     97        },
     98      ],
     99      "prefer-numeric-literals": "error",
    100      "prefer-promise-reject-errors": "error",
    101      "prefer-rest-params": "error",
    102      "prefer-spread": "error",
    103      "prefer-template": "error",
    104      radix: ["error", "always"],
    105      "sort-vars": "error",
    106      "symbol-description": "error",
    107      "vars-on-top": "error",
    108      yoda: ["error", "never"],
    109    },
    110  },
    111  {
    112    // TODO: Bug 1773467 - Move these to .mjs or figure out a generic way
    113    // to identify these as modules.
    114    files: ["test/schemas/**/*.js", "test/unit/**/*.js"],
    115    languageOptions: {
    116      sourceType: "module",
    117    },
    118  },
    119  {
    120    // These files use fluent-dom to insert content
    121    files: [
    122      "content-src/components/TopSites/**",
    123      "content-src/components/MoreRecommendations/MoreRecommendations.jsx",
    124      "content-src/components/CollapsibleSection/CollapsibleSection.jsx",
    125      "content-src/components/DiscoveryStreamComponents/DSCard/DSCard.jsx",
    126      "content-src/components/DiscoveryStreamComponents/DSEmptyState/DSEmptyState.jsx",
    127      "content-src/components/CustomizeMenu/**",
    128      "content-src/components/DiscoveryStreamComponents/TopicSelection/TopicSelection.jsx",
    129      "content-src/components/DiscoveryStreamComponents/InterestPicker/InterestPicker.jsx",
    130      "content-src/components/DiscoveryStreamComponents/ReportContent/ReportContent.jsx",
    131      "content-src/components/WallpaperCategories/WallpaperCategories.jsx",
    132    ],
    133    rules: {
    134      "jsx-a11y/anchor-has-content": "off",
    135      "jsx-a11y/heading-has-content": "off",
    136      "jsx-a11y/label-has-associated-control": "off",
    137      "jsx-a11y/no-onchange": "off",
    138    },
    139  },
    140  {
    141    files: [
    142      "bin/**",
    143      "content-src/**",
    144      "loaders/**",
    145      "tools/**",
    146      "test/unit/**",
    147    ],
    148    languageOptions: { globals: globals.node },
    149  },
    150  {
    151    // Use a configuration that's appropriate for modules, workers and
    152    // non-production files.
    153    files: ["bin/**", "lib/cache.worker.js", "test/**"],
    154    rules: {
    155      "no-implicit-globals": "off",
    156    },
    157  },
    158  {
    159    files: ["content-src/**", "test/unit/**"],
    160    rules: {
    161      // Disallow commonjs in these directories.
    162      "import/no-commonjs": 2,
    163    },
    164  },
    165  {
    166    // These tests simulate the browser environment.
    167    files: "test/unit/**",
    168    languageOptions: {
    169      globals: {
    170        ...globals.browser,
    171        ...globals.mocha,
    172        assert: "readonly",
    173        chai: "readonly",
    174        sinon: "readonly",
    175      },
    176    },
    177  },
    178  {
    179    files: "test/**",
    180    rules: {
    181      "func-name-matching": 0,
    182      "lines-between-class-members": 0,
    183    },
    184  },
    185 ];