-
Notifications
You must be signed in to change notification settings - Fork 27k
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
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
no-html-link-for-pages eslint rule uses cwd instead of project directory #26330
Comments
To be clear, explicitly setting the path like
works. But if possible, it would be great if the rule could automatically find the pages directory from the NextJS project root |
Hey @brandonchinn178, I'm currently working on something around this. Are you working from a monorepo? Or just a custom folder in a project? |
Yes, I'm in a monorepo |
Great, I think the solution in #27918 will help - but I'm not sure about auto-detecting, as that's more error-prone. Please let me know what you think. |
Looks great! Are there any other rules this is applicable for? Even if not, it's good/it makes sense to have this as a global setting. Is it possible to have it default to the location of the eslintrc file it's in? for my usecase, i wouldnt even need to set the setting then |
I don't think so, but I imagine there will be - and like you, I think it makes more sense to have this as a global setting. So the way we're rolling out our updated ESLint configs at Vercel is that we have a root config, and then use overrides to set any per-workspace settings. So everything is root-level in the monorepo. I'm guessing (correct me if I'm wrong) that you're running ESLint from the root of the repo, but the ESLint config file is within the workspace. What happens if you run the ESLint command from within the workspace? I imagine that might work because ESLint's context would then be that workspace. |
Yes, that's correct.
It would probably work, but I think it would break the dev workflow, or at least complicate the scripts that run eslint. |
Yes, I understand. I'll give it thought and see if there are any smart ways to automate this in future. |
## Introduction This PR enables setting a `rootDir` for a Next.js project, and follows the same pattern used by [`@typescript-eslint/parser`](https://github.com/typescript-eslint/typescript-eslint/tree/master/packages/parser#parseroptionsproject). ## Details Previously, users had to pass paths to the rule itself. ```js module.exports = { rules: { "@next/next/no-html-link-for-pages": [ "error", // This could be a string, or array of strings. "/packages/my-app/pages", ], }, }; ``` With this PR, this has been simplified (the previous implementation still works as expected). ```js module.exports = { settings: { next: { rootDir: "/packages/my-app", }, }, rules: { "@next/next/no-html-link-for-pages": "error", }, }; ``` Further, this rule allows the use of globs, again aligning with `@typescript-eslint/parser`. ```js module.exports = { settings: { next: { // Globs rootDir: "/packages/*", rootDir: "/packages/{app-a,app-b}", // Arrays rootDir: ["/app-a", "/app-b"], // Arrays with globs rootDir: ["/main-app", "/other-apps/*"], }, }; ``` This enables users to either provide per-workspace configuration with overrides, or to use globs for situations like monorepos where the apps share a domain (micro-frontends). This doesn't solve, but improves #26330. ## Feature - [x] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR. - [x] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Documentation added - [ ] Telemetry added. In case of a feature if it's used or not. - [ ] Errors have helpful link attached, see `contributing.md` ## Documentation / Examples - [x] Make sure the linting passes
## Introduction This PR enables setting a `rootDir` for a Next.js project, and follows the same pattern used by [`@typescript-eslint/parser`](https://github.com/typescript-eslint/typescript-eslint/tree/master/packages/parser#parseroptionsproject). ## Details Previously, users had to pass paths to the rule itself. ```js module.exports = { rules: { "@next/next/no-html-link-for-pages": [ "error", // This could be a string, or array of strings. "/packages/my-app/pages", ], }, }; ``` With this PR, this has been simplified (the previous implementation still works as expected). ```js module.exports = { settings: { next: { rootDir: "/packages/my-app", }, }, rules: { "@next/next/no-html-link-for-pages": "error", }, }; ``` Further, this rule allows the use of globs, again aligning with `@typescript-eslint/parser`. ```js module.exports = { settings: { next: { // Globs rootDir: "/packages/*", rootDir: "/packages/{app-a,app-b}", // Arrays rootDir: ["/app-a", "/app-b"], // Arrays with globs rootDir: ["/main-app", "/other-apps/*"], }, }; ``` This enables users to either provide per-workspace configuration with overrides, or to use globs for situations like monorepos where the apps share a domain (micro-frontends). This doesn't solve, but improves vercel#26330. ## Feature - [x] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR. - [x] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Documentation added - [ ] Telemetry added. In case of a feature if it's used or not. - [ ] Errors have helpful link attached, see `contributing.md` ## Documentation / Examples - [x] Make sure the linting passes
It seems that we don't have anything actionable now (it's not really a bug). |
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
What version of Next.js are you using?
11.0.1-canary.4
What version of Node.js are you using?
14.15.5
What browser are you using?
Chrome
What operating system are you using?
macOS
How are you deploying your application?
vercel
Describe the Bug
I have a project with separate directories for client and server (my project has two servers: nextjs and graphql), with the path
client/next.config.js
. Running eslint from the root directory using the next eslint plugin showsThis happens whether I add the plugin in the top-level
.eslintrc
or in theclient/.eslintrc
Expected Behavior
Rule should look for
pages
directory in the same directory asnext.config.js
(or some other marker of a NextJS project). Alternatively, rule should look forpages
directory in the same directory as the.eslintrc
file it's added in.To Reproduce
Create a NextJS project in a subdirectory and run linting from the parent directory.
The text was updated successfully, but these errors were encountered: