1.0.3 • Published 2 years ago

@northtech/eslint-config-typescript v1.0.3

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

@northtech/eslint-config-typescript

This package is an ESLint Sharable Config, bundling ESLint and TypeScript-ESLint rules for a consistent style in NorthTech projects.

It is fairly strict when it comes to formatting, in part because it can simply be auto-fixed, and in part because IDEs like IntelliJ recognize the rules and automatically configure their own settings accordingly, so the more rules we have, the more work the IDE will do automatically for us.

The rules are actually somewhat more lenient when it comes to the actual code, largely because we still often need inter-op with legacy code, where strictly enforced TypeScript rules would force us to jump through hoops simply to make the linter happy, with little gain for the actual code.

npm install --save-dev @northtech/eslint-config-typescript typescript@^4 eslint@^8 @typescript-eslint/parser@^5 @typescript-eslint/eslint-plugin@^5

-You probably already have TypeScript.

Project configuration

Create two configuration files in the project root:

.eslintrc.js: (Or .eslintrc.cjs, if you're using package type module in your package.json).

module.exports = {
  root: true,
  extends: ["@northtech/eslint-config-typescript"]
};

This points ESLint to the rules in the NorthTech package.

Be aware that the setup by default uses the TypeScript compiler settings from /tsconfig.json. If you use another file, override the parserOptions in the configuration, like

module.exports = {
  root: true,
  extends: ["@northtech/eslint-config-typescript"],
  "parserOptions": {"project": ["my-tsconfig.json"]}
};

.eslintignore:

node_modules
dist
coverage
docs
*.js
*.cjs

Don't lint these files. (We skip *.js files as they are typically compact configuration files for the various build tools. To wit, the .eslintrc.js file above would not pass linting due to the module export).

Scripts

I recommend adding

{
  ...
  "scripts": {
    ...
    "lint": "eslint . --ext .ts",
    "lint-fix": "eslint . --ext .ts --fix"
  },
  ...
}

to your package.json.

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago

1.0.0-rc.6

2 years ago

1.0.3

2 years ago

1.0.0-rc.5

2 years ago

1.0.0-rc.4

2 years ago

1.0.0-rc.3

3 years ago

1.0.0-rc.2

3 years ago

1.0.0-rc.1

3 years ago

1.0.0-rc.0

3 years ago