Skip to content

Latest commit

 

History

History
134 lines (97 loc) · 5.68 KB

File metadata and controls

134 lines (97 loc) · 5.68 KB

Creedengo-JS

An ESLint plugin which provides JavaScript and TypeScript rules of the Creedengo project.

👉 See creedengo-javascript README to have more information.

🚀 Getting started

Installation

You'll need to install ESLint (v7+) and this plugin:

# yarn
yarn add -D eslint @creedengo/eslint-plugin
# npm
npm install -D eslint @creedengo/eslint-plugin

You are using TypeScript? You will also need to install typescript-eslint to enable our rules.
Follow this official guide to install it in a few steps.

Are you working with a GitHub Packages registry?

The plugin is also available from GitHub npm registry under "green-code-initiative" scope:

# yarn
yarn add -D eslint @green-code-initiative/creedengo-eslint-plugin
# npm
npm install -D eslint @green-code-initiative/creedengo-eslint-plugin

Enable plugin with recommended configuration

ESLint Flat Configuration (eslint.config.js)

Add @creedengo "flat/recommended" configuration to your eslint.config.js:

import creedengo from "@creedengo/eslint-plugin";

export default [
  /* other eslint configurations */
  creedengo.configs["flat/recommended"],
];

ESLint deprecated legacy configuration (.eslintrc)

For legacy ESLint versions using the deprecated .eslintrc file, add the @creedengo "recommended" configuration to the extends array :

{
  "extends": ["plugin:@creedengo/recommended"]
}

Enable specific rules

ESLint Flat configuration (eslint.config.js)

Add the creedengo plugin configuration to your eslint.config.js and select the rules to activate:

import creedengo from "@creedengo/eslint-plugin";

export default [
  /* other eslint configurations */
  {
    plugins: { "@creedengo": creedengo },
    rules: {
      "@creedengo/no-multiple-access-dom-element": "error",
    },
  },
];

ESLint deprecated legacy configuration (.eslintrc)

If your project uses a legacy ESLint version, it may use as well the now deprecated .eslintrc file. In such case, add @creedengo to the plugins array, potentially followed by rules specific configurations:

{
  "plugins": ["@creedengo"],
  "rules": {
    "@creedengo/no-multiple-access-dom-element": "error",
  },
}

⚙ Configs

Name
flat/recommended
recommended

🔨 Rules

⚠️ Configurations set to warn in.
✅ Set in the flat/recommended configuration.
✅ Set in the recommended configuration.

Name Description ⚠️
avoid-autoplay Avoid autoplay for videos and audio content
avoid-brightness-override Should avoid to override brightness
avoid-css-animations Avoid usage of CSS animations
avoid-high-accuracy-geolocation Avoid using high accuracy geolocation in web applications
avoid-keep-awake Avoid screen keep awake
limit-db-query-results Should limit the number of returns for a SQL query
no-empty-image-src-attribute Disallow usage of image with empty source attribute
no-import-all-from-library Should not import all from library
no-multiple-access-dom-element Disallow multiple access of same DOM element
no-multiple-style-changes Disallow multiple style changes at once
no-torch Should not programmatically enable torch mode
prefer-collections-with-pagination Prefer API collections with pagination
prefer-lighter-formats-for-image-files Prefer lighter formats for image files
prefer-shorthand-css-notations Encourage usage of shorthand CSS notations
provide-print-css Enforce providing a print stylesheet

🛒 Distribution

You can follow changelog on GitHub Releases page.