eslint-config-toc
v1.9.1
Published
ESLint config for ToC TypeScript based projects
Downloads
431
Readme
🚦 eslint-config-toc
This package allows us to make decisions on code styling for all TypeScript based projects developed by or for Tired of Cancer B.V.
- Useable in any TS project (react, react-native, next.js etc).
- Extends proven conventions (airbnb config, unicorn plugin etc).
- Allows for opiniated deviations (added consistency or sensible overrides).
Contents
⚙️ Usage
This library requires node 16+.
yarn add -D eslint eslint-config-toc
.- Add the following to your
package.json
:
"prettier": "eslint-config-toc/.prettierrc",
"resolutions": {
"eslint-plugin-react-native": "4.0.0"
}
- Setup your linting config in
.eslintrc.js
:
// This enables ESLint to use dependencies of this config
// (see https://github.com/eslint/eslint/issues/3458)
require('eslint-config-toc/setup-plugins')
module.exports = {
// Uncomment only ONE (the most applicable) config for your project and remove the others
// extends: ['toc/typescript'],
// extends: ['toc/react'],
// extends: ['toc/nexstjs'],
// extends: ['toc/react-native'],
}
- Set up your TypeScript config in
tsconfig.json
. If your project was generated with a tsconfig file, make sure to remove all specific rules to prevent conflicts:
{
// Uncomment only ONE (the most applicable) config for your project and remove the others
// "extends": "eslint-config-toc/tsconfig-typescript.json",
// "extends": "eslint-config-toc/tsconfig-react.json",
// "extends": "eslint-config-toc/tsconfig-nextjs.json",
// "extends": "eslint-config-toc/tsconfig-react-native.json",
}
- Happy linting! 🎉
📣 Proposing changes
When proposing a change to this shared configuration, keep in mind that it will impact all ToC projects and developers. First ask yourself these questions:
- Does the change improve consistency, security and/or stability of our codestyle?
- Will the change benefit all projects and developers?
- Is the effort worth the gain? For example, if the change cannot be auto-fixed by prettier it may cause a lot of refactor work.
If all of these questions can be answered with a strong 'YES', go ahead with a proposal for change:
- Research the change and the impact on our existing projects.
- Create a PR to this repository containing:
- The change, added to the appropriate config (for example, React Native specific deviation rules should be added to
react-native.js
). - A comment right above the change(s) in the config files that explains in short why we are using that deviation.
- If applicable; the changes required to keep the files in this repository valid (test with
yarn lint
andyarn prettier
).
- The change, added to the appropriate config (for example, React Native specific deviation rules should be added to
- In the PR body, describe the following:
- What is the reason for this change.
- What will the impact be on existing projects.
- How can the changes be (temporarily) ignored. Add a code snippet.
- Add an appropriate label to the PR. These are used in our changelog automation:
bug
for solving bugs in this library or it's ci configuration.documentation
for updating the instructions in the README or clarifying comments with existing deviations.dependencies
for updating existing dependencies. These are usually done automatically by Renovate.feature
for proposing a new rule deviation or adding a new dependency.breaking
for any of the above changes when it also will cause breaking changes in any project depending on this library.
☝️ For an example PR, see #1.
When the PR is ready for review, request reviews from the rest of the team. Discussion should happen in the PR comments as much as possible to ensure future developers can see why certain decissions were made in the past.
When more than half of the rest of the team agrees with the proposed changes, the PR can be merged.
🚀 Versioning and releasing
When a PR is merged, the release notes for the next draft release are automatically prepared. Based on the added labels, the version number in the release title and package.json may be automatically updated as well.
When we are ready to publish a new version to NPM, all we need to do is publish the draft release:
- Go to the releases overview.
- Check if the last change has been added (the Github action workflow needs to complete after merging the most recent PR).
- Edit the existing draft release. If there is no draft release, there were no changes since the last release.
- Press
Publish release
. - Presto! A new Github release and tag have been made. A workflow will automatically publish this version to NPM.
🦸 Acknowledgements
The configured ruleset is based on airbnb's eslint config. Check their documentation on the reasoning behind all the rules that are not specifically configured as deviations in this repository.
The setup of this configuration project was inspired by eslint-config-molindo and eslint-config-ns.