11# Digital Bazaar ESLint Configs _ (@digitalbazaar/eslint-config )_
22
3- This package provides eslint rules used by Digital Bazaar as a set of extendable shared configs.
3+ This package provides eslint rules used by Digital Bazaar as a set of
4+ extendable shared configs.
45
56There are various core rule sets:
67- ` @digitalbazaar/eslint-config ` : Base rules for both node and browser code.
7- - ` @digitalbazaar/eslint-config/import ` : Rules for es6 imports in the browser and node code.
8- - ` @digitalbazaar/eslint-config/jsdoc ` : Rules for JSDoc for both node and browser code.
9- - ` @digitalbazaar/eslint-config/module ` : Rules for modules for both node and browser code.
8+ - ` @digitalbazaar/eslint-config/import ` : Rules for es6 imports in the browser
9+ and node code.
10+ - ` @digitalbazaar/eslint-config/jsdoc ` : Rules for JSDoc for both node and
11+ browser code.
12+ - ` @digitalbazaar/eslint-config/module ` : Rules for modules for both node and
13+ browser code.
1014- ` @digitalbazaar/eslint-config/vue3 ` : Rules for Vue 3 code.
1115
1216For common use cases, there are recommended configs, that load the core rules:
13- - ` @digitalbazaar/eslint-config/browser-recommended ` : Recommended rules for projects targeting web browsers.
14- - ` @digitalbazaar/eslint-config/node-recommended ` : Recommended rules for projects targeting node.
17+ - ` @digitalbazaar/eslint-config/browser-recommended ` : Recommended rules for
18+ projects targeting web browsers.
19+ - ` @digitalbazaar/eslint-config/node-recommended ` : Recommended rules for
20+ projects targeting node.
1521- ` @digitalbazaar/eslint-config/recommended ` : Common recommended rules.
16- - ` @digitalbazaar/eslint-config/universal-recommended ` : Recommended rules for projects targeting node and web browsers.
17- - ` @digitalbazaar/eslint-config/vue3-recommended ` : Recommended rules for projects targeting Vue 3.
22+ - ` @digitalbazaar/eslint-config/universal-recommended ` : Recommended rules for
23+ projects targeting node and web browsers.
24+ - ` @digitalbazaar/eslint-config/vue3-recommended ` : Recommended rules for
25+ projects targeting Vue 3.
1826
1927## Installation
2028
2129Requires:
2230- eslint v9
2331
24- If you do not have eslint installed:
2532``` sh
26- npm i -D eslint
33+ npm i -D eslint@9
2734npm i -D @digitalbazaar/eslint-config
2835```
2936
@@ -38,32 +45,17 @@ cp node_modules/@digitalbazaar/eslint-config/templates/node-recommended.js ./esl
3845
3946### Dependencies
4047
41- ** NOTE** : Currently the core and recommended configs may use dependencies that
42- need to be installed in a project ** manually** . This is to avoid requiring
43- dependencies in this package. A future version may provide alternative packages
44- with appropriate dependencies.
48+ ** NOTE** : The core and recommended configs use dependencies that are
49+ automatically installed. Depending on the configs you use, there may be extra
50+ plugin dependencies installed that are not needed. This adds some development
51+ bloat but simplifies usage and dependency management. A future version may
52+ provide alternative slimmer packages with appropriate dependencies.
4553
46- Dependencies for jsdoc checks:
47- ``` sh
48- npm i -D eslint-plugin-jsdoc
49- ```
50-
51- Dependencies for module and node checks:
52- ``` sh
53- npm i -D eslint-plugin-unicorn
54- ```
55-
56- Dependencies for vue checks:
57- ``` sh
58- npm i -D eslint-plugin-vue
59- ```
60-
61- Dependencies for vue checks when using ` legacy-peer-deps=true ` :
62- ``` sh
63- npm i -D vue-eslint-parser
64- ```
65-
66- Most recommended configs use the jsdoc and module checks and dependencies.
54+ Notable dependencies that are always installed:
55+ - [ ` eslint-plugin-jsdoc ` ] ( https://github.com/gajus/eslint-plugin-jsdoc )
56+ - [ ` eslint-plugin-unicorn ` ] ( https://github.com/sindresorhus/eslint-plugin-unicorn )
57+ - [ ` eslint-plugin-vue ` ] ( https://eslint.vuejs.org/ ) :
58+ - ` vue-eslint-parser ` (peer dependency of vue plugin)
6759
6860## Usage
6961
@@ -79,7 +71,7 @@ export default [
7971];
8072```
8173
82- Recommended configs (listed above ) exist for common use cases. They may be
74+ Recommended configs (listed earlier ) exist for common use cases. They may be
8375sufficient on their own when using the opinionated code and file style used by
8476Digital Bazaar for specific types of pacakges. However, they can also be mixed
8577and matched and modified as needed. Note that currently required plugin
@@ -107,15 +99,7 @@ export default [
10799
108100### JSDoc
109101
110- When using the recommended configs, or to use the JSDoc rules standalone, you
111- need to install
112- [ ` eslint-plugin-jsdoc ` ] ( https://github.com/gajus/eslint-plugin-jsdoc ) :
113-
114- ``` sh
115- npm i -D eslint-plugin-jsdoc
116- ```
117-
118- Example ` eslint.config.js ` JSDoc setup:
102+ Example ` eslint.config.js ` to explicitly use the JSDoc rules:
119103``` js
120104import config from ' @digitalbazaar/eslint-config'
121105import jsdocConfig from ' @digitalbazaar/eslint-config/jsdoc'
@@ -128,14 +112,7 @@ export default [
128112
129113### Modules
130114
131- When using the recommended configs, or to use the ES module rules standalone,
132- you need to install
133- [ ` eslint-plugin-unicorn ` ] ( https://github.com/sindresorhus/eslint-plugin-unicorn ) :
134- ``` sh
135- npm i -D eslint-plugin-unicorn
136- ```
137-
138- Example ` eslint.config.js ` ESM setup:
115+ Example ` eslint.config.js ` to explicitly use ES module rules:
139116``` js
140117import config from ' @digitalbazaar/eslint-config'
141118import moduleConfig from ' @digitalbazaar/eslint-config/module'
@@ -148,12 +125,7 @@ export default [
148125
149126### Vue 3
150127
151- To use the Vue 3 rules you will need to install [ ` eslint-plugin-vue ` ] ( https://eslint.vuejs.org/ ) :
152- ``` sh
153- npm i -D eslint-plugin-vue
154- ```
155-
156- Example ` eslint.config.js ` Vue setup:
128+ Example ` eslint.config.js ` to explicitly use Vue 3 rules:
157129``` js
158130import config from ' @digitalbazaar/eslint-config'
159131import vue3Config from ' @digitalbazaar/eslint-config/vue3'
@@ -184,7 +156,7 @@ export default [
184156
185157## Other Rules
186158
187- Other rules that are not included above but can be useful:
159+ Other rules that can be useful:
188160
189161### ` unicorn/prefer-node-protocol `
190162
@@ -193,12 +165,7 @@ Other rules that are not included above but can be useful:
193165
194166See [ ` unicorn/prefer-node-protocol ` ] ( https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-node-protocol.md ) .
195167
196- Requires:
197- ``` sh
198- npm i -D eslint-plugin-unicorn
199- ```
200-
201- Rules:
168+ Example ` eslint.config.js ` :
202169``` js
203170import config from ' @digitalbazaar/eslint-config'
204171
0 commit comments