Last active
September 10, 2022 20:17
-
-
Save ecxyzzy/dd7989bdf546942a6b7655602d4e8f79 to your computer and use it in GitHub Desktop.
Proposed ESLint config for ICSSC Projects, version 0.1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // JavaScript projects | |
| // setup: npm install --save-dev eslint eslint-plugin-simple-import-sort eslint-plugin-import | |
| const js = { | |
| "root": true, | |
| "plugins": ["simple-import-sort", "import"], | |
| "extends": ["eslint:recommended"], | |
| "rules": { | |
| "simple-import-sort/imports": "error", | |
| "simple-import-sort/exports": "error", // these two autosort imports and exports | |
| "import/first": "error", // ensures all imports are at top of file | |
| "import/newline-after-import": "error", // adds newline after the last import statement | |
| "import/no-duplicates": "error" // deduplicates import statements | |
| } | |
| } | |
| // TypeScript projects | |
| // setup: npm install --save-dev eslint eslint-plugin-simple-import-sort eslint-plugin-import @typescript-eslint/parser @typescript-eslint/eslint-plugin eslint-import-resolver-typescript | |
| const ts = { | |
| "root": true, | |
| "parser": "@typescript-eslint/parser", | |
| "parserOptions": { | |
| tsconfigRootDir: __dirname, | |
| project: ['./tsconfig.json'], | |
| }, | |
| "plugins": ["import", "simple-import-sort", "@typescript-eslint"], | |
| "extends": [ | |
| "eslint:recommended", | |
| "plugin:@typescript-eslint/recommended", | |
| "plugin:@typescript-eslint/recommended-requiring-type-checking" // optional but highly recommended, see https://typescript-eslint.io/docs/linting/typed-linting | |
| ], | |
| "rules": { | |
| "simple-import-sort/imports": "error", | |
| "simple-import-sort/exports": "error", | |
| "import/first": "error", | |
| "import/newline-after-import": "error", | |
| "import/no-duplicates": "error" | |
| }, | |
| "settings": { // settings to make eslint-plugin-import play nice with TypeScript | |
| "import/parsers": { | |
| "@typescript-eslint/parser": [".ts"] | |
| }, | |
| "import/resolver": { | |
| "typescript": { | |
| "alwaysTryTypes": true, | |
| "project": "tsconfig.json" | |
| } | |
| } | |
| } | |
| } | |
| // JavaScript + React projects | |
| // setup: npm install --save-dev eslint eslint-plugin-simple-import-sort eslint-plugin-import eslint-plugin-react eslint-plugin-react-hooks eslint-plugin-jsx-a11y | |
| const jsReact = { | |
| "root": true, | |
| "plugins": ["simple-import-sort", "import"], | |
| "extends": [ | |
| "eslint:recommended", | |
| "plugin:react/recommended", | |
| "plugin:react-hooks/recommended", | |
| "plugin:jsx-a11y/recommended" | |
| ], | |
| "rules": { | |
| "simple-import-sort/imports": "error", | |
| "simple-import-sort/exports": "error", | |
| "import/first": "error", | |
| "import/newline-after-import": "error", | |
| "import/no-duplicates": "error" | |
| }, | |
| "settings": { | |
| "react": { | |
| "version": "detect" // let eslint-plugin-react detect the React version in use | |
| } | |
| } | |
| } | |
| // TypeScript + React projects | |
| // setup: npm install --save-dev eslint eslint-plugin-simple-import-sort eslint-plugin-import @typescript-eslint/parser @typescript-eslint/eslint-plugin eslint-plugin-react eslint-plugin-react-hooks eslint-plugin-jsx-a11y eslint-import-resolver-typescript | |
| const tsReact = { | |
| "root": true, | |
| "parser": "@typescript-eslint/parser", | |
| "parserOptions": { | |
| tsconfigRootDir: __dirname, | |
| project: ['./tsconfig.json'], | |
| }, | |
| "plugins": ["import", "simple-import-sort", "@typescript-eslint"], | |
| "extends": [ | |
| "eslint:recommended", | |
| "plugin:@typescript-eslint/recommended", | |
| "plugin:@typescript-eslint/recommended-requiring-type-checking", | |
| "plugin:react/recommended", | |
| "plugin:react-hooks/recommended", | |
| "plugin:jsx-a11y/recommended" | |
| ], | |
| "rules": { | |
| "simple-import-sort/imports": "error", | |
| "simple-import-sort/exports": "error", | |
| "import/first": "error", | |
| "import/newline-after-import": "error", | |
| "import/no-duplicates": "error" | |
| }, | |
| "settings": { | |
| "import/parsers": { | |
| "@typescript-eslint/parser": [".ts"] | |
| }, | |
| "import/resolver": { | |
| "typescript": { | |
| "alwaysTryTypes": true, | |
| "project": "tsconfig.json" | |
| } | |
| }, | |
| "react": { | |
| "version": "detect" | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment