-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Remove `comma-dangle` * Begin ESLint v9 rewrite, remove unused React config * Switch to flat config * Change `no-console` to `warn` * Update package versions * Update peer dependencies versions, move import to dependencies * Mark as RC * Disable `import/no-named-as-default` See import-js/eslint-plugin-import#2995 and import-js/eslint-plugin-import#2556#issuecomment-2121423498 * Remove `plugins` * Update `eslint-plugin-import` In hindsight, I should have read the release notes and saw that the PR wasn't released yet even though it was merged. * Add typings * Release version 2.0.0 * Add the types to `package.json` * Add the ESLint configuration to the README
- Loading branch information
Showing
9 changed files
with
1,816 additions
and
1,716 deletions.
There are no files selected for viewing
This file contains 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
This file was deleted.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,59 @@ | ||
# `@hkamran/prettier-config` | ||
# `@hkamran/eslint-config` | ||
|
||
[![License: AGPL-3.0](https://img.shields.io/badge/License-AGPL3.0-green.svg)](../../LICENSE.md) | ||
[![npm version](https://badge.fury.io/js/%40hkamran%2Fprettier-config.svg)](https://badge.fury.io/js/%40hkamran%2Fprettier-config.svg) | ||
[![npm version](https://badge.fury.io/js/%40hkamran%2Feslint-config.svg)](https://badge.fury.io/js/%40hkamran%2Feslint-config.svg) | ||
|
||
My personal Prettier configuration | ||
My personal ESLint configuration | ||
|
||
## Installation | ||
|
||
```bash | ||
npm i -D @hkamran/prettier-config | ||
npm i -D @hkamran/eslint-config | ||
``` | ||
|
||
> [!NOTE] | ||
> For `.eslintrc.*` (not flat config), use version 1.0.1. | ||
## Usage | ||
|
||
Add the following key-value pair to your `package.json` file. | ||
Import the module, then use the spread operator to insert it into your ESLint configuration. | ||
|
||
```js | ||
import hkamranConfig from "@hkamran/eslint-config"; | ||
|
||
```json | ||
"prettier": "@hkamran/prettier-config" | ||
export default [ | ||
// ... other configuration ... | ||
...hkamranConfig, | ||
] | ||
``` | ||
|
||
## Settings | ||
|
||
| Rule | Setting | | ||
| --------------- | ------- | | ||
| Trailing Commas | all | | ||
| Tab Width | 4 | | ||
This configuration also includes the [recommended ESLint configuration](https://eslint.org/docs/latest/rules), [Prettier ESLint configuration](https://github.com/prettier/eslint-config-prettier), and the [import plugin](https://github.com/import-js/eslint-plugin-import). | ||
|
||
It runs on all JavaScript files (`.js`, `.mjs`, and `.cjs`) and TypeScript files (`.ts`). | ||
|
||
| Rule | Severity | Options | | ||
|-------------------------------|----------|------------------------------------------------------------------| | ||
| `no-alert` | Error | | | ||
| `no-await-in-loop` | Error | | | ||
| `no-return-assign` | Error | | | ||
| `no-restricted-syntax` | Error | `FunctionExpression`, `LabeledStatement`, `WithStatement` | | ||
| `no-var` | Error | | | ||
| `no-use-before-define` | Error | | | ||
| `no-unused-expressions` | Error | `enforceForJSX: true` | | ||
| `no-param-reassign` | Error | `props: false` | | ||
| `no-console` | Warn | | | ||
| `no-underscore-dangle` | Error | | | ||
| `prefer-const` | Error | `destructuring: all` | | ||
| `arrow-body-style` | Error | `as-needed`, `requireReturnForObjectLiteral: false` | | ||
| `space-before-function-paren` | Off | | | ||
| `import/first` | Error | | | ||
| `import/newline-after-import` | Error | | | ||
| `import/no-duplicates` | Error | | | ||
| `import/no-unassigned-import` | Error | `allow: [x@/styles/*.css"]` | | ||
| `import/no-unresolved` | Error | `allow: ["@/styles/*.css"]` | | ||
| `import/extensions` | Error | `never`, `css: always` | | ||
| `import/no-dynamic-require` | ERror | | | ||
| `import/no-cycle` | Error | | | ||
| `import/order` | Error | `groups: [builtin, external, internal, [parent, sibling], type]` | |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
declare const _default: import("@typescript-eslint/utils").TSESLint.FlatConfig.ConfigFile; | ||
export default _default; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,79 @@ | ||
const eslintrc = require("./.eslintrc.js"); | ||
import eslint from "@eslint/js"; | ||
import prettierConfig from "eslint-config-prettier"; | ||
import importPlugin from "eslint-plugin-import"; | ||
|
||
module.exports = eslintrc; | ||
/** @type{import('@typescript-eslint/utils').TSESLint.FlatConfig.ConfigFile} */ | ||
export default [ | ||
eslint.configs.recommended, | ||
prettierConfig, | ||
importPlugin.flatConfigs.recommended, | ||
{ | ||
files: ["**/*.{js,mjs,cjs,ts}"], | ||
languageOptions: { | ||
ecmaVersion: "latest", | ||
sourceType: "module", | ||
}, | ||
rules: { | ||
"no-alert": "error", | ||
"no-await-in-loop": "error", | ||
"no-return-assign": "error", | ||
"no-restricted-syntax": [ | ||
"error", | ||
"FunctionExpression", | ||
"LabeledStatement", | ||
"WithStatement", | ||
], | ||
"no-var": "error", | ||
"no-use-before-define": "error", | ||
"no-unused-expressions": ["error", { enforceForJSX: true }], | ||
"no-param-reassign": [ | ||
"error", | ||
{ | ||
props: false, | ||
}, | ||
], | ||
"no-console": "warn", | ||
"no-underscore-dangle": "error", | ||
|
||
"prefer-const": [ | ||
"error", | ||
{ | ||
destructuring: "all", | ||
}, | ||
], | ||
"arrow-body-style": [ | ||
"error", | ||
"as-needed", | ||
{ requireReturnForObjectLiteral: false }, | ||
], | ||
"space-before-function-paren": "off", | ||
|
||
"import/first": "error", | ||
"import/newline-after-import": "error", | ||
"import/no-duplicates": "error", | ||
"import/no-unassigned-import": [ | ||
"error", | ||
{ allow: ["@/styles/*.css"] }, | ||
], | ||
"import/no-unresolved": [ | ||
"error", | ||
{ ignore: ["@/styles/(.*).css"] }, | ||
], | ||
"import/extensions": ["error", "never", { css: "always" }], | ||
"import/no-dynamic-require": "error", | ||
"import/no-cycle": "error", | ||
"import/order": [ | ||
"error", | ||
{ | ||
groups: [ | ||
"builtin", | ||
"external", | ||
"internal", | ||
["parent", "sibling"], | ||
"type", | ||
], | ||
}, | ||
], | ||
}, | ||
}, | ||
]; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,14 @@ | ||
{ | ||
"name": "@hkamran/eslint-config", | ||
"version": "1.0.0", | ||
"license": "AGPL-3.0-or-later", | ||
"version": "2.0.0", | ||
"license": "AGPL-3.0", | ||
"description": "My personal ESLint configuration", | ||
"main": "index.js", | ||
"types": "index.d.ts", | ||
"type": "module", | ||
"scripts": { | ||
"prepare": "rimraf index.d.ts && tsc" | ||
}, | ||
"author": { | ||
"name": "H. Kamran", | ||
"email": "[email protected]", | ||
|
@@ -12,36 +17,34 @@ | |
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/hkamran80/devtools.git", | ||
"directory": "packages/prettier-config" | ||
"directory": "packages/eslint-config" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/hkamran80/devtools/issues" | ||
}, | ||
"homepage": "https://github.com/hkamran80/devtools/blob/main/packages/prettier-config/README.md", | ||
"homepage": "https://github.com/hkamran80/devtools/blob/main/packages/eslint-config/README.md", | ||
"keywords": [ | ||
"eslint", | ||
"eslint-config" | ||
], | ||
"dependencies": { | ||
"eslint-plugin-import": "^2.31.0" | ||
}, | ||
"devDependencies": { | ||
"@eslint/js": "^9.11.1", | ||
"@hkamran/prettier-config": "link:../prettier-config", | ||
"@typescript-eslint/parser": "^5.60.1", | ||
"eslint": "^8.43.0", | ||
"eslint-config-next": "^13.4.7", | ||
"eslint-config-prettier": "^8.8.0", | ||
"eslint-plugin-import": "npm:[email protected]", | ||
"prettier": "^2.8.8", | ||
"typescript": "^5.1.6" | ||
"@types/eslint-config-prettier": "^6.11.3", | ||
"@types/eslint__js": "^8.42.3", | ||
"@typescript-eslint/utils": "^8.8.0", | ||
"eslint": "^9.11.1", | ||
"eslint-config-prettier": "^9.1.0", | ||
"prettier": "^3.3.3", | ||
"rimraf": "^6.0.1", | ||
"typescript": "^5.6.2" | ||
}, | ||
"peerDependencies": { | ||
"eslint": "^8.0.0", | ||
"eslint-plugin-import": "npm:[email protected]", | ||
"prettier": "^2.7.1", | ||
"typescript": "^4.8.4" | ||
}, | ||
"eslintConfig": { | ||
"extends": [ | ||
"./.eslintrc.js" | ||
] | ||
"eslint": ">= 9", | ||
"prettier": ">= 2" | ||
}, | ||
"prettier": "@hkamran/prettier-config", | ||
"publishConfig": { | ||
|
Oops, something went wrong.