Skip to content

Commit

Permalink
fix: add workaround for eslint/eslint#3458
Browse files Browse the repository at this point in the history
  • Loading branch information
tgallacher committed Mar 21, 2022
1 parent 437e0cb commit 011210e
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 7 deletions.
3 changes: 2 additions & 1 deletion .npmignore
@@ -1,7 +1,8 @@
node_modules
.github
.commitlintrc.js
.eslintrc.js
.gitattributes
.gitignore
.prettierrc.js
yarn.lock
.github/
2 changes: 1 addition & 1 deletion index.js
Expand Up @@ -3,9 +3,9 @@ module.exports = {
"eslint:recommended",
"./import",
// "./javascript",
"./typescript",
"./storybook",
"./testing",
"./typescript",
// Note: must be last in list
// Note: This auto configures the eslint-config-prettier too!
"plugin:prettier/recommended",
Expand Down
3 changes: 2 additions & 1 deletion package.json
Expand Up @@ -42,14 +42,15 @@
"devDependencies": {
"@commitlint/cli": "^16.2.3",
"@commitlint/config-conventional": "^16.2.1",
"eslint": "^8.11.0",
"np": "^7.6.1",
"typescript": "^4.6.2"
},
"dependencies": {
"@rushstack/eslint-patch": "^1.1.1",
"@typescript-eslint/eslint-plugin": "^5.15.0",
"@typescript-eslint/parser": "^5.15.0",
"babel-eslint": "^10.1.0",
"eslint": "^8.11.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-import": "^2.25.4",
"eslint-plugin-prettier": "^4.0.0",
Expand Down
17 changes: 17 additions & 0 deletions patch/modern-module-resolution.js
@@ -0,0 +1,17 @@
// Workaround for https://github.com/eslint/eslint/issues/3458
//
// Use:
//
// Consumers of this config need to add the following to their `.eslintrc.js` file:
//
// ```js
// require('@tgallacher/eslint-config/patch/modern-module-resolution');
//
// module.exports = {
// extends: ["@tgallacher/eslint-config"],
// rules: {
// ...
// }
// }
// ```
require("@rushstack/eslint-patch/modern-module-resolution");
9 changes: 5 additions & 4 deletions typescript.js
@@ -1,15 +1,16 @@
const path = require("path");

const packageJsonPath = path.resolve(process.cwd(), "package.json");
const CWD = process.cwd();
const packageJsonPath = path.resolve(CWD, "package.json");
const packageJson = require(packageJsonPath); // eslint-disable-line import/no-dynamic-require

// note: Does not support the situation when the `nohoist` option is used
// @see https://classic.yarnpkg.com/blog/2018/02/15/nohoist/
const tsconfigPath = Array.isArray(packageJson.workspaces)
? packageJson.workspaces.map((workspacePath) =>
path.join(process.cwd(), workspacePath, "/tsconfig.json"),
path.join(CWD, workspacePath, "/tsconfig.json"),
)
: "tsconfig.json";
: path.join(CWD, "tsconfig.json");

module.exports = {
overrides: [
Expand All @@ -21,7 +22,7 @@ module.exports = {
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/recommended-requiring-type-checking",
],
plugins: ["@typescript-eslint", "eslint-plugin-tsdoc"],
plugins: ["@typescript-eslint/eslint-plugin", "eslint-plugin-tsdoc"],
parserOptions: {
project: tsconfigPath,
},
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Expand Up @@ -336,6 +336,11 @@
"@nodelib/fs.scandir" "2.1.5"
fastq "^1.6.0"

"@rushstack/eslint-patch@^1.1.1":
version "1.1.1"
resolved "https://registry.yarnpkg.com/@rushstack/eslint-patch/-/eslint-patch-1.1.1.tgz#782fa5da44c4f38ae9fd38e9184b54e451936118"
integrity sha512-BUyKJGdDWqvWC5GEhyOiUrGNi9iJUr4CU0O2WxJL6QJhHeeA/NVBalH+FeK0r/x/W0rPymXt5s78TDS7d6lCwg==

"@samverschueren/stream-to-observable@^0.3.0", "@samverschueren/stream-to-observable@^0.3.1":
version "0.3.1"
resolved "https://registry.yarnpkg.com/@samverschueren/stream-to-observable/-/stream-to-observable-0.3.1.tgz#a21117b19ee9be70c379ec1877537ef2e1c63301"
Expand Down

0 comments on commit 011210e

Please sign in to comment.