1. eslint-config-digitalbazaar
Digital Bazaar's eslint rules
eslint-config-digitalbazaar
Package: eslint-config-digitalbazaar
Created by: digitalbazaar
Last modified: Fri, 19 May 2023 04:04:41 GMT
Version: 5.0.1
License: BSD-3-Clause
Downloads: 3,623
Repository: https://github.com/digitalbazaar/eslint-config-digitalbazaar

Install

npm install eslint-config-digitalbazaar
yarn add eslint-config-digitalbazaar

eslint-config-digitalbazaar

This package provides eslint rules used by Digital Bazaar as a set of extendable shared configs.

There are 6 rule sets:

  1. eslint-config-digitalbazaar: Base rules for both node and the browser.
  2. eslint-config-digitalbazaar/import: Rules for es6 imports in the browser and node.
  3. eslint-config-digitalbazaar/jsdoc: Rules for JSDoc for both node and the browser.
  4. eslint-config-digitalbazaar/module: Rules for modules for both node and the browser.
  5. eslint-config-digitalbazaar/vue: Rules for Vue 2 projects and browser only.
  6. eslint-config-digitalbazaar/vue3: Rules for Vue 3 projects and browser only.

Installation

If you do not have eslint installed:

npm i -D eslint
npm i -D eslint-config-digitalbazaar

To start an eslint config file:

npx eslint --init

or rename a template from the templates dir

cp node_modules/eslint-config-digitalbazaar/templates/node.js ./.eslintrc.cjs

Usage

All rules can be accessed via the shorthand digitalbazaar
or using the full module name eslint-config-digitalbazaar.

Eslint's documentation on shareable configs can be found here.

Example .eslintrc.cjs root setup:

 module.exports = {
  root: true,
  // using full module name
  extends: ['eslint-config-digitalbazaar']
}

Imports

To use the import rules you need to install eslint-plugin-import:

npm i -D eslint-plugin-import

Example .eslintrc.cjs import setup:

 module.exports = {
  extends: ['digitalbazaar/import']
}

JSDoc

To use the JSDoc rules you will need to install eslint-plugin-jsdoc:

npm i -D eslint-plugin-jsdoc

Example .eslintrc.cjs JSDoc setup:

 module.exports = {
  // only the JSDoc rules and any rules in parent dirs
  extends: ['digitalbazaar/jsdoc']
}

Modules

To use ES module code rather than CommonJS, you will need to install eslint-plugin-unicorn:

npm i -D eslint-plugin-unicorn

Example .eslintrc.cjs ESM setup:

 module.exports = {
  // only the module rules and any rules in parent dirs
  extends: ['digitalbazaar/module']
}

Vue 2

To use the Vue 2 rules you will need to install eslint-plugin-vue:

npm i -D eslint-plugin-vue

Example .eslintrc.cjs Vue setup:

 module.exports = {
  // only the vue rules and any rules in parent dirs
  extends: ['digitalbazaar/vue']
}

For command line use you may need to explicitly enable linting .vue
files
.

Vue 3

To use the Vue 3 rules you will need to install eslint-plugin-vue:

npm i -D eslint-plugin-vue

Example .eslintrc.cjs Vue setup:

 module.exports = {
  // only the vue3 rules and any rules in parent dirs
  extends: ['digitalbazaar/vue3']
}

For command line use you may need to explicitly enable linting .vue
files
.

Composition

The rules do not depend on each other and are composable:

 module.exports = {
  extends: [
    'digitalbazaar',
    'digitalbazaar/jsdoc',
    'digitalbazaar/module'
    'digitalbazaar/vue3'
  ] // 4 rule sets in one file using shorthand.
}

The rules can also be used together via cascade configuration.

Other Rules

Other rules that are not included above but can be useful:

unicorn/prefer-node-protocol

Use node:module style for Node.js modules.

See unicorn/prefer-node-protocol.

Requires:

npm i -D eslint-plugin-unicorn

Rules:

   rules: {
    'unicorn/prefer-node-protocol': 'error'
  }

RELATED POST

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin