Configuration for eslint on typescript compiled Javascript files

I successfully configured a VS code project to adhere to the airbnb and typescript configuration, resulting in the expected behavior of typescript code linting.

To locate the .eslintrc.js file:

const path = require('path');
module.exports = {
  root: true,
  env: {
    browser: true,
    jquery: true
  },
  extends: [
    'airbnb/base',
    'plugin:@typescript-eslint/recommended',
  ],
  parserOptions: {
    parser: '@typescript-eslint/parser',
    ecmaVersion: 2018,
    sourceType: 'module',
  },
  settings: {
    'import/resolver': {
      alias: {
        map: [
          ['@', path.resolve(__dirname, 'src')],
        ],
        extensions: [
          '.js', '.js', '.json',
        ],
      },
    },
  },
  rules: { // List of linting rules...
};

Although eslint also applies to the typescript compiled .js files, I prefer it not to. I experimented with the tsc compiler and prettier plugin for compiling according to airbnb rules, which seemed most desirable. Alternatively, I consider disabling eslint for the js files. While I have successfully configured a project to work with typescript, I struggle with handling the linting of compiled .js files and how to compile multiple files simultaneously in a project.

In addition to my specific query, any insights on the typescript workflow are welcome. I assume one compiles all tsc files and designates the corresponding tsc compiled .js file as the app entry point, but unsure if this is correct.

Many thanks in advance.

Answer №1

If you need to tell eslint to skip over specific files or directories, you can customize the eslint configuration

For example, if your application is compiled into a directory named build, your eslint configuration might include:

"ignorePatterns": ["build"]

If you want to exclude all files with a .js extension regardless of their location, you could use:

"ignorePatterns": ["**/*.js"]

You can also apply similar patterns in a separate .eslintignore file.

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

Exporting the statement from Ionic 3 page.module.ts file

Recently, I started working on Ionic 3 and decided to implement the new page lazy loading approach. Specifically, I have a page named ControlPage that I am focusing on. In most of the resources I referred to, it was recommended to include the following co ...

Learn how to dynamically obtain AWS subnet and security group IDs using the serverless framework

I have been utilizing the Serverless Framework to deploy a Lambda function to AWS using Typescript. When connecting the Lambda to an existing VPC, it is necessary to specify the Subnet and Security Group IDs. Is there a method to obtain these values dynam ...

Setting a TypeScript collection field within an object prior to sending an HTTP POST request

Encountered an issue while attempting to POST an Object (User). The error message appeared when structuring it as follows: Below is the model class used: export class User { userRoles: Set<UserRole>; id: number; } In my TypeScript file, I included ...

Compiling TypeScript on save disrupts AngularJS functionality in Visual Studio 2017

I am currently working on a project in Visual Studio Community 2017 (15.2) that involves AngularJS 1.6.5 and a NancyFX server. You can find the code for this project here: https://github.com/GusBeare/NancyAngularTests This project serves as a learning pl ...

Experiencing Compatibility Issues: Next.js 14.0.3 with next-auth and NestJS Backend Runs Smoothly in Development Environment, but Encounters

Currently, I am developing a Next.js 14.0.3 application that utilizes next-auth for authentication. The application interacts with an external NestJS backend for authorization and JWT validation. While everything functions correctly in the development envi ...

The Hapi response fails to display JSON data in a nested tree format

Hey there! I've got this object with a specific structure. Here it is: interface FolderWithContent { uuid: string name: string; folders: Array<FolderWithContent>; files: Array<Files>; } Just a heads up, Files is an extens ...

I am having trouble establishing a connection between the MySQL Workbench database and VS Code

During my ReactJS CRUD training, I encountered an issue while trying to add an entry to the MySQL Workbench database from VS Code. Despite ensuring all names and symbols match up, the entry is not being added upon page reload. Clicking on "Execute the se ...

Retrieve a single record in Angular/Typescript and extract its ID value

There is data stored in a variable that is displayed in the Chrome console like this: 0: @attributes: actPer: "1", id: "19" 1: @attributes: actPer: "1" id: "17" etc To filter this data, the following code was used: myvar = this.obj.listR ...

Navigating through a large array list that contains both arrays and objects in Typescript:

I have an array containing arrays of objects, each with at least 10 properties. My goal is to extract and store only the ids of these objects in the same order. Here is the code I have written for this task: Here is the structure of my data: organisationC ...

how to implement dynamic water fill effects using SVG in an Angular application

Take a look at the code snippet here HTML TypeScript data = [ { name: 'server1', humidity: '50.9' }, { name: 'server2', humidity: '52.9', }, { name: 'server3', humidity: ...

Ways to restrict data types within function parameters

Can you validate types of one argument based on another argument in functions? Consider this example: interface Data { id?: number; name?: string; } let data : Data = {}; // I am unsure how to make the "value" argument strict function update(field : ...

Unfortunately, I am unable to utilize my Async Validator as it is wrapped within the "__zone_symbol" object

I have created an asynchronous validator for passwords. export class PasswordsValidators{ static oldPasswordMatch(control: AbstractControl) : Promise<ValidationErrors> | null { return new Promise((resolve) => { if(control. ...

Postgres Array intersection: finding elements common to two arrays

I'm currently developing a search function based on tags, within a table structure like this CREATE TABLE permission ( id serial primary key, tags varchar(255)[], ); After adding a row with the tags "artist" and "default," I aim ...

Interface for TypeScript hashmap/dictionary

I am currently working on incorporating a hashmap/dictionary interface. The progress I have made so far is as follows: export interface IHash { [details: string] : string; } I am facing difficulties in comprehending the exact meaning of this syntax. I ...

JavaScript - Modifying several object properties within an array of objects

I am attempting to update the values of multiple objects within an array of objects. // Using a for..of loop with variable i to access the second array and retrieve values const AntraegeListe = new Array(); for (let i = 0; i < MESRForm.MitarbeiterL ...

VSCode mistakenly detecting Sequelize findOne and findAll return type as any inferences

I have a model defined using Sequelize as shown below: import { Sequelize, Model, BuildOptions, DataTypes } from 'sequelize'; interface User extends Model { readonly id: string; email: string; name: string; password_hash: string; reado ...

Using RXJS with the 'never' subject as the specified generic type

In my current Angular project, I am using RXJS and Typescript. The code snippet below shows what I have implemented: const sub = new Subject<never>(); My understanding is that the above line implies that any subscriber defining the 'next' ...

Compilation error - TypeScript has encountered a poorly attached object

Encountering a puzzling React and TypeScript issue where a component loads momentarily, then abruptly crashes with the error: [internal] TypeScript error in [internal] (undefined,undefined): badly attached item found. TSINTERNAL_ERROR The problematic ...

Consolidating Typescript modules into a single .js file

Recently, I was able to get my hands on a TypeScript library that I found on GitHub. As I started exploring it, I noticed that there were quite a few dependencies on other npm packages. This got me thinking - is there a way to compile all these files int ...

Show the key and value of a JSON object in a React component

When attempting to parse a JSON data file, I encountered an error message stating: "Element implicitly has an 'any' type because expression of type 'string' can't be used to the index type." The JSON data is sourced locally from a ...