Skip to content

docs: rework structure and improve flat config docs #8507

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

Merged
merged 3 commits into from
Feb 20, 2024

Conversation

bradzacher
Copy link
Member

@bradzacher bradzacher commented Feb 19, 2024

PR Checklist

Overview

This started as me just adding some more content to the docs and evolved into me restructuring things a bit. I was going to create a whole new page on what I was going to call "advanced config" - however I later decided that we don't really need to provide that information as it is ultimately well covered by the ESLint docs.

This PR:

  • fix up some minor authoring issues like incorrect links
  • add flat config variants to all the .eslintrc.js code samples.
  • add more examples and rework the typescript-eslint package docs.
  • updated typescript-eslint so that it uses both default and named exports.
  • clean up some incorrect docs and rewords some sections in the getting started guide
  • reorganise the pages a little. Previously most things were nested under the "Getting Started" header. Troubleshooting is now its own top-level header and I moved Configs to the Users section. This felt a little cleaner overall:
After Before
before image after image

@bradzacher bradzacher added the documentation Documentation ("docs") that needs adding/updating label Feb 19, 2024
@typescript-eslint
Copy link
Contributor

Thanks for the PR, @bradzacher!

typescript-eslint is a 100% community driven project, and we are incredibly grateful that you are contributing to that community.

The core maintainers work on this in their personal time, so please understand that it may not be possible for them to review your work immediately.

Thanks again!


🙏 Please, if you or your company is finding typescript-eslint valuable, help us sustain the project by sponsoring it transparently on https://opencollective.com/typescript-eslint.

Copy link

netlify bot commented Feb 19, 2024

Deploy Preview for typescript-eslint ready!

Name Link
🔨 Latest commit b4784bc
🔍 Latest deploy log https://app.netlify.com/sites/typescript-eslint/deploys/65d3feac4235390008f1d9da
😎 Deploy Preview https://deploy-preview-8507--typescript-eslint.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 98 (no change from production)
Accessibility: 100 (no change from production)
Best Practices: 92 (no change from production)
SEO: 98 (no change from production)
PWA: 80 (no change from production)
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

nx-cloud bot commented Feb 19, 2024

Copy link
Member

@JoshuaKGoldberg JoshuaKGoldberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔥 Looks great to me! Really liking the tweaked flow.

Some proofreading thoughts inline, nothing blocking IMO.

@JoshuaKGoldberg
Copy link
Member

Is the before/after comparison flipped in the PR description?

export default tseslint.config(
{
// config with just ignores is the replacement for `.eslintignore`
ignores: ['**/build/**', '**/dist/**', 'src/some/file/to/ignore.ts'],
},
Copy link

@pete-willard pete-willard Feb 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: I applaud the idea of starting the example config with a global ignore in the new flat convention but is this syntax correct? I'm getting an Object literal may only specify known properties, and 'ignores' does not exist in type 'ConfigWithExtends'. error while attempting to refactor my own config to use this exact same syntax.

Copy link
Member Author

@bradzacher bradzacher Feb 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pete-willard try updating to (the just released) v7.0.2 first which included a fix so that TS could resolve the types correctly.

This is correct and should work just fine - it's what we do internally:

{
// config with just ignores is the replacement for `.eslintignore`
ignores: [
'**/jest.config.js',
'**/node_modules/**',
'**/dist/**',
'**/fixtures/**',
'**/coverage/**',
'**/__snapshots__/**',
'**/.docusaurus/**',
'**/build/**',
// Files copied as part of the build
'packages/types/src/generated/**/*.ts',
// Playground types downloaded from the web
'packages/website/src/vendor',
// see the file header in eslint-base.test.js for more info
'packages/rule-tester/tests/eslint-base',
],
},

I picked it as a good example of "a separate config object" and thought it was a great example cos almost every codebase I've worked on has a .eslintignore!

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is a great example to have 👍🏻 I just double checked (reinstalled packages, rebooted VSCode) and I am on the .2 version and still getting that error. Mind you my config is a .js file with the @ts-check directive. I'll try more tinkering in the morning. Sorry for hijacking the comment 😅

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just tested this locally and it worked.
I also added a passing test case to our integration test:
https://github.com/typescript-eslint/typescript-eslint/blob/bjz-rework-docs-20240219/packages/integration-tests/fixtures/flat-config-types/eslint.config.js#L21-L24
(this test runs to typecheck and validate we haven't broken the most barebones setup).

If you can create an isolated repro repo and file an issue - I'm happy to help investigate :)

@bradzacher bradzacher merged commit 7c77b1b into main Feb 20, 2024
@bradzacher bradzacher deleted the bjz-rework-docs-20240219 branch February 20, 2024 01:39
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 28, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
documentation Documentation ("docs") that needs adding/updating
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Docs: Don’t suggest tseslint.config helper in Getting Started
3 participants