diff --git a/CHANGELOG.md b/CHANGELOG.md index 34d9fca..2943f4f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,15 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Removed ### BREAKING CHANGES +## [2.4.2] - 2021-08-22 + +### Added +- docs(#107): Add usage with TypeScript docs + +### Changed +- chore(deps): Update devDependencies + + ## [2.4.1] - 2021-08-16 ### Fixed diff --git a/README.md b/README.md index 1d7c87f..1c8937b 100644 --- a/README.md +++ b/README.md @@ -31,6 +31,7 @@ __This plugin ensures that your architecture boundaries are respected by the ele * [Elements matchers](#elements-matchers) * [Advanced example](#advanced-example) - [Resolvers](#resolvers) +- [Usage with TypeScript](#usage-with-typescript) - [Debug mode](#debug-mode) - [Acknowledgements](#acknowledgements) - [Contributing](#contributing) @@ -387,6 +388,41 @@ This plugin uses `eslint-module-utils/resolve` module under the hood, which is a } ``` +## Usage with TypeScript + +This plugin can be used also in [TypeScript](https://www.typescriptlang.org/) projects using `@typescript-eslint/eslint-plugin`. Follow next steps to configure it: + +Install dependencies: + +```bash +npm i --save-dev @typescript-eslint/eslint-plugin @typescript-eslint/parser eslint-import-resolver-typescript +``` + +Configure [`@typescript-eslint/parser`](https://github.com/typescript-eslint/typescript-eslint) as parser, load the [`@typescript-eslint`](https://github.com/typescript-eslint/typescript-eslint) plugin, and setup the [`eslint-import-resolver-typescript`](https://github.com/alexgorbatchev/eslint-import-resolver-typescript) resolver in the `.eslintrc.js` config file: + +```js +module.exports = { + parser: "@typescript-eslint/parser", + plugins: ["@typescript-eslint", "boundaries"], + extends: [ + "eslint:recommended", + "plugin:@typescript-eslint/recommended", + "plugin:boundaries/recommended", + ], + settings: { + "import/resolver": { + typescript: { + alwaysTryTypes: true, + }, + }, + }, +}; +``` + +> Note that `eslint-import-resolver-typescript` detects even custom paths defined in the `tsconfig.json` file, so its usage is also compatible with this plugin. + +In case you face any issue configuring it, you can also [use this repository as a guide](https://github.com/javierbrea/epb-ts-example). It contains a fully working and tested example. + ## Debug mode In order to help during the configuration process, the plugin can trace information about the files and imports being analyzed. The information includes the file path, the assigned element type, the captured values, etc. So, it can help you to check that your `elements` setting works as expected. You can enable it using the `ESLINT_PLUGIN_BOUNDARIES_DEBUG` environment variable. diff --git a/package-lock.json b/package-lock.json index 9f5533f..2fab6b1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "eslint-plugin-boundaries", - "version": "2.4.1", + "version": "2.4.2", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -1847,9 +1847,9 @@ "dev": true }, "eslint-import-resolver-node": { - "version": "0.3.5", - "resolved": "https://registry.npmjs.org/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.5.tgz", - "integrity": "sha512-XMoPKjSpXbkeJ7ZZ9icLnJMTY5Mc1kZbCakHquaFsXPpyWOwK0TK6CODO+0ca54UoM9LKOxyUNnoVZRl8TeaAg==", + "version": "0.3.6", + "resolved": "https://registry.npmjs.org/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.6.tgz", + "integrity": "sha512-0En0w03NRVMn9Uiyn8YRPDKvWjxCWkslUEhGNTdGx15RvPJYQ+lbOlqrlNI2vEAs4pDYK4f/HN2TbDmk5TP0iw==", "requires": { "debug": "^3.2.7", "resolve": "^1.20.0" diff --git a/package.json b/package.json index 1273522..7eb432e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "eslint-plugin-boundaries", - "version": "2.4.1", + "version": "2.4.2", "description": "Eslint plugin checking architecture boundaries between elements", "keywords": [ "eslint", @@ -31,7 +31,7 @@ "eslint": "^6.0.0 || ^7.0.0" }, "dependencies": { - "eslint-import-resolver-node": "0.3.5", + "eslint-import-resolver-node": "0.3.6", "eslint-module-utils": "2.6.2", "chalk": "4.1.2", "is-core-module": "2.5.0", diff --git a/sonar-project.properties b/sonar-project.properties index 37cb201..2c57a30 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -1,6 +1,6 @@ sonar.organization=javierbrea sonar.projectKey=javierbrea_eslint-plugin-boundaries -sonar.projectVersion=2.4.1 +sonar.projectVersion=2.4.2 sonar.javascript.file.suffixes=.js sonar.sourceEncoding=UTF-8