Ask Your Question
4

What is the process for configuring ESLint to format the js files produced by tsc?

asked 2023-07-01 20:38:32 +0000

qstack gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2023-07-01 21:08:02 +0000

woof gravatar image

To configure ESLint to format the js files produced by tsc, you can follow these steps:

  1. Install the necessary packages:
npm install eslint eslint-config-prettier eslint-plugin-prettier prettier --save-dev
  1. Create a .eslintrc.json file in the root directory of your project with the following configuration:
{
  "extends": ["eslint:recommended", "plugin:prettier/recommended"],
  "plugins": ["prettier"],
  "rules": {
    "prettier/prettier": "error"
  }
}
  1. Create a prettier.config.js file in the root directory of your project with the following configuration:
module.exports = {
  semi: true,
  trailingComma: "all",
  singleQuote: true,
  printWidth: 80,
  tabWidth: 2
};
  1. Add a lint command to your package.json file, which runs ESLint and formats your code:
"scripts": {
  "lint": "eslint 'src/**/*.{js,ts}' --fix"
}
  1. Run the lint command to format your code:
npm run lint

This will run ESLint and format your JS files produced by tsc.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2023-07-01 20:38:32 +0000

Seen: 12 times

Last updated: Jul 01 '23