@gitlab/eslint-plugin
Version:
GitLab package for our custom eslint rules
135 lines (132 loc) • 3.96 kB
JavaScript
const baseConfig = require('./base');
const tsEslint = require('@typescript-eslint/eslint-plugin');
const tsParser = require('@typescript-eslint/parser');
const globals = require('globals');
const tsConfig = [
{
languageOptions: {
globals: {
...baseConfig.languageOptions.globals,
...globals.mocha,
...globals.jest,
},
ecmaVersion: baseConfig.languageOptions.ecmaVersion,
sourceType: baseConfig.languageOptions.sourceType,
parserOptions: baseConfig.languageOptions.parserOptions || {},
},
plugins: {
...baseConfig.plugins,
},
settings: {
...baseConfig.settings,
},
rules: {
...baseConfig.rules,
},
},
// TypeScript-specific config
{
files: ['**/*.ts', '**/*.tsx'],
languageOptions: {
parser: tsParser,
parserOptions: {
project: ['./tsconfig.json'],
tsconfigRootDir: process.cwd(),
},
},
plugins: {
'@typescript-eslint': tsEslint,
},
settings: {
'import/resolver': {
node: {
extensions: ['.mjs', '.js', '.json', '.node', '.ts', '.tsx'],
},
},
},
rules: {
'import/extensions': [
'error',
'ignorePackages',
{
js: 'never',
jsx: 'never',
ts: 'never',
tsx: 'never',
},
],
semi: [2, 'always'],
'max-params': 'off',
'no-throw-literal': 'off',
'no-shadow': 'off',
'no-empty-function': 'off',
'no-plusplus': 'off',
'no-unused-vars': 'off',
'no-await-in-loop': 'error',
'unicorn/no-array-callback-reference': 'off',
'generator-star-spacing': 'off',
'max-len': 'off',
'no-console': 'warn',
'indent': 'off',
'quotes': 'off',
'implicit-arrow-linebreak': 'off',
'function-paren-newline': 'off',
'no-redeclare': 'off',
'brace-style': 'off',
'no-undef': 'off',
'no-tabs': 'off',
'operator-linebreak': 'off',
'no-confusing-arrow': 'off',
'object-curly-newline': 'off',
'@typescript-eslint/only-throw-error': 'error',
'@typescript-eslint/no-unused-vars': 'error',
'@typescript-eslint/no-shadow': 'error',
'@typescript-eslint/return-await': 'error',
'@typescript-eslint/no-floating-promises': 'error',
'@typescript-eslint/no-explicit-any': 'error',
'@typescript-eslint/no-non-null-assertion': 'error',
'@typescript-eslint/no-var-requires': 'error',
'@typescript-eslint/explicit-member-accessibility': [
'error',
{
accessibility: 'no-public',
},
],
'class-methods-use-this': 'off',
'import/no-cycle': 'error',
'promise/param-names': 'off',
'no-use-before-define': ['warn', 'nofunc'],
'no-restricted-syntax': [
'error',
{
selector: ':matches(PropertyDefinition, MethodDefinition)[accessibility="private"]',
message: 'Use # prefix instead of `private` to indicate private class members.',
},
{
selector: 'ForInStatement',
message:
'for..in loops iterate over the entire prototype chain, which is virtually never what you want. Use Object.{keys,values,entries}, and iterate over the resulting array.',
},
{
selector: 'LabeledStatement',
message:
'Labels are a form of GOTO; using them makes code confusing and hard to maintain and understand.',
},
{
selector: 'WithStatement',
message:
'`with` is disallowed in strict mode because it makes code impossible to predict and optimize.',
},
],
},
},
// Test files config
{
files: ['**/*.test.ts', '**/*.test.js'],
rules: {
'max-classes-per-file': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
},
},
];
module.exports = tsConfig;