Skip to content

Commit

Permalink
Add eslint-plugin-perfectionist and eslint-plugin-react-perf to t…
Browse files Browse the repository at this point in the history
…he base and `/react` configs, respectively (#20)
  • Loading branch information
mangs authored Sep 18, 2024
1 parent 7d7c647 commit 190a48d
Show file tree
Hide file tree
Showing 13 changed files with 94 additions and 48 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/publishWorkflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v2
with:
bun-version: "1.1.17"
bun-version: "1.1.27"
- uses: mangs/simple-release-notes-action@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pullRequestWorkflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v2
with:
bun-version: "1.1.17"
bun-version: "1.1.27"
- run: bun install --frozen-lockfile
- run: bun run check:environment
- run: bun --bun run check:formatting
Expand Down
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# Changelog

## 2.1.0

- Add [`eslint-plugin-perfectionist`](https://github.com/azat-io/eslint-plugin-perfectionist) to the base configuration and all its dependent configurations
- Provides more robust and consistent alphabetical sorting features than what ESLint provides by default
- All rules are auto-fixable
- Its rules replace rules `import/order`, `sort-keys`, and `sort-vars`
- Add [`eslint-plugin-react-perf`](https://github.com/cvazac/eslint-plugin-react-perf) to the `/react` configuration and all its dependent configurations
- Provides performance-related checks to prevent code that causes performance problems
- Upgrade dependencies to latest versions
- Upgrade Bun version from `1.1.17` to `1.1.27`

## 2.0.3

- Upgrade dependencies to latest versions
Expand Down
Binary file modified bun.lockb
Binary file not shown.
35 changes: 24 additions & 11 deletions lib/eslintBaseConfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@
"plugins": [
"eslint-plugin-eslint-comments",
"eslint-plugin-import",
"eslint-plugin-perfectionist",
"eslint-plugin-regexp",
"eslint-plugin-unicorn"
],
"extends": [
"eslint-config-airbnb-base",
"plugin:eslint-comments/recommended",
"plugin:import/recommended",
"plugin:perfectionist/recommended-alphabetical-legacy",
"plugin:regexp/recommended",
"plugin:unicorn/recommended"
],
Expand All @@ -33,25 +35,36 @@
"import/group-exports": "error",
"import/no-default-export": "error",
"import/no-unresolved": ["error", { "caseSensitiveStrict": true }],
"import/order": [
"import/order": "off",
"import/prefer-default-export": "off",
"no-console": "error",
"no-restricted-syntax": "off",
"no-use-before-define": ["error", { "functions": false }],
"perfectionist/sort-imports": [
"error",
{
"environment": "node",
"groups": [
["side-effect", "side-effect-style"],
["builtin", "external"],
["index", "internal", "parent", "sibling", "unknown"],
["type"],
["object"]
],
"newlines-between": "always"
"object",
[
"builtin-type",
"external-type",
"index-type",
"internal-type",
"parent-type",
"sibling-type",
"type"
],
"style"
]
}
],
"import/prefer-default-export": "off",
"no-console": "error",
"no-restricted-syntax": "off",
"no-use-before-define": ["error", { "functions": false }],
"perfectionist/sort-named-exports": ["error", { "groupKind": "values-first" }],
"perfectionist/sort-named-imports": ["error", { "groupKind": "values-first" }],
"require-await": "error",
"sort-keys": "error",
"sort-vars": "error",
"unicorn/filename-case": ["error", { "case": "camelCase" }],
"unicorn/numeric-separators-style": ["error", { "number": { "minimumDigits": 0 } }],
"unicorn/relative-url-style": ["error", "always"],
Expand Down
27 changes: 23 additions & 4 deletions lib/eslintBunConfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,31 @@
"globals": {
"Bun": "readonly"
},
"settings": {
"import/core-modules": ["bun", "bun:jsc", "bun:sql", "bun:sqlite", "bun:test"]
},
"rules": {
"n/no-unsupported-features/es-builtins": "off",
"n/no-unsupported-features/es-syntax": "off",
"n/no-unsupported-features/node-builtins": "off"
"n/no-unsupported-features/node-builtins": "off",
"perfectionist/sort-imports": [
"error",
{
"environment": "bun",
"groups": [
["side-effect", "side-effect-style"],
["builtin", "external"],
["index", "internal", "parent", "sibling", "unknown"],
"object",
[
"builtin-type",
"external-type",
"index-type",
"internal-type",
"parent-type",
"sibling-type",
"type"
],
"style"
]
}
]
}
}
3 changes: 2 additions & 1 deletion lib/eslintReactConfig.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{
"plugins": ["eslint-plugin-jsx-a11y"],
"plugins": ["eslint-plugin-jsx-a11y", "eslint-plugin-react-perf"],
"extends": [
"eslint-config-airbnb",
"airbnb/hooks",
"plugin:jsx-a11y/recommended",
"plugin:react-perf/recommended",
"./eslintBaseConfig.json"
],
"env": {
Expand Down
30 changes: 16 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@babbel/eslint-config",
"version": "2.0.3",
"version": "2.1.0",
"author": "Eric L. Goldstein <[email protected]>",
"description": "Hierarchical ESLint configuration collection that intends to be simple to use, layered, and shared with others",
"keywords": [
Expand All @@ -10,7 +10,7 @@
"engines": {
"node": "^18.18.0 || >=20.0.0"
},
"packageManager": "[email protected].17",
"packageManager": "[email protected].27",
"exports": {
".": "./lib/eslintBaseConfig.json",
"./browser": "./lib/eslintBrowserConfig.json",
Expand Down Expand Up @@ -53,30 +53,32 @@
"eslint-config-airbnb-base": "15.0.0",
"eslint-config-airbnb-typescript": "18.0.0",
"eslint-config-prettier": "9.1.0",
"eslint-plugin-compat": "6.0.0",
"eslint-plugin-compat": "6.0.1",
"eslint-plugin-eslint-comments": "3.2.0",
"eslint-plugin-import": "2.29.1",
"eslint-plugin-jest": "28.7.0",
"eslint-plugin-import": "2.30.0",
"eslint-plugin-jest": "28.8.3",
"eslint-plugin-jest-dom": "5.4.0",
"eslint-plugin-jest-formatting": "3.1.0",
"eslint-plugin-jsdoc": "50.0.0",
"eslint-plugin-jsx-a11y": "6.9.0",
"eslint-plugin-jsdoc": "50.2.3",
"eslint-plugin-jsx-a11y": "6.10.0",
"eslint-plugin-n": "17.10.2",
"eslint-plugin-perfectionist": "3.6.0",
"eslint-plugin-playwright": "1.6.2",
"eslint-plugin-react-perf": "3.3.2",
"eslint-plugin-regexp": "2.6.0",
"eslint-plugin-security": "3.0.1",
"eslint-plugin-unicorn": "55.0.0"
},
"devDependencies": {
"@mangs/bun-utils": "2.30.1",
"@playwright/test": "1.46.0",
"@types/aws-lambda": "8.10.143",
"@types/node": "22.1.0",
"@types/react": "18.3.3",
"@mangs/bun-utils": "2.32.0",
"@playwright/test": "1.47.1",
"@types/aws-lambda": "8.10.145",
"@types/node": "22.5.5",
"@types/react": "18.3.6",
"@types/react-dom": "18.3.0",
"eslint": "8.57.0",
"eslint": "8.57.1",
"jest": "29.7.0",
"preact": "10.23.1",
"preact": "10.24.0",
"prettier": "3.3.3",
"prop-types": "15.8.1",
"react": "18.3.1",
Expand Down
24 changes: 12 additions & 12 deletions test/eslintBaseConfig/exampleBaseConfigEntrypoint.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -192,26 +192,26 @@ export {
anError,
buffer,
checkRegexRuleNoMissingGFlag,
checkUnicornRulePreferObjectFromEntries,
checkUnicornRuleRequireArrayJoinSeparator,
checkUnicornRulePreferStringStartsEndsWith,
checkUnicornRulePreferTypeError,
checkRegexRuleNoUselessDollarReplacements,
checkUnicornRulePreferOptionalCatchBinding,
checkUnicornRulePreferSetHas,
checkUnicornRulePreferSpread,
checkUnicornRuleExplicitLengthCheck,
checkUnicornRulePreferTernary,
checkUnicornRulePreferStringTrimStartEnd,
checkUnicornRulePreferRegexpTest,
checkUnicornRulePreferSwitch,
checkUnicornRulePreferArrayFind,
checkUnicornRulePreferArrayFlat,
checkUnicornRulePreferReflectApply,
checkUnicornRulePreferArrayFlatMap,
checkUnicornRulePreferAt,
checkUnicornRulePreferBlobReadingMethods,
checkUnicornRulePreferIncludes,
checkUnicornRulePreferObjectFromEntries,
checkUnicornRulePreferOptionalCatchBinding,
checkUnicornRulePreferReflectApply,
checkUnicornRulePreferRegexpTest,
checkUnicornRulePreferSetHas,
checkUnicornRulePreferSpread,
checkUnicornRulePreferStringStartsEndsWith,
checkUnicornRulePreferStringTrimStartEnd,
checkUnicornRulePreferSwitch,
checkUnicornRulePreferTernary,
checkUnicornRulePreferTypeError,
checkUnicornRuleRequireArrayJoinSeparator,
escapeSequence,
eventTarget,
fortyTwo,
Expand Down
2 changes: 1 addition & 1 deletion test/eslintReactConfig/exampleReactConfigEntrypoint.jsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// Code based on this example: https://react.dev/learn/tutorial-tic-tac-toe#what-are-you-building

// External Imports
import { createRoot } from 'react-dom/client';
import React from 'react';
import { createRoot } from 'react-dom/client';

// Internal Imports
import { Game } from './components/Game.jsx';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// Code based on this example: https://react.dev/learn/tutorial-tic-tac-toe#what-are-you-building

// External Imports
import { createRoot } from 'react-dom/client';
import React from 'react';
import { createRoot } from 'react-dom/client';

// Internal Imports
import { Game } from './components/Game.tsx';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// Internal Imports
import {
alternateRoute,
buildUncachedResponse,
defaultRoute,
alternateRoute,
} from './exampleTypescriptConfigImport.ts';

// Type Imports
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ function alternateRoute(apiGatewayEvent: APIGatewayProxyEvent): APIGatewayProxyS
}

// Module Exports
export { buildUncachedResponse, defaultRoute, alternateRoute };
export { alternateRoute, buildUncachedResponse, defaultRoute };

0 comments on commit 190a48d

Please sign in to comment.