Local Development
Thank you for your interest in developing on typescript-eslint! ❤️🔥
See Contributing and Issues for details on our general contribution flows.
Setup
After forking the repo from GitHub and installing pnpm:
git clone https://github.com/<your-name-here>/typescript-eslint
cd typescript-eslint
pnpm install
You can see which version of pnpm we use by checking the packageManager field in the root package.json.
Postinstall scripts will then fully build your repository locally with (pnpm run build).
At this point, you're ready to develop! 🚀
Builds
You can run pnpm run build in the root to build all packages, or in any package to build just that package.
Keep in mind that packages generally depend on each other's built outputs, and you'll need to pnpm run build dependents for their consumers to receive any new local changes.
For example, if you make a change within scope-manager and want to use it in eslint-plugin, you'll need to pnpm run build either from the root or within packages/scope-manager.
Validating Changes
The following checks are all run on pull requests automatically. You can also perform them locally.
See Contributing > Pull Requests for more information on pull requests.
Formatting
We use Prettier to auto-format code.
A Git pre-commit hook should apply it to all committed changes.
Alternately, you can run pnpm run format in any package or in the root.
Linting
All code changes must pass ESLint.
You can run pnpm run lint in any package or in the root.
Proofreading
Changes must pass two linters for documentation and naming, the commands for which may be run from the root:
pnpm run check-spelling: CSpell, for all codepnpm run lint-markdown: Markdownlint, for Markdown documentation
Tests
All code changes should ideally be unit tested if possible.
You can run pnpm run test in any package to run its tests.
Oftentimes, you will only want to run one specific test related to the bug you are fixing or the feature you are implementing. To do this, you can add only: true to the test object definition. (Doing this will cause a new lint error for eslint-plugin/no-only-tests, but just ignore it while you work. The lint rule is only there so that you remember to delete the only: true once it comes time to make a pull request.)
The repository has Visual Studio Code launch tasks that allow for visually debugging tests.
Type Checking
All code should pass TypeScript type checking.
You can run pnpm run typecheck in any package or in the root to run tsc.
Run
pnpm run typecheck -wto starttscin watch mode.
Rule Development
Some portions of this repository are generated by manually running scripts that read from rule files. If you modify rules, you may need to run either or both of:
pnpm run generate-configsfrom root: to regenerate shared configspnpm run test docs -ufrompackages/eslint-plugin: to regenerate snapshots based on rule docs and options
Website Development
Our interactive documentation website is built with Docusaurus.
Running pnpm run start from either the root or packages/website will start a local dev server on localhost:3000.
The
websitepackage relies on other packages being built. We recommend runningpnpm run buildfrom the root beforepnpm run start.