monkeytype/packages/eslint-config/index.js
Jack ceedf8ace2
refactor: enable no-unsafe-call rule (@miodec) (#5883)
### Description

<!-- Please describe the change(s) made in your PR -->

### Checks

- [ ] Adding quotes?
- [ ] Make sure to include translations for the quotes in the
description (or another comment) so we can verify their content.
- [ ] Adding a language or a theme?
- [ ] If is a language, did you edit `_list.json`, `_groups.json` and
add `languages.json`?
  - [ ] If is a theme, did you add the theme.css?
- Also please add a screenshot of the theme, it would be extra awesome
if you do so!
- [ ] Check if any open issues are related to this PR; if so, be sure to
tag them below.
- [ ] Make sure the PR title follows the Conventional Commits standard.
(https://www.conventionalcommits.org for more info)
- [ ] Make sure to include your GitHub username prefixed with @ inside
parentheses at the end of the PR title.

<!-- label(optional scope): pull request title (@your_github_username)
-->

<!-- I know I know they seem boring but please do them, they help us and
you will find out it also helps you.-->

Closes #

<!-- the issue(s) your PR resolves if any (delete if that is not the
case) -->
<!-- please also reference any issues and or PRs related to your pull
request -->
<!-- Also remove it if you are not following any issues. -->

<!-- pro tip: you can mention an issue, PR, or discussion on GitHub by
referencing its hash number e.g:
[#1234](https://github.com/monkeytypegame/monkeytype/pull/1234) -->

<!-- pro tip: you can press . (dot or period) in the code tab of any
GitHub repo to get access to GitHub's VS Code web editor Enjoy! :) -->
2024-09-13 15:18:00 +02:00

151 lines
4.5 KiB
JavaScript

/** @type {import("eslint").Linter.Config} */
module.exports = {
env: {
node: true,
},
parser: "@typescript-eslint/parser",
ignorePatterns: [
// Ignore dotfiles
".*.js",
"node_modules/",
"dist/",
"build/",
],
extends: [
"eslint:recommended",
"plugin:json/recommended",
"plugin:import/recommended",
"plugin:import/typescript",
"prettier",
],
plugins: ["json", "require-path-exists", "@typescript-eslint"],
parserOptions: {
sourceType: "module",
ecmaVersion: 2020,
},
rules: {
"json/*": ["error"],
indent: ["off"],
"no-empty": ["error", { allowEmptyCatch: true }],
"no-var": 2,
"no-duplicate-imports": ["error"],
"no-constant-condition": ["error"],
"no-constant-binary-expression": "error",
"no-unused-vars": [
"error",
{
argsIgnorePattern: "^(_|e|event)",
caughtErrorsIgnorePattern: "^(_|e|error)",
varsIgnorePattern: "^_",
},
],
"import/no-duplicates": "off",
"import/no-unresolved": [
"error",
{
ignore: ["^@monkeytype/"],
},
],
"no-mixed-operators": [
"error",
{
groups: [["+", "??"]],
},
],
},
overrides: [
{
// enable the rule specifically for TypeScript files
files: ["*.ts", "*.tsx"],
extends: [
"plugin:import/errors",
"plugin:import/warnings",
"plugin:import/typescript",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/strict",
"plugin:@typescript-eslint/strict-type-checked",
],
rules: {
//strict type checked
"@typescript-eslint/require-await": "off",
"@typescript-eslint/unbound-method": "off",
"@typescript-eslint/await-thenable": "off",
"@typescript-eslint/no-unnecessary-template-expression": "off",
"@typescript-eslint/prefer-promise-reject-errors": "off",
"@typescript-eslint/no-this-alias": "off",
"@typescript-eslint/no-unnecessary-type-arguments": "off",
"@typescript-eslint/restrict-template-expressions": "off",
"@typescript-eslint/no-redundant-type-constituents": "off",
"@typescript-eslint/restrict-plus-operands": "off",
// TODO: enable at some point
"@typescript-eslint/no-unsafe-member-access": "off", //~105
//
"@typescript-eslint/no-unsafe-call": "error",
"@typescript-eslint/no-unsafe-argument": "error",
"@typescript-eslint/no-unsafe-assignment": "error",
"@typescript-eslint/no-unnecessary-type-assertion": "error",
"@typescript-eslint/no-confusing-void-expression": [
"error",
{ ignoreArrowShorthand: true },
],
"@typescript-eslint/explicit-function-return-type": [
"error",
{
allowExpressions: true,
},
],
"@typescript-eslint/ban-ts-comment": "off",
"@typescript-eslint/no-empty-function": "error",
"@typescript-eslint/no-unused-vars": [
"error",
{
argsIgnorePattern: "^(_|e|event)",
caughtErrorsIgnorePattern: "^(_|e|error)",
varsIgnorePattern: "^_",
},
],
"@typescript-eslint/no-unused-expressions": [
"error",
{
allowTernary: true,
},
],
"@typescript-eslint/no-var-requires": "error",
"@typescript-eslint/no-this-alias": "off",
"@typescript-eslint/no-misused-promises": [
"error",
{
checksVoidReturn: false,
},
],
"@typescript-eslint/promise-function-async": "error",
"@typescript-eslint/no-floating-promises": "error",
"@typescript-eslint/strict-boolean-expressions": [
"error",
{ allowNullableBoolean: true, allowNullableNumber: true },
],
"@typescript-eslint/non-nullable-type-assertion-style": "off",
"@typescript-eslint/no-unnecessary-condition": "off",
"@typescript-eslint/consistent-type-definitions": ["error", "type"],
"@typescript-eslint/no-invalid-void-type": "off",
"import/namespace": "off",
},
settings: {
"import/resolver": {
typescript: {
project: "./tsconfig.json",
},
},
},
parserOptions: {
ecmaVersion: 12,
sourceType: "module",
project: "**/tsconfig.json",
},
},
],
};