From 5086323b45930e298a49521372db86a474848627 Mon Sep 17 00:00:00 2001 From: Agustinus Nathaniel Date: Thu, 27 Jan 2022 21:52:53 +0700 Subject: [PATCH] feat(rules): enforce consistent usage of type imports https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/consistent-type-imports.md --- README.md | 8 ++++++-- rules.js | 4 ++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 7df371e..12821f3 100644 --- a/README.md +++ b/README.md @@ -9,11 +9,11 @@ ESLint rules I use throughout my personal projects with bundled dependencies. ## 🔧 Installation ```bash -npm i --save-dev eslint@^7 eslint-config-sznm +npm i --save-dev eslint eslint-config-sznm # or (if using yarn) -yarn add -D eslint@^7 eslint-config-sznm +yarn add -D eslint eslint-config-sznm ``` ## :computer: Usage @@ -26,6 +26,7 @@ add the extends to your project's eslintrc config make sure `eslint-config-next` is installed (as `devDependencies`) ```js +/** @type {import('eslint').Linter.Config} */ module.exports = { extends: ['sznm/react', 'plugin:@next/next/recommended'], }; @@ -34,6 +35,7 @@ module.exports = { optional: ```js +/** @type {import('eslint').Linter.Config} */ module.exports = { extends: [ 'sznm/react', @@ -46,6 +48,7 @@ module.exports = { ### ⚛️ React Projects ```js +/** @type {import('eslint').Linter.Config} */ module.exports = { extends: ['sznm/react'], }; @@ -56,6 +59,7 @@ module.exports = { > ❗⚠️ [WIP] still tinkering around here, I made this config with support for Next.js and React + TypeScript as first priority in mind. ```js +/** @type {import('eslint').Linter.Config} */ module.exports = { extends: ['sznm'], }; diff --git a/rules.js b/rules.js index 0744f36..2a3ec70 100644 --- a/rules.js +++ b/rules.js @@ -5,6 +5,10 @@ module.exports = { 'no-unused-vars': 'off', '@typescript-eslint/no-unused-vars': ['error'], '@typescript-eslint/explicit-module-boundary-types': 'off', + '@typescript-eslint/consistent-type-imports': [ + 'error', + { prefer: 'type-imports' }, + ], complexity: 'warn', 'no-console': 'error', },