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

feat(eslint): add flat configs #114

wants to merge 14 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-community/[email protected] None +2 98.3 kB eslint-community-bot
npm/@eslint/[email protected] None 0 14.6 kB eslintbot
npm/@types/[email protected] None +3 256 kB types
npm/@types/[email protected] None +1 2.36 MB types
npm/@typescript-eslint/[email protected] Transitive: environment, filesystem +37 8.54 MB bradzacher, jameshenry
npm/@typescript-eslint/[email protected] Transitive: environment, filesystem +30 3.73 MB bradzacher, jameshenry
npm/@vitest/[email protected] Transitive: environment, filesystem +32 4.81 MB veritemm
npm/[email protected] Transitive: environment, eval, filesystem, unsafe +102 8.45 MB benmosher, jfmengels, ljharb
npm/[email protected] filesystem Transitive: environment +32 4.73 MB simenb
npm/[email protected] Transitive: eval +91 12 MB evcohen, jessebeach, lencioni, ...1 more
npm/[email protected] None +2 307 kB mxschmitt
npm/[email protected] None 0 0 B
npm/[email protected] Transitive: environment, eval, filesystem +113 8.48 MB ljharb, yannickcr
npm/[email protected] Transitive: environment, filesystem +44 3.97 MB testing-library-bot
npm/[email protected] Transitive: environment, eval, filesystem, unsafe +15 4.74 MB odspnpm
npm/[email protected] Transitive: environment, filesystem, shell, unsafe +67 6.82 MB sindresorhus
npm/[email protected] environment Transitive: eval, filesystem, shell, unsafe +84 10.4 MB eslintbot
npm/[email protected] None 0 176 kB sindresorhus
npm/[email protected] environment, filesystem, unsafe 0 7.7 MB prettier-bot
npm/[email protected] Transitive: environment, filesystem +32 4.48 MB jameshenry

🚮 Removed packages: npm/@typescript-eslint/[email protected], npm/@typescript-eslint/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], 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.*`
@@ -0,0 +1,10 @@
const importPlugin = require('eslint-plugin-import');

/** @type {improt('eslint').Linter.Config} */
Copy link

Choose a reason for hiding this comment

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

You have a typo here. import instead of improt

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