Skip to content
Snippets Groups Projects
  • Kamil Mielnik's avatar
    c18c3f0d
    Backport - RFC 70 - Automate sorting imports (#39096) · c18c3f0d
    Kamil Mielnik authored
    * Include e2e directory in prettier scripts
    
    * Align ESLint & prettier paths in "lint-stage" & "scripts" in package.json
    
    * Handle ts files in e2e tests
    
    * Format "lint-prettier-pure" script the same way as "prettier"
    
    * Ignore database files in ESLint as they reference a file that is git-ignored but does exist locally
    
    * Remove duplicated eslint call
    
    * Manually fix ESLint-reported issues
    
    * Upgrade eslint-plugin-import
    
    * Configure import/order rule for consistent, predictable imports
    
    * Change "eslint-disable-next-line no-restricted-imports" into "eslint-disable-line"
    
    * Ensure imports are in a single block
    
    * Move or remove informative comments between import statements
    
    * Remove imports-grouping comments
    
    * Configure groups
    - the difference between the default setting is the presence of "internal" group
    
    * Manually fix imports order and disable "import/order" rule in files with possible circular dependencies
    
    * Move comment to the same line as import
    
    * Run "yarn eslint-fix" 5 times
    
    * Manually fix imports order in remaining files
    
    * Run "yarn prettier"
    
    * Fix import
    
    * Fix circular dependency
    
    * Fix circular dependency
    
    * ESLint
    Backport - RFC 70 - Automate sorting imports (#39096)
    Kamil Mielnik authored
    * Include e2e directory in prettier scripts
    
    * Align ESLint & prettier paths in "lint-stage" & "scripts" in package.json
    
    * Handle ts files in e2e tests
    
    * Format "lint-prettier-pure" script the same way as "prettier"
    
    * Ignore database files in ESLint as they reference a file that is git-ignored but does exist locally
    
    * Remove duplicated eslint call
    
    * Manually fix ESLint-reported issues
    
    * Upgrade eslint-plugin-import
    
    * Configure import/order rule for consistent, predictable imports
    
    * Change "eslint-disable-next-line no-restricted-imports" into "eslint-disable-line"
    
    * Ensure imports are in a single block
    
    * Move or remove informative comments between import statements
    
    * Remove imports-grouping comments
    
    * Configure groups
    - the difference between the default setting is the presence of "internal" group
    
    * Manually fix imports order and disable "import/order" rule in files with possible circular dependencies
    
    * Move comment to the same line as import
    
    * Run "yarn eslint-fix" 5 times
    
    * Manually fix imports order in remaining files
    
    * Run "yarn prettier"
    
    * Fix import
    
    * Fix circular dependency
    
    * Fix circular dependency
    
    * ESLint
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
.eslintrc 4.77 KiB
{
  "rules": {
    "strict": [2, "never"],
    "no-undef": 2,
    "no-var": 1,
    "no-unused-vars": [
      "error",
      {
        "vars": "all",
        "args": "none",
        "varsIgnorePattern": "^_",
        "ignoreRestSiblings": true
      }
    ],
    "no-empty": [1, { "allowEmptyCatch": true }],
    "no-restricted-imports": [
      "error",
      {
        "paths": [
          {
            "name": "moment",
            "message": "Moment is deprecated, please use dayjs"
          },
          {
            "name": "moment-timezone",
            "message": "Moment is deprecated, please use dayjs"
          }
        ]
      }
    ],
    "curly": [1, "all"],
    "eqeqeq": [1, "smart"],
    "import/no-default-export": 2,
    "import/no-named-as-default": 0,
    "import/no-commonjs": 1,
    "import/order": [
      "error",
      {
        "newlines-between": "always",
        "alphabetize": {
          "order": "asc",
          "orderImportKind": "asc",
          "caseInsensitive": false
        },
        "groups": ["builtin", "external", "internal", "parent", "sibling", "index"],
        "warnOnUnassignedImports": false
      }
    ],
    "no-console": [2, { "allow": ["warn", "error"] }],
    "react/no-is-mounted": 2,
    "react/prefer-es6-class": 2,
    "react/display-name": 1,
    "react/prop-types": 2,
    "react/no-did-mount-set-state": 0,
    "react/no-did-update-set-state": 0,
    "react/no-find-dom-node": 0,
    "react/no-children-prop": 2,
    "react/no-string-refs": 2,
    "react/no-unescaped-entities": 2,
    "react/jsx-no-target-blank": 2,
    "react/jsx-key": 2,
    "react/forbid-component-props": [2, { "forbid": ["sx"] }],
    "react-hooks/exhaustive-deps": [
      "warn",
      { "additionalHooks": "(useSyncedQueryString|useSafeAsyncFunction)" }
    ],
    "prefer-const": [1, { "destructuring": "all" }],
    "no-useless-escape": 0,
    "no-only-tests/no-only-tests": [
      "error",
      {
        "block": [
          "describe",
          "it",
          "context",
          "test",
          "tape",
          "fixture",
          "serial",
          "Feature",
          "Scenario",
          "Given",
          "And",
          "When",
          "Then",
          "describeWithSnowplow",
          "describeEE"
        ]
      }
    ],
    "complexity": ["error", { "max": 54 }]
  },
  "globals": {
    "before": true,
    "cy": true,
    "Cypress": true
  },
  "env": {
    "browser": true,
    "es6": true,
    "commonjs": true,
    "jest": true,
    "jest/globals": true
  },
  "parser": "babel-eslint",
  "plugins": ["react", "no-only-tests"],
  "extends": [
    "eslint:recommended",
    "plugin:react/recommended",
    "plugin:react/jsx-runtime",
    "plugin:react-hooks/recommended",
    "plugin:import/errors",
    "plugin:import/warnings",
    "plugin:import/typescript"
  ],
  "settings": {
    "import/internal-regex": "^metabase/|^metabase-lib/",
    "import/resolver": {
      "webpack": {
        "typescript": true
      }
    },
    "import/ignore": ["\\.css$"],
    "react": {
      "version": "detect"
    }
  },
  "parserOptions": {
    "ecmaFeatures": {
      "legacyDecorators": true
    }
  },
  "overrides": [
    {
      "files": ["*.js", "*.jsx", "*.ts", "*.tsx"],
      "rules": {
        "no-unconditional-metabase-links-render": "error"
      }
    },
    {
      "files": ["*.unit.spec.*", "frontend/src/metabase/admin/**/*"],
      "rules": {
        "no-unconditional-metabase-links-render": "off"
      }
    },
    {
      "extends": ["plugin:@typescript-eslint/recommended"],
      "files": ["*.ts", "*.tsx"],
      "parser": "@typescript-eslint/parser",
      "plugins": ["@typescript-eslint"],
      "rules": {
        "prefer-rest-params": "off",
        "@typescript-eslint/explicit-module-boundary-types": "off",
        "@typescript-eslint/no-inferrable-types": "off",
        "@typescript-eslint/no-explicit-any": "off",
        "@typescript-eslint/no-this-alias": "off",
        "@typescript-eslint/consistent-type-imports": "error",
        "@typescript-eslint/no-unused-vars": [
          "error",
          {
            "argsIgnorePattern": "^_",
            "varsIgnorePattern": "^_",
            "ignoreRestSiblings": true,
            "destructuredArrayIgnorePattern": "^_"
          }
        ],
        // This was introduced in 6.0.0
        "@typescript-eslint/no-unsafe-declaration-merging": "off"
      }
    },
    {
      "extends": [
        "plugin:jest/recommended",
        "plugin:jest-dom/recommended",
        "plugin:testing-library/react"
      ],
      "plugins": ["jest", "jest-dom", "testing-library"],
      "files": [
        "*.unit.spec.ts",
        "*.unit.spec.tsx",
        "*.unit.spec.js",
        "*.unit.spec.jsx"
      ],
      "rules": {
        "jest/valid-title": ["error", { "ignoreTypeOfDescribeName": true }]
      }
    }
  ]
}