Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

125
Views
Can I write my own custom rule in eslint config?

Is it possible to write custom rule in eslint config? My case is based on type 'any'. In eslint doc is rule "@typescript-eslint/no-explicit-any", but it's too strong for me. I want to block assignment like this:

const dontknow: any = ''; const name: string = dontknow;

Is it possible to block this case?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You can use the no-unsafe-assignment rule instead of the no-explicit-any rule.

This rule disallows assigning any to a variable, and assigning any[] to an array destructuring. This rule also compares the assigned type to the variable's type to ensure you don't assign an unsafe any in a generic position to a receiver that's expecting a specific type. For example, it will error if you assign Set to a variable declared as Set.

.eslintrc

  {
        "root": true,
        "parser": "@typescript-eslint/parser",
        "plugins": [
          "@typescript-eslint"
        ],
        "extends": [
          "eslint:recommended",
          "plugin:@typescript-eslint/eslint-recommended",
          "plugin:@typescript-eslint/recommended"
        ],
        "rules": { 
            "@typescript-eslint/no-unsafe-assignment": 2
        },
        "overrides": [
            {
              "files": ["*.ts", "*.tsx"], // Your TypeScript files extension
              "parserOptions": {
                "project": ["./tsconfig.json"], // Specify it only for TypeScript files
              },
            },
          ],
      }
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!