@khanhtran47/config
This is my personal ESLint, Prettier, and TypeScript configuration. It is a shareable configuration that can be used in any JavaScript or TypeScript project.
Install
npm install --save-dev @khanhtran47/config
Be sure to install the appropriately versioned of
eslint
andprettier
peer dependency as well.
Usage
Follow the ESLint documentation on shared configurations. See the documentation on ignoring files if you need to ignore anything the config doesn't already ignore by default.
Follow the Prettier documentation on sharing configurations.
Examples
ESlint
Create a eslint.config.js
file in your project root with the following content:
import { config as defaultConfig } from '@khanhtran47/config/eslint';
/** @type {import("eslint").Linter.Config[]} */
const config = [
...defaultConfig,
// overrides here
];
export default config;
Prettier
package.json
{
"prettier": "@khanhtran47/config/prettier",
"scripts": {
...
"lint": "eslint --cache --cache-location ./node_modules/.cache/eslint .",
"format": "prettier --cache --write .",
"format:check": "prettier --cache --check .",
...
}
}
If you need to customize the configuration, you can use a dedicated Prettier config file instead of the one-liner in package.json:
prettier.config.js
import { config as defaultConfig } from '@khanhtran47/config/prettier';
/** @type {import("prettier").Options} */
export const config = {
...defaultConfig,
// overrides here
};
export default config;
TypeScript
Create a tsconfig.json
file in your project root with the following content:
{
"extends": ["@khanhtran47/config/typescript"],
"compilerOptions": {
// overrides here
}
}