Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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.