Skip to content
This repository has been archived by the owner on Mar 8, 2024. It is now read-only.

ESLint configuration for Ontario Frontend projects

Notifications You must be signed in to change notification settings

ongov/eslint-config-ontario

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

@ontario-digital-service/eslint-config-ontario

This package provides the shared ESLint configuration used by Ontario Frontend projects. It enforces a consistent code style for JavaScript projects to help keep code clean and readable.

Features

  • Print Width: Set to 80 characters to maintain readability across various devices and editors.
  • Tab Width: Uses 2 spaces for indentation to ensure code is clean and readable.
  • Semicolons: Requires semicolons at the end of statements for clarity.
  • Single Quotes: Enforces the use of single quotes for strings, except in Markdown files where double quotes are preferred.
  • Trailing Commas: Requires trailing commas in multi-line objects, arrays, etc., which makes version control diffs cleaner.
  • Bracket Spacing: Ensures spaces are present inside object literal braces for better readability.
  • Bracket Same Line: Places the closing angle bracket of elements on the same line as the last prop.
  • Overrides for Markdown: For .md files, double quotes are used instead of single quotes.

Installation

To use the @ontario-digital-service/eslint-config-ontario in your project, follow the steps for based on your package manager:

NPM

  1. First, you need to install ESLint if it's not already installed:

    npm install eslint --save-dev
  2. Next, install the @ontario-digital-service/eslint-config-ontario package:

    npm install @ontario-digital-service/eslint-config-ontario --save-dev

YARN

  1. First, you need to install ESLint if it's not already installed:

    yarn add eslint --dev
  2. Next, install the @ontario-digital-service/eslint-config-ontario package:

    yarn add @ontario-digital-service/eslint-config-ontario --dev

Usage

After installation, you'll need to set up your ESLint configuration file if you haven't already. Here's how:

  1. Create a file named .eslintrc.json in your project's root directory.

  2. Add the following content to .eslintrc.json to extend the @ontario-digital-service/eslint-config-ontario configuration:

    {
        "extends": "@ontario-digital-service/eslint-config-ontario"
    }

This line tells ESLint to use the @ontario-digital-service/eslint-config-ontario rules for your project.

Customizing

If you need to override any rules, you can do so within your project's .eslintrc file. For example:

{
  "extends": "@ontario-digital-service/eslint-config-ontario",
  "rules": {
    "no-unused-vars": "warn",
    "semi": ["error", "never"]
  }
}

This customization will change the handling of unused variables to a warning and remove the requirement for semicolons.

Contributing

We welcome contributions to improve the eslint-config-ontario package. Please feel free to submit a pull request or open an issue on our GitHub repository.

About

ESLint configuration for Ontario Frontend projects

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published