Skip to content
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

feat(eslint): add flat configs #114

Open
wants to merge 15 commits into
base: canary
Choose a base branch
from
Open

feat(eslint): add flat configs #114

wants to merge 15 commits into from

Conversation

appano1
Copy link

@appano1 appano1 commented Nov 6, 2024

Resolves #73
Resolves #108

Related to #113

The goal of this PR is to ensure that developers meet no breaking changes.
Developers can apply the flat config as follows.

import vercel from '@vercel/style-guide/eslint/flat'
export default [
  ...vercel.configs.recommended,
  ...vercel.configs.typescript,
  ...vercel.configs.react,
  ...vercel.configs.next,
]

Due to certain characteristics of the flat config, it is not fully identical to the legacy config. @vercel/style-guide/eslint/browser and @vercel/style-guide/eslint/node might not be needed since developers can register them through the globals package. Instead, developers can continue to use the existing _base.js by applying configs.recommended.

import vercel from '@vercel/style-guide/eslint/flat'
export default [
  ...vercel.configs.recommended,
  {
    languageOptions: {
      globals: {
        ...globals.browser,
        ...globals.node,
      },
    },
  },
]

For @vercel/style-guide/eslint/jest, I’ve added jest-typescript.js to increase flexibility, as users may need to configure it within the flat config using options.files.

import vercel from '@vercel/style-guide/eslint/flat'
export default [
  { files: [/*path*/], ...vercel.configs.jest },
  vercel.configs['jest-typescript'],
]

Copy link

socket-security bot commented Nov 6, 2024

New and removed dependencies detected. Learn more about Socket for GitHub ↗︎

Package New capabilities Transitives Size Publisher
npm/@eslint/js@9.14.0 None 0 14.6 kB eslintbot
npm/@types/node@22.9.0 None +1 2.36 MB types
npm/@typescript-eslint/eslint-plugin@8.13.0 Transitive: environment, filesystem +37 8.54 MB bradzacher, jameshenry
npm/@typescript-eslint/parser@8.13.0 Transitive: environment, filesystem +30 3.73 MB bradzacher, jameshenry
npm/eslint-plugin-import@2.31.0 environment, filesystem, unsafe Transitive: eval +102 8.45 MB ljharb
npm/eslint-plugin-jest@28.9.0 filesystem Transitive: environment +32 4.73 MB simenb
npm/eslint-plugin-jsx-a11y@6.10.2 Transitive: eval +91 12 MB evcohen, jessebeach, lencioni, ...1 more
npm/eslint-plugin-playwright@2.0.0 None +2 307 kB mxschmitt
npm/eslint-plugin-react-hooks@5.0.0 None 0 0 B
npm/eslint-plugin-react@7.37.2 Transitive: environment, eval, filesystem +113 8.48 MB ljharb, yannickcr
npm/eslint-plugin-testing-library@6.4.0 Transitive: environment, filesystem +44 3.97 MB testing-library-bot
npm/eslint-plugin-tsdoc@0.3.0 Transitive: environment, eval, filesystem, unsafe +15 4.74 MB odspnpm
npm/eslint-plugin-unicorn@56.0.0 Transitive: environment, filesystem, shell, unsafe +67 6.82 MB sindresorhus
npm/eslint@9.14.0 environment Transitive: eval, filesystem, shell, unsafe +84 10.4 MB eslintbot
npm/globals@15.12.0 None 0 176 kB sindresorhus
npm/prettier@3.3.3 environment, filesystem, unsafe 0 7.7 MB prettier-bot

🚮 Removed packages: npm/@typescript-eslint/eslint-plugin@7.1.1, npm/@typescript-eslint/parser@7.1.1, npm/eslint-plugin-eslint-comments@3.2.0, npm/eslint-plugin-import@2.29.1, npm/eslint-plugin-jest@27.9.0, npm/eslint-plugin-jsx-a11y@6.8.0, npm/eslint-plugin-playwright@1.5.2, npm/eslint-plugin-react-hooks@4.6.0, npm/eslint-plugin-react@7.34.0, npm/eslint-plugin-testing-library@6.2.0, npm/eslint-plugin-tsdoc@0.2.17, npm/eslint-plugin-unicorn@51.0.1, npm/eslint-plugin-vitest@0.3.22, npm/eslint@8.57.0, npm/prettier@3.2.5

View full report↗︎

@@ -12,12 +12,12 @@ module.exports = {
'plugin:import/recommended',
'prettier',
require.resolve('./rules/best-practice'),
require.resolve('./rules/comments'),
Copy link
Author

Choose a reason for hiding this comment

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

I added a comments config and a unicorn config to ensure that only pure rules, excluding plugins, are in the rules directory.

@@ -1,6 +1,6 @@
module.exports = {
extends: [
'plugin:eslint-comments/recommended',
Copy link
Author

Choose a reason for hiding this comment

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

I replaced eslint-comment to @eslint-community/eslint-comments cause eslint-comment is not maintained for a while

* Fix no-unused-vars
* Add a rule for `*.config.mjs` files.
* Install `@types/node` for `process.*`
eslint/flat/import.js Outdated Show resolved Hide resolved
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.

supprt eslint 9 ESLint flat config support
2 participants