Source: https://github.com/mscharley/node-presets
Author: Matthew Scharley
Contributors: See contributors on GitHub
Bugs/Support: Github Issues
License: MIT license
Status: Active
This is a preset for eslint for use with TypeScript or JavaScript projects.
$ npm install --save-dev @mscharley/eslint-config
// .eslintrc.js
module.exports = {
root: true,
extends: [
'@mscharley', // Baseline rules for any TS or JS project.
'@mscharley/eslint-config/node', // For projects running on NodeJS.
// '@mscharley/eslint-config/react', // For projects running React.
],
};
If using Prettier to format files other than TypeScript and JavaScript files then you should ignore all TS/JS files to prevent ESLint and Prettier from fighting with each other.
# .prettierignore
**/*.cts
**/*.mts
**/*.ts
**/*.cjs
**/*.mjs
**/*.js
As a general rule we can't enable the deprecation/deprecation
rule for JavaScript files because this rule requires TypeScript type information to work. If you have a mixed TypeScript/JavaScript project then you can enable it for the JavaScript files inside your TypeScript project using the following override:
// .eslintrc.js
module.exports = {
overrides: [
{
// This must be a valid path inside your TypeScript source folders.
files: ["src/**/*.{js,jsx}"],
rules: { "deprecation/deprecation": "warn" },
},
],
};