Is there a way to restrict the use of `any` exclusively to the tests folder when working with biome

I am currently working on a TypeScript repository that has both a 'src' and 'tests' folder. My goal is to set up biome for this project. Specifically, I want to enforce strict linting rules in the 'src' folder, but allow the usage of 'any' in the 'tests' folder.

I attempted to configure 'biome.json' to permit the 'lint/suspicious/noExplicitAny' rule, but unfortunately it was also applied to the 'src' folder where I need stricter enforcement.

Is there a method to accomplish what I'm looking to achieve?

Answer №1

I stumbled upon a reference in the documentation that provided instructions on how to exempt specific rules for certain paths

By configuring my biome.json file as shown below, I was able to resolve my issue.

{
    "$schema": "https://biomejs.dev/schemas/1.9.1/schema.json",
    "vcs": {
        "enabled": false,
        "clientKind": "git",
        "useIgnoreFile": false
    },
    "files": {
        "ignoreUnknown": false,
        "ignore": []
    },
    "formatter": {
        "enabled": true,
        "indentStyle": "tab"
    },
    "organizeImports": {
        "enabled": true
    },
    "linter": {
        "enabled": true,
        "rules": {
            "recommended": true
        }
    },
    "javascript": {
        "formatter": {
            "quoteStyle": "double"
        }
    },
    "overrides": [
        {
          "include": ["tests/**"],
          "linter": {
            "rules": {
              "suspicious": {
                "noExplicitAny": "off"
              }
            }
          }
        }
    ]
}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Converting an object into an array using React and TypeScript

Extracted from a form is an object with input, output, and outputType fields that can vary between number, string, and boolean types. To display the information in a table without the output type, I have created a mapped obj. However, I also need to prese ...

Angular 2: Implementing functionality on selected option

I have written code for my HTML <select [(ngModel)]="empfile.storeno" class="form-control"> <option *ngFor="let p of concept" [ngValue]="p.MAP_Code">{{p.MAP_Code}}</option> </select> As for my component public concept = []; ...

Tips for confirming a sub string is present in an array using JavaScript/TScript

I am currently testing for the presence of a SubString within an array. In my test, I am asserting using: expect(classList).toContain('Rail__focused') However, I encountered the following error: Error: expect(received).toContain(expected // inde ...

Error occurs in Angular Mat Table when attempting to display the same column twice, resulting in the message "Duplicate column definition name provided" being

What is the most efficient method to display a duplicated column with the same data side by side without altering the JSON or using separate matColumnDef keys? Data: const ELEMENT_DATA: PeriodicElement[] = [ {position: 1, name: 'Hydrogen', wei ...

Inheritance-based generic type inference in Typescript

Take a look at this piece of code: class A<T> { t?: T; } interface B {} class C implements A<B> {} function f<T1 extends A<T2>, T2>(a: T1): T2 | undefined { return a.t; } const result = f(new C()); const result2 = f(new A<B> ...

Error encountered: Module 'redux-saga/effects' declaration file not found. The file '.../redux-saga-effects-npm-proxy.cjs.js' is implicitly typed as 'any'. Error code: TS7016

<path-to-project>/client/src/sagas/index.ts TypeScript error in <path-to-project>/client/src/sagas/index.ts(1,46): Could not find a declaration file for module 'redux-saga/effects'. '<path-to-project>/client/.yarn/cache/red ...

Tips for clearing an observable in Angular version 4

In the code snippet below, an observable has been created: private permissionSubject = new Subject<any>(); permissionObservable$ = this.permissionSubject.asObservable(); constructor( public apiService: ApiService) { } updatePermissionsDat ...

Using React and TailwindCSS to create interactive hover effects on elements within the Document Object Model

When hovering over a container, an icon appears. Currently, it is positioned relative to ensure it stays within the container. However, this positioning affects the vertical alignment of other items in the container. Using negative margins as a workaround ...

Creating a new item in Angular 2 using user input

Just dipping my toes into Angular2 and attempting to append a new item to the list through input. However, upon clicking submit, instead of text I get [object Object]. Check out the code snippet below: app.component.html <form (submit)="addItem(item) ...

Encountering numerous errors during Typescript compilation after installing Visual Studio 2017

I recently installed VisualStudio 2017 on my computer and have encountered an issue with typescript compilation. I am struggling to find a solution to this problem, as the same errors were present in VS2015 as well. Currently, I have globally installed [em ...

How can you display a set of components in React using TypeScript?

I'm currently working on rendering an array of JSX Components. I've identified two possible methods to achieve this. Method one (current approach): Create the array as an object type that stores the component properties and then build the JSX co ...

Updating CodeLens in a VS Code Extension

When using VS Code, certain language extensions can provide codelens that display reference counts above functions, variables, and other symbols. Check it out here. I've recently taken on a project and one of my first tasks is to restructure it. In d ...

Tips on validating interconnected strings with the help of yup within a react native environment

In my scenario, I am dealing with two date strings called start_date and end_date. Initially, both of these start off as empty strings: export interface FilterSchema { start_date?: any; end_date?: any; } const initialValues: FilterSchema = { s ...

Utilize ng-bootstrap in an Angular CLI project by integrating it with npm commands

I've been attempting to set up a project using Angular CLI with ng-bootstrap, but I'm having trouble getting the style to work properly. Here are the exact steps I followed (as outlined in the get-started page): Create a new project using `ng n ...

Is it possible to utilize MongooseArray.prototype.pull() in typescript?

A problem has arisen in Typescript at this specific line of code: user.posts.pull(postId); An error message I'm encountering states: Property 'pull' does not exist on type 'PostDoc[]' The issue seems to be related to the fac ...

Encountering issues with `createAsyncThunks` triggering errors in Prettier

I'm encountering errors from Prettier specifically related to the createAsyncThunk code, whereas TypeScript and ESLint do not detect these issues. What could be causing this discrepancy? Error instances include: src\store\slices\calend ...

The best approach for setting a select value and managing state in React using TypeScript

Currently, I am in the process of familiarizing myself with TypeScript within my React projects. I have defined a type for the expected data structure (consisting of name and url). type PokedexType = { name: string; url: string; } The API respon ...

What are the steps to set up tsline in settings.json file?

Currently utilizing visual studio code Upon searching for the settings.json file, the contents appear as follows: { "liveServer.settings.donotVerifyTags": true, "liveServer.settings.donotShowInfoMsg": true, "javascript ...

Creating a Typescript definition that includes a custom constant enumeration allows for precise

Struggling to generate TypeScript definition files for a specific library. The library contains a method that requires a parameter of type number, limited to a specific set of numbers. Therefore, I aim to specify in my definition that it necessitates an e ...

Using JavaScript to define an array of objects

My issue lies with transforming a JSON structure like the one below: [{ "groupid": 29, "percentage": 14 }, { "groupid": 29, "percentage": 22 }, { "groupid": 59, "percentage": 66, }] I am looking to convert it into the format shown ...