4.1.2 • Published 4 months ago

@atws/eslint-config v4.1.2

Weekly downloads
-
License
MIT
Repository
-
Last release
4 months 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

4 months ago

4.1.1

5 months ago

4.1.0

5 months ago

3.2.0

9 months ago

3.0.1

9 months ago

3.0.0

9 months ago

4.0.0

8 months ago

3.1.0

9 months ago

2.2.1

11 months ago

2.2.0

11 months ago

2.0.2

12 months ago

2.2.3

11 months ago

2.2.2

11 months ago

2.0.1

12 months ago

2.0.0

12 months ago

2.1.2

11 months ago

2.1.1

12 months ago

2.1.4

11 months ago

2.1.3

11 months ago

2.1.6

11 months ago

2.1.5

11 months ago

2.1.0

12 months ago

1.9.1

12 months ago

1.9.0

12 months ago

1.8.1

1 year ago

1.8.0

1 year ago

1.9.2

12 months ago

1.7.13

1 year ago

1.7.12

1 year ago

1.7.11

1 year ago

1.7.10

1 year ago

1.7.9

1 year ago

1.7.8

1 year ago

1.7.7

1 year ago

1.7.6

1 year ago

1.7.5

1 year ago

1.7.4

1 year ago

1.7.3

1 year ago

1.7.2

1 year ago

1.7.1

1 year ago

1.7.0

1 year ago

1.6.0

1 year ago

1.5.0

1 year ago

1.4.0

1 year ago

1.3.4

1 year ago

1.3.3

1 year ago

1.3.2

1 year ago

1.3.0

1 year ago

1.2.1

1 year ago

1.2.0

1 year ago

1.1.3

1 year ago

1.1.2

1 year ago

1.1.1

1 year ago

1.1.0

1 year ago

1.0.0

1 year ago