Skip to content

Commit

Permalink
feat(eslint-config): migrate to flat config
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh-Cena committed Apr 18, 2024
1 parent af43412 commit 370e5b1
Show file tree
Hide file tree
Showing 24 changed files with 3,326 additions and 3,199 deletions.
4 changes: 0 additions & 4 deletions .eslintignore

This file was deleted.

18 changes: 0 additions & 18 deletions .eslintrc

This file was deleted.

37 changes: 37 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// @ts-check

import jcRules from "eslint-config-jc";
import tseslint from "typescript-eslint";

export default tseslint.config(
...jcRules({
node: true,
react: true,
}),
{
ignores: [
"node_modules",
".yarn",
"**/dist/",
"**/build/",
"**/.docusaurus/",
],
},
{
languageOptions: {
parserOptions: {
project: true,
},
},
},
{
files: ["**/rules/**.js"],
rules: {
"sort-keys": "warn",
},
},
{
files: ["**/*.{js,mjs,cjs}"],
...tseslint.configs.disableTypeChecked,
},
);
19 changes: 5 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,19 @@
],
"scripts": {
"format": "prettier -w .",
"lint": "eslint \"**/*.{js,ts,jsx,tsx}\"",
"lint": "eslint .",
"spellcheck": "cspell \"**\" --no-progress",
"prepare": "husky install",
"build": "yarn workspaces foreach --no-private -t -v run build",
"publish": "yarn workspaces foreach --no-private npm publish"
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^7.0.1",
"@typescript-eslint/parser": "^7.0.1",
"cspell": "^8.4.0",
"eslint": "^8.56.0",
"eslint-plugin-header": "^3.1.1",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-jsx-a11y": "^6.8.0",
"eslint-plugin-n": "^16.6.2",
"eslint-plugin-react": "^7.33.2",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-regexp": "^2.2.0",
"cspell": "^8.7.0",
"eslint": "^8.57.0",
"husky": "^8.0.3",
"lint-staged": "^15.2.2",
"prettier": "^3.2.5",
"typescript": "~5.3.3"
"typescript": "~5.4.5"
},
"packageManager": "yarn@4.0.2"
"packageManager": "yarn@4.1.1"
}
21 changes: 0 additions & 21 deletions packages/eslint-config/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,6 @@ My personal coding style.

This is designed to be a replacement for `eslint:recommended`, `plugin:react-hooks/recommended`, `plugin:@typescript-eslint/recommended`, and of course, everyone's favorite `airbnb`. It also extends `prettier`.

## Dependencies

It requires the following plugins:

```json
{
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^5.10.2",
"@typescript-eslint/parser": "^5.10.2",
"eslint": "^8.8.0",
"eslint-plugin-header": "^3.1.1",
"eslint-plugin-import": "^2.25.3",
"eslint-plugin-jsx-a11y": "^6.5.1",
"eslint-plugin-react": "^7.27.0",
"eslint-plugin-react-hooks": "^4.3.0"
}
}
```

Although peer dependencies are evil, we can't self-install these plugins if the downstream user depends on a different version—the wrong one will be resolved.

## Configuration

ESLint config:
Expand Down
17 changes: 0 additions & 17 deletions packages/eslint-config/index.js

This file was deleted.

55 changes: 17 additions & 38 deletions packages/eslint-config/package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "eslint-config-jc",
"version": "4.3.0",
"version": "5.0.0",
"description": "Josh-Cena's personal coding style",
"main": "index.js",
"type": "module",
"repository": {
"type": "git",
"url": "git+https://github.com/jc-verse/js-style-guide.git",
Expand All @@ -23,48 +23,27 @@
},
"homepage": "https://jc-verse.github.io/js-style-guide/",
"exports": {
".": "./index.js",
"./base": "./rules/base.js",
"./regex": "./rules/regex.js",
"./import": "./rules/import.js",
"./node": "./rules/node.js",
"./jsx": "./rules/jsx.js",
"./react": "./rules/react.js",
"./react-class-comps": "./rules/react-class-comps.js",
"./react-prop-types": "./rules/react-prop-types.js",
"./typescript": "./rules/typescript.js",
"./typescript-typecheck": "./rules/typescript-typecheck.js"
".": "./dist/index.js"
},
"dependencies": {
"eslint-config-prettier": "^9.1.0"
"scripts": {
"build": "tsc",
"prepublishOnly": "yarn build"
},
"peerDependencies": {
"@typescript-eslint/eslint-plugin": "^7.0.1",
"@typescript-eslint/parser": "^7.0.1",
"eslint": "^8.56.0",
"dependencies": {
"@typescript-eslint/eslint-plugin": "^7.7.0",
"@typescript-eslint/parser": "^7.7.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-header": "^3.1.1",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-jsx-a11y": "^6.8.0",
"eslint-plugin-n": "^16.6.2",
"eslint-plugin-react": "^7.33.2",
"eslint-plugin-n": "^17.2.1",
"eslint-plugin-react": "^7.34.1",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-regexp": "^2.2.0"
"eslint-plugin-regexp": "^2.5.0",
"globals": "^15.0.0",
"typescript-eslint": "^7.7.0"
},
"peerDependenciesMeta": {
"eslint-plugin-header": {
"optional": true
},
"eslint-plugin-jsx-a11y": {
"optional": true
},
"eslint-plugin-n": {
"optional": true
},
"eslint-plugin-react": {
"optional": true
},
"eslint-plugin-react-hooks": {
"optional": true
}
"devDependencies": {
"@types/eslint-config-prettier": "^6.11.3"
}
}
Loading

0 comments on commit 370e5b1

Please sign in to comment.