4.1.2 • Published 1 year ago

@atws/eslint-config v4.1.2

Weekly downloads
-
License
MIT
Repository
-
Last release
1 year ago

@atws/eslint-config

npm

This package contains extensive eslint rulesets; it is based on gajus/eslint-config-canonical and includes opinionated modifications.

Usage

Install eslint and the package:

yarn add -D eslint @atws/eslint-config

In the root of your project, create a .eslintrc.js file and extend the base configuration.

To extend the base configuration for specific files, use the overrides property. You can also create a separate .eslintrc.js file in the directory where you want to extend the configuration.

Create a .eslintrc.js in your project root

/* global module */

module.exports = {
  extends: ['@atws/eslint-config'],
  overrides: [
    {
      extends: ['@atws/eslint-config/cdk'],
      files: 'infrastructure/**/*.ts',
      parserOptions: {
        project: ['./tsconfig.json'],
        tsconfigRootDir: `${__dirname}/infrastructure/cdk-backend`,
      },
    },
    {
      extends: ['@atws/eslint-config/react'],
      files: '*.tsx',
      parserOptions: {
        project: ['./tsconfig.json'],
        tsconfigRootDir: __dirname,
      },
    },
    {
      extends: ['@atws/eslint-config/typescript'],
      files: 'backend/**/*.ts',
      parserOptions: {
        project: ['./tsconfig.json'],
        tsconfigRootDir: `${__dirname}/backend`,
      },
    },
  ],
  root: true,
}

Integration with prettier

Create a .prettierrc.js in your project root. You can use @atws/prettier-config to get started with prettier.

Previously in v2, we used prettier as an eslint plugin. This is no longer the case. We now use prettier as a standalone tool and run it before the eslint fixer. This means that prettier will fix all formatting issues and eslint will fix all linting issues.

yarn add -D prettier @atws/prettier-config

.prettierrc.js

const preset = require('@atws/prettier-config')

/** @type {import("prettier").Options} */
const config = {
  ...preset,
}

module.exports = config

To run prettier before eslint you need to install the Format Code Action VSCode extension and add the following to your .vscode/settings.json file.

{
  "editor.formatOnSave": false,
  "editor.defaultFormatter": "esbenp.prettier-vscode",
  "editor.codeActionsOnSave": ["source.formatDocument", "source.fixAll.eslint"]
}

Variants

There are a few variants of the base config that can be used to extend the base config.

Typescript

Add rules for typescript projects.

{
  extends: ['@atws/eslint-config/typescript']
}

React

Add rules for React projects.

{
  extends: ['@atws/eslint-config/react']
}

CDK

Disable rules that conflict with common CDK patterns.

{
  extends: ['@atws/eslint-config/cdk']
}

Projen

Disable rules that conflic with the projen jsii compiler.

{
  extends: ['@atws/eslint-config/projen']
}
4.1.2

1 year ago

4.1.1

1 year ago

4.1.0

2 years ago

3.2.0

2 years ago

3.0.1

2 years ago

3.0.0

2 years ago

4.0.0

2 years ago

3.1.0

2 years ago

2.2.1

2 years ago

2.2.0

2 years ago

2.0.2

2 years ago

2.2.3

2 years ago

2.2.2

2 years ago

2.0.1

2 years ago

2.0.0

2 years ago

2.1.2

2 years ago

2.1.1

2 years ago

2.1.4

2 years ago

2.1.3

2 years ago

2.1.6

2 years ago

2.1.5

2 years ago

2.1.0

2 years ago

1.9.1

2 years ago

1.9.0

2 years ago

1.8.1

2 years ago

1.8.0

2 years ago

1.9.2

2 years ago

1.7.13

2 years ago

1.7.12

2 years ago

1.7.11

2 years ago

1.7.10

2 years ago

1.7.9

2 years ago

1.7.8

2 years ago

1.7.7

2 years ago

1.7.6

2 years ago

1.7.5

2 years ago

1.7.4

2 years ago

1.7.3

2 years ago

1.7.2

2 years ago

1.7.1

2 years ago

1.7.0

2 years ago

1.6.0

2 years ago

1.5.0

2 years ago

1.4.0

2 years ago

1.3.4

2 years ago

1.3.3

2 years ago

1.3.2

2 years ago

1.3.0

2 years ago

1.2.1

2 years ago

1.2.0

2 years ago

1.1.3

2 years ago

1.1.2

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.0

2 years ago