From 316d799711c99ec2534600e1b386075f46dc1e1a Mon Sep 17 00:00:00 2001 From: Toastie Date: Thu, 3 Oct 2024 00:06:16 +1300 Subject: [PATCH] Updated readme and package files --- README.md | 58 +++++++++++++++++++++++++++++++++------------------- package.json | 2 +- 2 files changed, 38 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index 517e473..d583f40 100644 --- a/README.md +++ b/README.md @@ -7,36 +7,52 @@ First, install the plugin using npm. ```bash -npm install --save-dev eslint @valkyriecoms/eslint-plugin @typescript-eslint/eslint-plugin @typescript-eslint/parser eslint-plugin-import +npm install --save-dev eslint @valkyriecoms/eslint-plugin @typescript-eslint/parser ``` ## Usage -Create `.eslintrc.cjs` file and write as follows +Create `eslint.config.js` file and write as follows -```javascript:.eslintrc.cjs -module.exports = { - root: true, - parserOptions: { - tsconfigRootDir: __dirname, - project: ['./tsconfig.json'], +```javascript:eslint.config.js +import pluginValkyriecoms from '@valkyriecoms/eslint-plugin'; +import tsParser from '@typescript-eslint/parser'; + +export default [ + ...pluginValkyriecoms.configs['recommended'], + { + files: ['**/*.js', '**/*.jsx'], + languageOptions: { + parserOptions: { + ecmaVersion: 'latest', + sourceType: 'module', + }, + }, }, - ignorePatterns: ['**/.eslintrc.cjs'], - extends: [ - 'plugin:@valkyriecoms/recommended', - ], -}; + { + files: ['**/*.ts', '**/*.tsx'], + languageOptions: { + parserOptions: { + ecmaVersion: 'latest', + parser: tsParser, + project: ['./tsconfig.json'], + sourceType: 'module', + tsconfigRootDir: import.meta.dirname, + }, + }, + }, +]; ``` In tsconfig, strictNullChecks must be true. ```json:tsconfig.json { - "compilerOptions": { - ... - "strictNullChecks": true, - ... - }, + "compilerOptions": { + // ... + "strictNullChecks": true, + // ... + }, } ``` @@ -44,9 +60,9 @@ Add the eslint task to `package.json` ```json:package.json { - "scripts": { - "eslint": "eslint . --ext .js,.jsx,.ts,.tsx" - }, + "scripts": { + "eslint": "eslint './**/*.{js,jsx,ts,tsx}'" + }, } ``` diff --git a/package.json b/package.json index 20b9c71..fc1ef65 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "type": "commonjs", "main": "index.js", "scripts": { - "eslint": "eslint . --ext .js,.jsx,.ts,.tsx" + "eslint": "eslint ./**/*.{js,jsx,ts,tsx}" }, "files": [ "index.js",