Gathering detailed insights and metrics for @vercel/style-guide
Gathering detailed insights and metrics for @vercel/style-guide
Gathering detailed insights and metrics for @vercel/style-guide
Gathering detailed insights and metrics for @vercel/style-guide
npm install @vercel/style-guide
v6.0.0
Published on 05 Mar 2024
v6.0.0-canary.1
Published on 05 Mar 2024
v5.3.0-canary.8
Published on 05 Mar 2024
v5.3.0-canary.7
Published on 05 Mar 2024
v5.3.0-canary.6
Published on 05 Mar 2024
v5.3.0-canary.5
Published on 05 Mar 2024
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
1,281 Stars
115 Commits
37 Forks
36 Watching
3 Branches
80 Contributors
Updated on 26 Nov 2024
JavaScript (99.53%)
Shell (0.47%)
Cumulative downloads
Total Downloads
Last day
-13.7%
51,674
Compared to previous day
Last week
-2.2%
305,759
Compared to previous week
Last month
15.4%
1,337,788
Compared to previous month
Last year
496.2%
12,023,080
Compared to previous year
20
4
This repository is the home of Vercel's style guide, which includes configs for popular linting and styling tools.
The following configs are available, and are designed to be used together.
Please read our contributing guide before creating a pull request.
All of our configs are contained in one package, @vercel/style-guide
. To install:
1# If you use npm 2npm i --save-dev @vercel/style-guide 3 4# If you use pnpm 5pnpm i --save-dev @vercel/style-guide 6 7# If you use Yarn 8yarn add --dev @vercel/style-guide
Some of our ESLint configs require peer dependencies. We'll note those alongside the available configs in the ESLint section.
Note: Prettier is a peer-dependency of this package, and should be installed at the root of your project.
To use the shared Prettier config, set the following in package.json
.
1{ 2 "prettier": "@vercel/style-guide/prettier" 3}
Note: ESLint is a peer-dependency of this package, and should be installed at the root of your project.
See: https://eslint.org/docs/user-guide/getting-started#installation-and-usage
This ESLint config is designed to be composable.
The following base configs are available. You can use one or both of these
configs, but they should always be first in extends
:
@vercel/style-guide/eslint/browser
@vercel/style-guide/eslint/node
Note that you can scope configs, so that configs only target specific files.
For more information, see: Scoped configuration with overrides
.
The following additional configs are available:
@vercel/style-guide/eslint/jest
@vercel/style-guide/eslint/jest-react
(includes rules for @testing-library/react
)@vercel/style-guide/eslint/next
(requires @next/eslint-plugin-next
to be installed at the same version as next
)@vercel/style-guide/eslint/playwright-test
@vercel/style-guide/eslint/react
@vercel/style-guide/eslint/typescript
(requires typescript
to be installed and additional configuration)@vercel/style-guide/eslint/vitest
You'll need to use
require.resolve
to provide ESLint with absolute paths, due to an issue around ESLint config resolution (see eslint/eslint#9188).
For example, use the shared ESLint config(s) in a Next.js project, set the
following in .eslintrc.js
.
1module.exports = { 2 extends: [ 3 require.resolve('@vercel/style-guide/eslint/browser'), 4 require.resolve('@vercel/style-guide/eslint/react'), 5 require.resolve('@vercel/style-guide/eslint/next'), 6 ], 7};
Some of the rules enabled in the TypeScript config require additional type
information, you'll need to provide the path to your tsconfig.json
.
For more information, see: https://typescript-eslint.io/docs/linting/type-linting
1const { resolve } = require('node:path'); 2 3const project = resolve(__dirname, 'tsconfig.json'); 4 5module.exports = { 6 root: true, 7 extends: [ 8 require.resolve('@vercel/style-guide/eslint/node'), 9 require.resolve('@vercel/style-guide/eslint/typescript'), 10 ], 11 parserOptions: { 12 project, 13 }, 14 settings: { 15 'import/resolver': { 16 typescript: { 17 project, 18 }, 19 }, 20 }, 21};
jsx-a11y
It's common practice for React apps to have shared components like Button
,
which wrap native elements. You can pass this information along to jsx-a11y
via the components
setting.
The below list is not exhaustive.
1module.exports = { 2 root: true, 3 extends: [require.resolve('@vercel/style-guide/eslint/react')], 4 settings: { 5 'jsx-a11y': { 6 components: { 7 Article: 'article', 8 Button: 'button', 9 Image: 'img', 10 Input: 'input', 11 Link: 'a', 12 Video: 'video', 13 }, 14 }, 15 }, 16};
overrides
ESLint configs can be scoped to include/exclude specific paths. This ensures that rules don't "leak" into places where those rules don't apply.
In this example, Jest rules are only being applied to files matching Jest's default test match pattern.
1module.exports = { 2 extends: [require.resolve('@vercel/style-guide/eslint/node')], 3 overrides: [ 4 { 5 files: ['**/__tests__/**/*.[jt]s?(x)', '**/?(*.)+(spec|test).[jt]s?(x)'], 6 extends: [require.resolve('@vercel/style-guide/eslint/jest')], 7 }, 8 ], 9};
By default, all TypeScript rules are scoped to files ending with .ts
and
.tsx
.
However, when using overrides, file extensions must be included or ESLint will
only include .js
files.
1module.exports = { 2 overrides: [ 3 { files: [`directory/**/*.[jt]s?(x)`], rules: { 'my-rule': 'off' } }, 4 ], 5};
This style guide provides multiple TypeScript configs. These configs correlate to the LTS Node.js versions, providing the appropriate lib
, module
, target
, and moduleResolution
settings for each version. The following configs are available:
Node.js Version | TypeScript Config |
---|---|
v16 | @vercel/style-guide/typescript/node16 |
v18 | @vercel/style-guide/typescript/node18 |
v20 | @vercel/style-guide/typescript/node20 |
To use the shared TypeScript config, set the following in tsconfig.json
.
1{ 2 "extends": "@vercel/style-guide/typescript/node16" 3}
The base TypeScript config is also available as @vercel/style-guide/typescript
which only specifies a set of general rules. You should inherit from this file when setting custom lib
, module
, target
, and moduleResolution
settings.
No vulnerabilities found.
No security vulnerabilities found.