New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@madgex/eslint-config-madgex

Package Overview
Dependencies
Maintainers
15
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@madgex/eslint-config-madgex

Madgex ESLint config - based on eslint-config-airbnb

  • 1.2.3
  • npm
  • Socket score

Version published
Weekly downloads
216
increased by44%
Maintainers
15
Weekly downloads
 
Created
Source

Overview

This module allows us to have a common set of rules across multiple code repositories, without having to copy/paste those rules everywhere. See "ESLint's Sharable Configs article" for more details.

Adopting almost all of the popular AirBnB Style Guide, we have tweaked some of the rules and added support for the popular Prettier code formatting tool.

NOTE: Bitbucket markdown formatting is really bad, it breaks the npm command in step 1. View source to see the un-mangled line.

Installation

  1. Run this command in your node project to install everything needed by the config:

    npx install-peerdeps --dev @madgex/eslint-config-madgex
    
  2. You can see in your package.json there are now a big list of devDependencies.

  3. Create an .eslintrc.js file in the root of the project and configure ESLint to use the Madgex ruleset by adding the following code to the .eslintrc.js file:

    module.exports = {
      extends: "@madgex/eslint-config-madgex"
    };
    
  4. Create an .prettierrc file in the root of the project. Add the following config to tell prettier to use the same formatting rules as ESLint:

    {
      "useTabs": false,
      "tabWidth": 2,
      "printWidth": 120,
      "singleQuote": true,
      "trailingComma": "es5",
      "bracketSpacing": true,
      "arrowParens": "always",
      "endOfLine":"auto",
    }
    
  5. You can add two scripts to your package.json to lint and/or fix:

    "scripts": {
      "lint": "eslint .",
      "lint:fix": "eslint . --fix"
    },
    

Editor integration

VSCode provides good support for ESLint & Prettier via 2 plugins:

Open VSCode and press CMD + P to open the command bar, then install using:

ext install dbaeumer.vscode-eslint > ext install prettier-vscode

Other editor integrations for eslint can be found, as well as editor integrations for Prettier.

You can format your document as you work with this setting:

"editor.formatOnSave": true,

If working with Vue you can integrate linting with this user setting:

"eslint.validate": ["javascript", "javascriptreact", "vue"],


Ignoring files/dirs from linting

If you'd like to exclude certain files from ESLint then you can create a .eslintignore file too.

Package dependencies, i.e. what comes with it this module

  • eslint
  • eslint-config-airbnb-base
  • eslint-config-prettier
  • eslint-plugin-import
  • eslint-plugin-promise
  • eslint-plugin-prettier
  • prettier

What's different from AirBnB

We disable these:

no-debugger - allow devs to use the debugger statement in development, only trigger a warning if the NODE_ENV is production. no-console - allow console logging. no-plusplus - allow devs to use the ++ and -- unary operators. linebreak-style - due to working in a cross-platform environment, allow Unix and Windows line feeds.

Alter this setting:

arrow-body-style - for readability, always require braces in arrow functions. This can often be auto-fixed by eslint.

Adding linting to your package.json

Add these two lines to your package.json scripts to add the npm linting scripts. Run with npm run lint and npm run lint-fix.

"lint": "eslint .",
"lint-fix": "eslint . --fix"

FAQs

Package last updated on 17 Jan 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc