パッケージの詳細

eslint-config-digitalbazaar

digitalbazaar22.1kBSD-3-Clause5.2.0

Digital Bazaar's eslint rules

eslint, config

readme

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'
  }

更新履歴

eslint-config-digitalbazaar ChangeLog

5.2.0 - 2024-05-02

Changed

  • Ignore long URLs.

5.1.0 - 2024-05-02

Changed

  • Ingore SPDX-License-Identifier comment lengths. The spec requires one line which can be long when using multiple custom ids.

5.0.1 - 2023-05-19

Fixed

  • Fix peer dependency version.

5.0.0 - 2023-05-18

Changed

  • BREAKING: Update for eslint-plugin-jsdoc@42.
    • jsdoc/newline-after-description changed to jsdoc/tag-lines rule.
    • eslint-plugin-jsdoc >= 42 now required to support newer tag-lines options.
    • Add optional peer dependency version on eslint-plugin-jsdoc@42.

4.2.0 - 2022-11-28

Added

  • Add digitalbazaar/import preset. Uses eslint-plugin-import rules to check ES6 imports.

4.1.0 - 2022-07-20

Added

  • Add digitalbazaar/vue3 preset for Vue 3. Use digitalbazaar/vue for Vue 2.

Changed

  • Template cleanups.

4.0.1 - 2022-06-23

Changed

  • Use package.json files field.

4.0.0 - 2022-06-23

Added

3.0.0 - 2022-04-25

Changed

  • BREAKING: Update to eslint@8.
  • Use es2022 environment. Automatically sets ecmaVersion to 13 (2022).
  • Disable jsdoc/check-examples until eslint 8 related issue is fixed.

2.9.0 - 2022-04-22

Added

  • Use eslint-plugin-eslint-plugin to self check.
  • Add module preset.

Changed

  • Use "test" target to show file errors. This should be improved to do proper testing.
  • Use "lint" target to self check.

2.8.0 - 2021-04-12

Added

  • Add rule for dot-notation.

2.7.0 - 2021-04-12

Added

  • Add rule for one-var. Require multiple variable declarations per scope.

2.6.1 - 2020-09-11

Changed

  • Change peerDep for eslint to ^7.1.0 to ensure no-loss-of-precision support.
  • Change devDep for eslint to ^7.1.0 to ensure no-loss-of-precision support.

2.6.0 - 2020-09-10

Added

  • Add rule no-loss-of-precision: 'error'.
  • Add rule no-return-await: 'error'.
  • Add tests for no-loss-of-precision.

2.5.0 - 2020-05-20

Changed

  • Support eslint@7.

2.4.0 - 2020-04-29

Added

  • A rule to disallow yoda comparisons.
  • Add rule no-cond-assign.
  • Add rule valid-typeof.

2.3.0 - 2020-02-25

Added

  • Use 'brace-style' of '1tbs'.

2.2.0 - 2020-01-28

Changed

  • Update eslint dependencies:
    • Update version.
    • BREAKING: Remove from regular dependencies.
    • Add to devDependencies.
    • Add to peerDependencies.

2.1.0 - 2020-01-21

Added

  • Add no-dupe-key.

2.0.1 - 2019-08-19

Fixed

  • Fixed vue/mustache-interpolation-spacing rule style.

2.0.0 - 2019-03-19

Changed

  • BREAKING: JSDoc and Vue rules no longer depend on base rules. This means that one must explicitly include the base rules as required.
  • Update README to better explain the project.
  • Added a template for all the rules.

1.8.0 - 2019-03-12

Added

  • Linting rules for jsdocs.

1.7.0 - 2019-02-22

Added

  • Config templates that can be used to setup other modules.

1.6.0 - 2019-02-18

Changed

  • Add rules related to quote-props and template literals.

1.5.0 - 2019-02-08

Changed

  • Remove func-paren rule.
  • Add rule for single quotes.

1.4.0 - 2019-02-06

Changed

  • Set function-paren-newline rule so function paranthesis line breaks are consistent.
  • Set operator-linebreak so line breaks come after operators.

1.3.0 - 2019-02-05

Changed

  • Set vue/html-closing-bracket-newline rule to never for single and multiline.

1.2.0 - 2019-02-04

Changed

  • Make eslint a regular dependency.

1.1.0 - 2019-01-31

Changed

  • Update arrow function paren rule.
  • Add vue rules.

1.0.0 - 2019-01-30

  • See git history for changes previous to this release.