Skip to content

Commit

Permalink
support CRA5 in eslint-config (#128)
Browse files Browse the repository at this point in the history
  • Loading branch information
macfarlandian authored Jan 6, 2023
1 parent 7ac4190 commit d6cbbd9
Show file tree
Hide file tree
Showing 4 changed files with 3,143 additions and 102 deletions.
10 changes: 10 additions & 0 deletions packages/eslint-config/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,16 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## v3.0.0

## Added
- support for applications using `react-scripts` 5.x and ESLint 8.x
- overrides to some newly included rules based on existing usage

## Changed
- all updated to latest compatible versions
- all are now `dependencies` rather than `peerDependencies` to limit build noise and tedious installation process

## v2.0.0

### Added
Expand Down
20 changes: 17 additions & 3 deletions packages/eslint-config/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Recidiviz - a data platform for criminal justice reform
// Copyright (C) 2021 Recidiviz, Inc.
// Copyright (C) 2022 Recidiviz, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
Expand All @@ -19,7 +19,12 @@ module.exports = {
env: {
browser: true,
},
extends: ["react-app", "airbnb", "plugin:prettier/recommended"],
extends: [
"react-app",
"airbnb",
"airbnb/hooks",
"plugin:prettier/recommended",
],
ignorePatterns: ["node_modules/", "build/", "public/"],
plugins: ["simple-import-sort"],
rules: {
Expand Down Expand Up @@ -49,6 +54,11 @@ module.exports = {
},
],
"no-new": 1,
// the return value is harmless (it is ignored) and we use this pattern a lot in tests,
// in the form of one-line arrow functions. Would add unnecessary verbosity
"no-promise-executor-return": "off",
// "default" is restricted but we use that pattern a lot in index files
"no-restricted-exports": "off",
"no-restricted-imports": [
"error",
{
Expand Down Expand Up @@ -78,6 +88,8 @@ module.exports = {

// we are only targeting es5 environments so we don't have to pass 10
radix: ["error", "as-needed"],
// this rule has poor Typescript compatibility
"react/function-component-definition": "off",
// conflicts with prettier
"react/jsx-curly-newline": 0,
"react/jsx-filename-extension": ["error", { extensions: [".tsx", ".js"] }],
Expand All @@ -91,7 +103,7 @@ module.exports = {
{ declaration: false, assignment: false },
],
"simple-import-sort/imports": "error",
"simple-import-sort/exports": "error"
"simple-import-sort/exports": "error",
},
overrides: [
{
Expand All @@ -106,6 +118,8 @@ module.exports = {
"@typescript-eslint/no-shadow": "error",
"no-use-before-define": "off",
"@typescript-eslint/no-use-before-define": ["error"],
// common workaround for strict return types
"react/jsx-no-useless-fragment": ["error", { allowExpressions: true }],
// TypeScript makes these redundant
"react/prop-types": "off",
"react/require-default-props": "off",
Expand Down
32 changes: 15 additions & 17 deletions packages/eslint-config/package.json
Original file line number Diff line number Diff line change
@@ -1,26 +1,24 @@
{
"name": "@recidiviz/eslint-config",
"version": "2.0.0",
"version": "3.0.0",
"description": "Shared ESLint config for Recidiviz web applications",
"author": "Recidiviz <[email protected]>",
"main": "index.js",
"license": "GPL-3.0-only",
"dependencies": {
"eslint-config-airbnb": "^18.2.0",
"eslint-config-prettier": "^8.1.0",
"prettier": "^2.2.1"
},
"peerDependencies": {
"@typescript-eslint/parser": "^4.4.0",
"@typescript-eslint/eslint-plugin": "^4.4.0",
"eslint": ">=6",
"eslint-import-resolver-typescript": "^2.3.0",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-jsx-a11y": "^6.4.1",
"eslint-plugin-prettier": "^3.1.4",
"eslint-plugin-react": "^7.23.1",
"eslint-config-react-app": "^6.0.0",
"eslint-plugin-react-hooks": "^4.2.0",
"eslint-plugin-simple-import-sort": "^7.0.0"
"@typescript-eslint/eslint-plugin": "^5.46.0",
"@typescript-eslint/parser": "^5.46.0",
"eslint": "^8.2.0",
"eslint-config-airbnb": "19.0.4",
"eslint-config-prettier": "^8.5.0",
"eslint-config-react-app": "^7.0.1",
"eslint-import-resolver-typescript": "^3.5.2",
"eslint-plugin-import": "^2.25.3",
"eslint-plugin-jsx-a11y": "^6.5.1",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-react": "^7.28.0",
"eslint-plugin-react-hooks": "^4.3.0",
"eslint-plugin-simple-import-sort": "^8.0.0",
"prettier": "^2.8.1"
}
}
Loading

0 comments on commit d6cbbd9

Please sign in to comment.