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 21 commits into
base: canary
Choose a base branch
from
Open

Conversation

appano1
Copy link

@appano1 appano1 commented Nov 6, 2024

⚠️ Breaking Changes

Requires ESLint ^8.57.0, or ^9.0.0 because of eslint-plugin-testing-library.
See also: eslint-plugin-testing-library v7 migration guide

Descriptions

Resolves #73
Resolves #108
Resolves #115

Related to #113

The goal of this PR is to minimize 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, updated, and removed dependencies detected. Learn more about Socket for GitHub ↗︎

Package New capabilities Transitives Size Publisher
npm/@babel/[email protected] 🔁 npm/@babel/[email protected] None +7 399 kB nicolo-ribaudo
npm/@eslint/[email protected] 🔁 npm/@eslint/[email protected] None 0 14.9 kB eslintbot, openjsfoundation
npm/@types/[email protected] 🔁 npm/@types/[email protected] None +1 2.37 MB types
npm/@typescript-eslint/[email protected] 🔁 npm/@typescript-eslint/[email protected] Transitive: environment, filesystem +39 7.94 MB bradzacher, jameshenry
npm/@typescript-eslint/[email protected] 🔁 npm/@typescript-eslint/[email protected] Transitive: environment, filesystem +30 2.93 MB bradzacher, jameshenry
npm/[email protected] 🔁 npm/[email protected] environment Transitive: eval +123 11.2 MB ljharb
npm/[email protected] 🔁 npm/[email protected] Transitive: environment +32 3.9 MB aaronabramov, jeysal, jsonp, ...6 more
npm/[email protected] 🔁 npm/[email protected] Transitive: eval +115 14.8 MB ljharb
npm/[email protected] 🔁 npm/[email protected] None +2 307 kB mxschmitt
npm/[email protected] 🔁 npm/[email protected] None 0 169 kB react-bot
npm/[email protected] 🔁 npm/[email protected] Transitive: environment, eval +125 11.1 MB ljharb, yannickcr
npm/[email protected] 🔁 npm/[email protected] Transitive: environment +33 3.59 MB testing-library-bot
npm/[email protected] 🔁 npm/[email protected] Transitive: environment, eval, filesystem, unsafe +15 4.74 MB odspnpm
npm/[email protected] 🔁 npm/[email protected] Transitive: environment, filesystem, shell, unsafe +67 6.82 MB sindresorhus
npm/[email protected] 🔁 npm/[email protected] Transitive: eval, shell, unsafe +83 10.7 MB eslintbot, openjsfoundation
npm/[email protected] None 0 177 kB sindresorhus
npm/[email protected] 🔁 npm/[email protected] Transitive: environment, filesystem +14 577 kB matzkoh
npm/[email protected] 🔁 npm/[email protected] None 0 7.7 MB prettier-bot

🚮 Removed packages: npm/[email protected], npm/[email protected]

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
@appano1 appano1 changed the title feat(eslint): add flat configs feat(eslint)!: add flat configs Dec 13, 2024
@RobinGiel
Copy link

Will this be merged anytime soon?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants