2.0.2 • Published 2 years ago

@cylution/eslint-config-nodejs v2.0.2

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

@cylution/eslint-config-nodejs

npm i -D eslint@^8 @cylution/eslint-config-nodejs

Usage

Edit .eslintrc or .eslintrc.js

module.exports = {
  env: {
    jest: true, // for jest
  },
  extends: [
    '@cylution/nodejs',
  ]
}

Extra steps for typescript

Normal

npm i -D @typescript-eslint/parser typescript

Edit .eslintrc or .eslintrc.js

module.exports = {
  env: {
    jest: true, // for jest
  },
  extends: [
    '@cylution/nodejs',
  ],
  overrides: [
    // typescript
    {
      files: ['*.ts', '*.tsx'],
      parser: '@typescript-eslint/parser',
    },
  ],
}

Typescript recommended

npm i -D typescript \
  @typescript-eslint/parser \
  @typescript-eslint/eslint-plugin

# then, if `tsc` not found, open new terminal
tsc --init

Edit .eslintrc or .eslintrc.js

/* eslint-env node */

module.exports = {
  env: {
    jest: true,
  },
  extends: [
    '@cylution/nodejs',
  ],
  overrides: [
    // typescript
    {
      files: ['*.ts', '*.tsx'],
      parser: '@typescript-eslint/parser',
      plugins: ['@typescript-eslint'],
      extends: [
        'plugin:@typescript-eslint/recommended'
      ],
      parserOptions: {
        project: "./tsconfig.json",
      },
      rules: {
        '@typescript-eslint/ban-ts-comment': 'off',
        '@typescript-eslint/no-explicit-any': 'off',
        '@typescript-eslint/type-annotation-spacing': ['warn', {
          before: false,
          after: true
        }],
        '@typescript-eslint/member-delimiter-style': ['error', {
          multiline: {
            delimiter: 'none',
            requireLast: false,
          },
          singleline: {
            delimiter: 'comma',
            requireLast: false,
          },
          // overrides: {
          //   interface: {
          //     multiline: {
          //       delimiter: 'none',
          //       requireLast: false
          //     }
          //   }
          // }
        }],
        '@typescript-eslint/dot-notation': ['error', {
          allowPrivateClassPropertyAccess: true,
          allowProtectedClassPropertyAccess: true,
          // allowIndexSignaturePropertyAccess: true,
        }],
      },
      overrides: [
        {
          files: ['*.d.ts'],
          rules: {
            'no-use-before-define': 'off',
            '@typescript-eslint/no-unused-vars': 'off',
            // '@typescript-eslint/ban-types': 'off',
            // '@typescript-eslint/adjacent-overload-signatures': 'off',
          },
        },
      ],
    },
  ],
  rules: {
    'dot-notation': 'off',
  },
}

Note

If you get error message like: Could not load/find module eslint-blahblah, please remove node_modules and run npm install or yarn to reinstall packages

2.0.2

2 years ago

2.0.1

3 years ago

2.0.0-alpha.0

3 years ago

2.0.0

3 years ago

1.0.15

3 years ago

1.0.14

3 years ago

1.0.13

3 years ago

1.0.12

4 years ago

1.0.11

4 years ago

1.0.10

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.7-alpha.0

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago