streetmix/streetmix

View on GitHub
.eslintrc

Summary

Maintainability
Test Coverage
{
  "parser": "@babel/eslint-parser",
  "parserOptions": {
    "ecmaVersion": 6,
    "sourceType": "module",
    "ecmaFeatures": {
      "jsx": true
    },
    "babelOptions": {
      "plugins": [
        // Import attributes are required to import JSON
        // Deprecated syntax must be used to support Node < 20.10.0
        // We cannot switch to "with" syntax until "assert" is fully removed
        [
          "@babel/plugin-syntax-import-attributes",
          { "deprecatedAssertSyntax": true }
        ]
      ]
    }
  },
  "env": {
    "browser": true,
    "cypress/globals": true,
    "node": true,
    "es6": true,
    "mocha": true
  },
  "settings": {
    "react": {
      "version": "detect"
    }
  },
  "plugins": ["react", "cypress", "react-hooks"],
  "extends": [
    "eslint:recommended",
    "plugin:react/recommended",
    "standard",
    "standard-jsx",
    "standard-react",
    "plugin:import/errors",
    "plugin:import/warnings"
  ],
  "rules": {
    "import/no-unresolved": 0,
    "import/order": ["warn", {
      "groups": ["builtin", "external", "internal", "parent", "sibling", "index", "object", "type"],
      "pathGroups": [
        {
          "pattern": "~/**",
          "group": "internal"
        }
      ]
    }],
    "jsx-quotes": ["error", "prefer-double"],
    "react/jsx-boolean-value": ["error", "always"],
    "react/jsx-no-bind": 0,
    "no-restricted-globals": [
      "error",
      {
        "name": "isNaN",
        "message": "Use Number.isNaN() instead of the global isNan()."
      },
      {
        "name": "isFinite",
        "message": "Use Number.isFinite() instead of the global isFinite()."
      },
      {
        "name": "parseInt",
        "message": "Use Number.parseInt() instead of the global parseInt()."
      },
      {
        "name": "parseFloat",
        "message": "Use Number.parseFloat() instead of the global parseFloat()."
      }
    ],
    "react-hooks/rules-of-hooks": "error",
    "react-hooks/exhaustive-deps": "warn"
  },
  "overrides": [
    // Only run TypeScript linting on TypeScript files, otherwise it'd
    // report TypeScript errors on regular JavaScript files (bad!)
    {
      "files": ["**/*.ts", "**/*.tsx"],
      "parser": "@typescript-eslint/parser",
      "plugins": ["@typescript-eslint", "import"],
      "extends": [
        "plugin:@typescript-eslint/recommended",
        "plugin:import/typescript",
        "standard-with-typescript"
      ],
      "settings": {
        "import/resolver": {
          "typescript": true,
          "node": true
        }
      },
      // TODO: set up project-specific eslint "flat config" (eslint v9) inside
      // of client package
      "parserOptions": {
        "tsconfigRootDir": "client",
        "project": "./tsconfig.json"
      },
      "rules": {
        // This was added as an error in eslint-config-standard-with-typescript
        // v42.0.0 and is much too strict while parts of the app are still in JS
        // Warnings indicate opportunities for typescript porting
        "@typescript-eslint/no-unsafe-argument": "warn",
        "@typescript-eslint/strict-boolean-expressions": [
          2,
          {
            "allowString": true
          }
        ],
        // Turns off an error that was only reporting for useIntl
        // see https://github.com/formatjs/formatjs/issues/4133
        "@typescript-eslint/unbound-method": "off"
      }
    }
  ],
  "root": true
}