From ca80ef3c63504e39971d1876ab33eca0fcab5d2e Mon Sep 17 00:00:00 2001 From: Robert Vitonsky Date: Thu, 4 Apr 2024 00:26:40 +0200 Subject: [PATCH] docs: update readme --- README.md | 52 ++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 46 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 79c96ac..711bd79 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,51 @@ -Short one paragraph description, which answer to question "what is this?". +Eslint plugin to replace a relative imports, according to `paths` options in `tsconfig.json` or `jsconfig.json`. -Detailed description in few paragrapghs about "for what this?" and how it works. +# Setup -# Features +Install package with `npm install -D eslint-plugin-paths`, then update eslint config - +```json +{ + "plugins": [ + "paths", + ], + "rules": { + "paths/aliases": "error" + } +} +``` -# Usage +# Examples - +If you have `tsconfig.json` with config below + +```json +{ + "compilerOptions": { + "baseUrl": ".", + "paths": { + "@foo/*": ["src/foo/*"], + "@bar/*": ["src/bar/*"] + } + } +} +``` + +then code below will be valid + +```ts +// src/index.ts + +import foo from '@foo'; +import barZ from '@bar/x/y/z'; +import bazZ from './baz/x/y/z'; +``` + +and this code will be invalid + +```ts +// src/index.ts + +import foo from './foo'; +import barZ from './bar/x/y/z'; +``` \ No newline at end of file