Skip to content

Conversation

@mrstork
Copy link
Contributor

@mrstork mrstork commented May 27, 2025

  • Use eslint setup from netlify/cli project as a base
  • Ignore any rules that are throwing errors, and look to resolve them once eslint is running as part of CI
  • Add lint workflow to CI

Part of FRB-1853

},
],

'@typescript-eslint/array-type': 'off',
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Technically a lot of these are auto-fixable, but I wanted to keep this PR as tightly-scoped to eslint changes as I could. Cleanup can be done in follow-ups.

@mrstork mrstork force-pushed the configure-eslint branch from 25fafc1 to 6ef8c5d Compare May 27, 2025 21:13
@mrstork mrstork changed the title Refresh project eslint setup ci: setup eslint workflow May 28, 2025
@mrstork mrstork force-pushed the configure-eslint branch 3 times, most recently from 0152f11 to 415e6e0 Compare May 28, 2025 12:14
@mrstork mrstork marked this pull request as ready for review May 28, 2025 12:15
@mrstork mrstork requested a review from a team as a code owner May 28, 2025 12:15
@mrstork mrstork force-pushed the configure-eslint branch 6 times, most recently from 81287e3 to 61f8015 Compare May 28, 2025 15:18
@mrstork mrstork force-pushed the configure-eslint branch from 61f8015 to a76e103 Compare May 28, 2025 15:19
@mrstork mrstork force-pushed the configure-eslint branch from a76e103 to 4533459 Compare May 28, 2025 15:21
serhalp
serhalp previously approved these changes May 28, 2025
Copy link
Member

@serhalp serhalp left a comment

Choose a reason for hiding this comment

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

Thank you! Feel free to choose how you want to divide up follow-ups in separate PRs

// @ts-check
import * as path from 'node:path'
import { fileURLToPath } from 'node:url'
import { includeIgnoreFile } from '@eslint/compat'
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
import { includeIgnoreFile } from '@eslint/compat'

This is a brand new repo, so I think it would be better to avoid using legacy compat stuff if we can help it. I'll leave another suggestion change below with how to do that.

...temporarySuppressions,

// Must be last
prettier,
Copy link
Member

Choose a reason for hiding this comment

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

https://eslint.org/docs/latest/use/configure/migration-guide#ignoring-files

It should just be taking the contents of .gitignore:

node_modules
.env
.DS_Store
.netlify
coverage
.eslintcache
.cache
.vscode
.fleet

and massaging it into an array of glob patterns (slightly different than ignore file patterns):

Suggested change
prettier,
prettier,
{
ignores: [
'.DS_Store',
'.cache/',
'.eslintcache',
'.netlify/',
'.vscode/',
'coverage/',
],
}

(I also removed some irrelevant/unused ones)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will aim to do this in a follow-up, ideally this is a programatically generated list

Copy link
Member

Choose a reason for hiding this comment

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

🤔 how could it be generated? in any case, I think the code suggestion I made should work as is


export default tseslint.config(
// Global rules and configuration
includeIgnoreFile(path.resolve(__dirname, '.gitignore')),
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
includeIgnoreFile(path.resolve(__dirname, '.gitignore')),

{
languageOptions: {
parserOptions: {
project: ['./tsconfig.base.json', './packages/*/tsconfig.json'],
Copy link
Member

Choose a reason for hiding this comment

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

It looks like this is actually dead code. The intent with a .base file is usually to be referenced in extends in each of the tsconfig.json files, but none of them do 😢.

Suggested change
project: ['./tsconfig.base.json', './packages/*/tsconfig.json'],
project: ['./packages/*/tsconfig.json'],

I'll fix that in my PR where I fix the issue with not type-checking test/ dirs.

Comment on lines +45 to +54
{
rules: {
'n/no-extraneous-import': 'off',
'n/no-extraneous-require': 'off',
'n/no-missing-import': 'off',
'n/no-missing-require': 'off',
'n/no-unpublished-import': 'off',
'n/no-unpublished-require': 'off',
},
},
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
{
rules: {
'n/no-extraneous-import': 'off',
'n/no-extraneous-require': 'off',
'n/no-missing-import': 'off',
'n/no-missing-require': 'off',
'n/no-unpublished-import': 'off',
'n/no-unpublished-require': 'off',
},
},

AFAICT this was some sort of tech debt shortcut specifically to the repo you copied this from that doesn't apply here. In fact I think these are the very rules that would have prevented undeclared dependencies.

Feel free to tackle this in a separate PR though!

Copy link
Member

Choose a reason for hiding this comment

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

... although ooh actually, let's keep the two no-unpublished rules off and leave a comment that that's covered by publint

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Marking this as a follow-up item

Comment on lines +60 to +61
// `interface` and `type` have different use cases, allow both
'@typescript-eslint/consistent-type-definitions': 'off',
Copy link
Member

Choose a reason for hiding this comment

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

😶 For the record I disagree, but I know this is someone else's copy-pasted opinion and I won't bother elaborating—this isn't worth bikeshedding on, so leaving the rule off to enforce nothing seems reasonable.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Feel free to remove in a follow-up!

"forceConsistentCasingInFileNames": true,
"strict": true,
"skipLibCheck": true,
"typeRoots": ["node_modules/@types", "types"]
Copy link
Member

Choose a reason for hiding this comment

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

if you're deleting this, please also delete packages/headers/types/.gitkeep!

@mrstork mrstork enabled auto-merge (squash) May 28, 2025 21:02
@mrstork mrstork merged commit b4cbcea into main May 28, 2025
10 checks passed
@mrstork mrstork deleted the configure-eslint branch May 28, 2025 21:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants