diff --git a/.npmignore b/.npmignore index 70deaf6..876892b 100644 --- a/.npmignore +++ b/.npmignore @@ -1,7 +1,8 @@ +node_modules +.github .commitlintrc.js .eslintrc.js .gitattributes .gitignore .prettierrc.js yarn.lock -.github/ diff --git a/index.js b/index.js index 7caee60..80fc0e8 100644 --- a/index.js +++ b/index.js @@ -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", diff --git a/package.json b/package.json index f345dae..fe513a1 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/patch/modern-module-resolution.js b/patch/modern-module-resolution.js new file mode 100644 index 0000000..1d38e20 --- /dev/null +++ b/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"); diff --git a/typescript.js b/typescript.js index a2cea66..c439716 100644 --- a/typescript.js +++ b/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: [ @@ -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, }, diff --git a/yarn.lock b/yarn.lock index e1b87cc..247fbf1 100644 --- a/yarn.lock +++ b/yarn.lock @@ -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"