Skip to content

IT-WIBRC/eslint-config-epsvue

Repository files navigation

eslint-config-epsvue

js-standard-style

NPM Unpacked Size NPM Version NPM Downloads NPM Downloads GA CI

These are my settings for ESLint, Prettier and Stylelint that you can use for Vuejs app

You might like them - or you might not. Don't worry you can always change them.

What do you need to know before using this

This version 1.1.0 use eslint version >= 9.0.0, this support only the nodejs versions above 18.18.0 same as stylelint 16 witch support node 18.12.0.

Warning

Make sure you upgrade to at least Node.js v18.18.0 when using ESLint v9.0.0. One important thing to double check is the Node.js version supported by your editor when using ESLint via editor integrations. If you are unable to upgrade, we recommend continuing to use ESLint v8.56.0 until you are able to upgrade Node.js. You can read it on the eslint's official documentation

Note

The current version doesn't support the legacy .eslintrc* configuration format. If ?you want to use this format, feel free to install this version v1.0.4

And you need to note that:

Note

If you want to know more about the new configurations, you can see the Key Differences between Configuration Formats

What it does

  • Lints JavaScript and TypeScript based on the latest standards
  • Fixes issues and formatting errors with Prettier
  • Lints + Fixes inside of html script tags
  • You can see all the rules here. You are very welcome to overwrite any of these settings, or just fork the entire thing to create your own.

Project setup

It's recommended you install this once per every project. ESLint used to have global configs, but no longer.

  1. Installation

      npm install -D eslint-config-epsvue
  2. Extend the eslint configuration

    create a file called eslint.config.mjs file in the root of your project. after copy this in the file:

    import pluginEpsVue from "eslint-plugin-epsvue";
    
    export default [...pluginEpsVue];
  3. Extend the stylelint configuration by adding this in the package.json

    "stylelint": {
        "extends": ["eslint-config-epsvue/stylelint"]
      }

    You can also extends it in your own .styelintrc.json file

    {
      "extends": ["eslint-config-epsvue/stylelint"]
    }
  4. You can add two scripts to your package.json to lint, lint fix, format and style css:

     "scripts": {
       "lint": "eslint .", // Detect errors
       "lint:fix": "eslint src/ --fix", //fix all resolvable eslint problems found starting from the base directory
       "format": "prettier src/ -w", // format code starting from the base directory
       "stylelint": "stylelint --aei '**/*.{css,vue,scss}'",
     },

Settings

If you'd like to overwrite eslint or prettier settings, you can add the rules in your .eslintrc file. The ESLint rules go directly under "rules".

import pluginEpsVue from "eslint-plugin-epsvue";

export default [
  ...pluginEpsVue,
  {
    rules: {
      "no-console": 2,
    },
  },
];

Prettier Rules

There are only 2 prettier rules included in my config - singleQuote: true and endOfLine: 'auto'.

If you want custom prettier options, it's recommended to create a .prettierrc file in your root directory like so:

{
  "singleQuote": true,
  "endOfLine": "auto",
  "tabWidth": 4
}

You can also put this in your EsLint config as a rule like so:

import pluginEpsVue from "eslint-plugin-epsvue";

export default [
  ...pluginEpsVue,
  {
    rules: {
      //... any eslint rules here
      "no-console": 2,
      "prettier/prettier": [
        "error",
        {
          singleQuote: true,
          endOfLine: "auto",
          tabWidth: 4,
        },
      ],
    },
  },
];

With VS Code

You should read this entire thing. Serious!

Once you have done one, or both, of the above installs. You probably want your editor to lint and fix for you. Here are the instructions for VS Code:

  • install eslint abd prettier extensions

  • If you use vetur, you need to do this to avoid some eslint issues Now we need to setup some VS Code settings via Code/FilePreferencesSettings. It's easier to enter these settings while editing the settings.json file, so click the Open (Open Settings) icon in the top right corner: Now we need to setup some VS Code settings via Code/FilePreferencesSettings. It's easier to enter these settings while editing the settings.json file, so click the Open (Open Settings) icon in the top right corner:

    add this :

     "vetur.validation.template": false,
     "vetur.validation.script": false,
     "vetur.validation.style": false,

With WSL

It should work as above.

With JetBrains Products (IntelliJ IDEA, WebStorm, RubyMine, PyCharm, PhpStorm, etc)

If you have previously configured ESLint to run via a File Watcher, turn that off.

If you choose Local / Per Project Install Above

  1. Open ESLint configuration by going to File > Settings (Edit > Preferences on Mac) > Languages & Frameworks > Code Quality Tools > ESLint (optionally just search settings for "eslint")
  2. Select Automatic ESLint Configuration
  3. Check Run eslint --fix on save

If you choose Global Install

The following steps are for a typical Node / ESLint global installtion. If you have a customized setup, refer to JetBrains docs for more ESLint Configuration Options.

  1. Open ESLint configuration by going to File > Settings (Edit > Preferences on Mac) > Languages & Frameworks > Code Quality Tools > ESLint (optionally just search settings for "eslint")
  2. Select Manual ESLint configuration
  3. Choose your Node interpreter from the detected installations
  4. Select the global ESLint package from the dropdown
  5. Leave Configuration File as Automatic Search
  6. Check Run eslint --fix on save

Ensure the Prettier plugin is disabled if installed

  1. Open Prettier configuration by going to File > Settings (Edit > Preferences on Mac) > Languages & Frameworks > Code Quality Tools > Prettier (optionally just search settings for "prettier")
  2. Uncheck both On code reformat and On save
  3. Optional BUT IMPORTANT: If you have the Prettier extension enabled for other languages like CSS and HTML, turn it off for JS since we are doing it through Eslint already.
    1. Make sure the Run for files glob does not include js,ts,jsx,tsx.
    2. An example glob for styles, config, and markdown. {**/*,*}.{yml,css,sass,md}

There is also a section on the documentation about 💻Editor integrations

Resources

For any reports

For any report, problems encountered, please report on this discussion feedbacks.

About

An eslint shareable configuration for Vuejs app

Resources

Stars

Watchers

Forks

Packages

No packages published