Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue with eslint v8 + jest #23

Merged
merged 4 commits into from
Dec 29, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "eslint-plugin-ft-flow",
"description": "Flowtype linting rules for ESLint by flow-typed",
"version": "1.1.0",
"version": "1.1.1-alpha-0",
"license": "MIT",
"main": "./dist/index.js",
"repository": {
Expand Down Expand Up @@ -30,7 +30,7 @@
"@babel/eslint-parser": "^7.16.5",
"@babel/node": "^7.15.8",
"@babel/plugin-syntax-flow": "^7.16.5",
"@babel/plugin-syntax-jsx": "^7.16.0",
"@babel/plugin-syntax-jsx": "^7.16.5",
"@babel/plugin-transform-react-jsx": "^7.16.5",
"@babel/preset-env": "^7.16.5",
"@babel/preset-flow": "^7.16.0",
Expand All @@ -42,11 +42,11 @@
"eslint-config-airbnb": "^19.0.2",
"eslint-config-bzc": "^1.0.5",
"eslint-plugin-fb-flow": "^0.0.4",
"eslint-plugin-ft-flow": "^1.0.1",
"eslint-plugin-ft-flow": "^1.1.0",
"eslint-plugin-import": "^2.25.3",
"eslint-plugin-jest": "^25.3.0",
"eslint-plugin-jest": "^25.3.2",
"eslint-plugin-jsx-a11y": "^6.5.1",
"eslint-plugin-react": "^7.27.1",
"eslint-plugin-react": "^7.28.0",
"eslint-plugin-react-hooks": "^4.3.0",
"eslint-plugin-testing-library": "^5.0.1",
"flow-bin": "^0.167.1",
Expand Down
19 changes: 15 additions & 4 deletions src/utilities/getBuiltinRule.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,26 @@
/**
* This is used to pull the definition of a builtin rule from eslint.
*
* Adopted from https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/rules/utils/get-builtin-rule.js.
*/
export const getBuiltinRule = (id) => {
// TODO: Remove this when we drop support for ESLint 7
const eslintVersion = require('eslint/package.json').version;
/* istanbul ignore next */
if (eslintVersion.startsWith('7.')) {
return require(`eslint/lib/rules/${id}`);
}

// TODO: This whole file and area should be looked at
// eslint-disable-next-line import/no-unresolved
return require('eslint/use-at-your-own-risk').builtinRules.get(id);
// In eslint 8 and beyond using https://nodejs.org/api/packages.html#subpath-exports
// eslint has defined public exported paths and has locked the rest of the
// directory as private.
//
// Though there is an issue when run with `jest` apparently where it does not support ESM.
// So we're gonna do it the same old fashion way if it crashes when requiring.
// ref: https://github.com/typescript-eslint/typescript-eslint/issues/4210#issuecomment-981203332
try {
// eslint-disable-next-line import/no-unresolved
return require('eslint/use-at-your-own-risk').builtinRules.get(id);
} catch (e) {
return require(`eslint/lib/rules/${id}`);
}
};
49 changes: 21 additions & 28 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -538,13 +538,6 @@
dependencies:
"@babel/helper-plugin-utils" "^7.8.0"

"@babel/plugin-syntax-jsx@^7.16.0":
version "7.16.0"
resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-jsx/-/plugin-syntax-jsx-7.16.0.tgz#f9624394317365a9a88c82358d3f8471154698f1"
integrity sha512-8zv2+xiPHwly31RK4RmnEYY5zziuF3O7W2kIDW+07ewWDh6Oi0dRq8kwvulRkFgt6DB97RlKs5c1y068iPlCUg==
dependencies:
"@babel/helper-plugin-utils" "^7.14.5"

"@babel/plugin-syntax-jsx@^7.16.5":
version "7.16.5"
resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-jsx/-/plugin-syntax-jsx-7.16.5.tgz#bf255d252f78bc8b77a17cadc37d1aa5b8ed4394"
Expand Down Expand Up @@ -1765,18 +1758,18 @@ eslint-config-airbnb-base@^15.0.0:
semver "^6.3.0"

eslint-config-airbnb@^19.0.2:
version "19.0.2"
resolved "https://registry.yarnpkg.com/eslint-config-airbnb/-/eslint-config-airbnb-19.0.2.tgz#3a1681e39b68cc6abeae58300014ed5d5706b625"
integrity sha512-4v5DEMVSl043LaCT+gsxPcoiIk0iYG5zxJKKjIy80H/D//2E0vtuOBWkb0CBDxjF+y26yQzspIXYuY6wMmt9Cw==
version "19.0.4"
resolved "https://registry.yarnpkg.com/eslint-config-airbnb/-/eslint-config-airbnb-19.0.4.tgz#84d4c3490ad70a0ffa571138ebcdea6ab085fdc3"
integrity sha512-T75QYQVQX57jiNgpF9r1KegMICE94VYwoFQyMGhrvc+lB8YF2E/M/PYDaQe1AJcWaEgqLE+ErXV1Og/+6Vyzew==
dependencies:
eslint-config-airbnb-base "^15.0.0"
object.assign "^4.1.2"
object.entries "^1.1.5"

eslint-config-bzc@^1.0.5:
version "1.0.5"
resolved "https://registry.yarnpkg.com/eslint-config-bzc/-/eslint-config-bzc-1.0.5.tgz#9bd5b8d294f075b953a50ef812c8ae5eebb02137"
integrity sha512-zXl1L2vhPzR28+QGbtqi+0h6/iDMcL1LTym3BRIquc/CfVOwr2o9cq0QfPquAs8ut+YZh/H4tFHrh0HCgV4UnA==
version "1.0.6"
resolved "https://registry.yarnpkg.com/eslint-config-bzc/-/eslint-config-bzc-1.0.6.tgz#5bc543da2dcd1ad064864dc28bbda6585ed643a9"
integrity sha512-BqhRZZWBSlplKydIzCa0SDoHEEZikeIZ4vggCUL4PE5j9vwR4VAVmKlT1AkdBJEXTyMC+r+XGgyISbja+rZVaQ==

eslint-import-resolver-node@^0.3.6:
version "0.3.6"
Expand All @@ -1800,10 +1793,10 @@ eslint-plugin-fb-flow@^0.0.4:
resolved "https://registry.yarnpkg.com/eslint-plugin-fb-flow/-/eslint-plugin-fb-flow-0.0.4.tgz#47fa51630a5620b3b03919194e783ddfc094fd5d"
integrity sha512-VWRoULiRkYqgeX4uCw2uIuu4v5DOhtWC+4fLM+qXX2mUtLf07znqhyTtxwIugnX8MgPczkaKmtDPrkuhvFmAoA==

eslint-plugin-ft-flow@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/eslint-plugin-ft-flow/-/eslint-plugin-ft-flow-1.0.1.tgz#9188c01396b1cbf91f3e80c40fac619d6d8f8ca9"
integrity sha512-iRMHqeUph+uxBCyKeUhGa63t12U/ID6JWul//DdyuFkjXbYvC+NRiP9kiQnPflInFcO+kze+pgMOcBik9uTUig==
eslint-plugin-ft-flow@^1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/eslint-plugin-ft-flow/-/eslint-plugin-ft-flow-1.1.0.tgz#bc41e242b26e542c9eb23280eacae933a43f7447"
integrity sha512-Z1MVInDFYHV66Ok0dA+jR7fiHLCYY8eDl0z8yiQ/wAXkmfOJ8fEuHeFvx+z5Ykt3IojhWrmLKkDbC/KDj7FCQw==
dependencies:
lodash "^4.17.21"
string-natural-compare "^3.0.1"
Expand All @@ -1827,10 +1820,10 @@ eslint-plugin-import@^2.25.3:
resolve "^1.20.0"
tsconfig-paths "^3.11.0"

eslint-plugin-jest@^25.3.0:
version "25.3.0"
resolved "https://registry.yarnpkg.com/eslint-plugin-jest/-/eslint-plugin-jest-25.3.0.tgz#6c04bbf13624a75684a05391a825b58e2e291950"
integrity sha512-79WQtuBsTN1S8Y9+7euBYwxIOia/k7ykkl9OCBHL3xuww5ecursHy/D8GCIlvzHVWv85gOkS5Kv6Sh7RxOgK1Q==
eslint-plugin-jest@^25.3.2:
version "25.3.2"
resolved "https://registry.yarnpkg.com/eslint-plugin-jest/-/eslint-plugin-jest-25.3.2.tgz#702801e37c502546fe4c4986888720f6eed3b129"
integrity sha512-1aPC7RRJkMCNgklHMDECw8fnzag3JBH53LaxmFkDTR7+PfMCO5V6f8XFRHoT2I+Fr4pVO9cPdRGlf7/haB2O5Q==
dependencies:
"@typescript-eslint/experimental-utils" "^5.0.0"

Expand All @@ -1857,10 +1850,10 @@ eslint-plugin-react-hooks@^4.3.0:
resolved "https://registry.yarnpkg.com/eslint-plugin-react-hooks/-/eslint-plugin-react-hooks-4.3.0.tgz#318dbf312e06fab1c835a4abef00121751ac1172"
integrity sha512-XslZy0LnMn+84NEG9jSGR6eGqaZB3133L8xewQo3fQagbQuGt7a63gf+P1NGKZavEYEC3UXaWEAA/AqDkuN6xA==

eslint-plugin-react@^7.27.1:
version "7.27.1"
resolved "https://registry.yarnpkg.com/eslint-plugin-react/-/eslint-plugin-react-7.27.1.tgz#469202442506616f77a854d91babaae1ec174b45"
integrity sha512-meyunDjMMYeWr/4EBLTV1op3iSG3mjT/pz5gti38UzfM4OPpNc2m0t2xvKCOMU5D6FSdd34BIMFOvQbW+i8GAA==
eslint-plugin-react@^7.28.0:
version "7.28.0"
resolved "https://registry.yarnpkg.com/eslint-plugin-react/-/eslint-plugin-react-7.28.0.tgz#8f3ff450677571a659ce76efc6d80b6a525adbdf"
integrity sha512-IOlFIRHzWfEQQKcAD4iyYDndHwTQiCMcJVJjxempf203jnNLUnW34AXLrV33+nEXoifJE2ZEGmcjKPL8957eSw==
dependencies:
array-includes "^3.1.4"
array.prototype.flatmap "^1.2.5"
Expand Down Expand Up @@ -1918,9 +1911,9 @@ eslint-visitor-keys@^3.0.0, eslint-visitor-keys@^3.1.0:
integrity sha512-yWJFpu4DtjsWKkt5GeNBBuZMlNcYVs6vRCLoCVEJrTjaSB6LC98gFipNK/erM2Heg/E8mIK+hXG/pJMLK+eRZA==

eslint@^8.4.1:
version "8.4.1"
resolved "https://registry.yarnpkg.com/eslint/-/eslint-8.4.1.tgz#d6531bbf3e598dffd7c0c7d35ec52a0b30fdfa2d"
integrity sha512-TxU/p7LB1KxQ6+7aztTnO7K0i+h0tDi81YRY9VzB6Id71kNz+fFYnf5HD5UOQmxkzcoa0TlVZf9dpMtUv0GpWg==
version "8.5.0"
resolved "https://registry.yarnpkg.com/eslint/-/eslint-8.5.0.tgz#ddd2c1afd8f412036f87ae2a063d2aa296d3175f"
integrity sha512-tVGSkgNbOfiHyVte8bCM8OmX+xG9PzVG/B4UCF60zx7j61WIVY/AqJECDgpLD4DbbESD0e174gOg3ZlrX15GDg==
dependencies:
"@eslint/eslintrc" "^1.0.5"
"@humanwhocodes/config-array" "^0.9.2"
Expand Down