@alvarosabu/eslint-config-ts
Advanced tools
Comparing version 0.2.2 to 0.2.3
220
index.js
const fs = require('node:fs') | ||
const { join } = require('node:path') | ||
const basic = require('@alvarosabu/eslint-config-base') | ||
const base = require('@alvarosabu/eslint-config-base') | ||
@@ -18,47 +18,53 @@ const tsconfig = process.env.ESLINT_TSCONFIG || 'tsconfig.eslint.json' | ||
}, | ||
overrides: basic.overrides.concat( | ||
overrides: base.overrides.concat( | ||
!fs.existsSync(join(process.cwd(), tsconfig)) | ||
? [] | ||
: [{ | ||
parserOptions: { | ||
tsconfigRootDir: process.cwd(), | ||
project: [tsconfig], | ||
}, | ||
parser: '@typescript-eslint/parser', | ||
excludedFiles: ['**/*.md/*.*'], | ||
files: ['*.ts', '*.tsx', '*.mts', '*.cts'], | ||
// https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/src/configs/recommended-requiring-type-checking.ts | ||
rules: { | ||
'no-throw-literal': 'off', | ||
'@typescript-eslint/no-throw-literal': 'error', | ||
'no-implied-eval': 'off', | ||
'@typescript-eslint/no-implied-eval': 'error', | ||
'dot-notation': 'off', | ||
'@typescript-eslint/dot-notation': ['error', { allowKeywords: true }], | ||
'@typescript-eslint/no-floating-promises': 'error', | ||
'@typescript-eslint/no-misused-promises': 'error', | ||
'@typescript-eslint/await-thenable': 'error', | ||
'@typescript-eslint/no-for-in-array': 'error', | ||
'@typescript-eslint/no-unnecessary-type-assertion': 'error', | ||
'@typescript-eslint/no-unsafe-argument': 'error', | ||
'@typescript-eslint/no-unsafe-assignment': 'error', | ||
'@typescript-eslint/no-unsafe-call': 'error', | ||
'@typescript-eslint/no-unsafe-member-access': 'error', | ||
'@typescript-eslint/no-unsafe-return': 'error', | ||
'require-await': 'off', | ||
'@typescript-eslint/require-await': 'error', | ||
'@typescript-eslint/restrict-plus-operands': 'error', | ||
'@typescript-eslint/restrict-template-expressions': 'error', | ||
'@typescript-eslint/unbound-method': 'error', | ||
}, | ||
}, { | ||
// https://github.com/jest-community/eslint-plugin-jest/blob/main/docs/rules/unbound-method.md | ||
files: ['**/__tests__/**/*.ts', '**/*.spec.ts', '**/*.test.ts'], | ||
plugins: ['jest'], | ||
rules: { | ||
// you should turn the original rule off *only* for test files | ||
'@typescript-eslint/unbound-method': 'off', | ||
'jest/unbound-method': 'error', | ||
}, | ||
}], | ||
: [ | ||
{ | ||
parserOptions: { | ||
tsconfigRootDir: process.cwd(), | ||
project: [tsconfig], | ||
}, | ||
parser: '@typescript-eslint/parser', | ||
excludedFiles: ['**/*.md/*.*'], | ||
files: ['*.ts', '*.tsx', '*.mts', '*.cts'], | ||
// https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/src/configs/recommended-requiring-type-checking.ts | ||
rules: { | ||
'no-throw-literal': 'off', | ||
'@typescript-eslint/no-throw-literal': 'error', | ||
'no-implied-eval': 'off', | ||
'@typescript-eslint/no-implied-eval': 'error', | ||
'dot-notation': 'off', | ||
'@typescript-eslint/dot-notation': [ | ||
'error', | ||
{ allowKeywords: true }, | ||
], | ||
'@typescript-eslint/no-floating-promises': 'error', | ||
'@typescript-eslint/no-misused-promises': 'error', | ||
'@typescript-eslint/await-thenable': 'error', | ||
'@typescript-eslint/no-for-in-array': 'error', | ||
'@typescript-eslint/no-unnecessary-type-assertion': 'error', | ||
'@typescript-eslint/no-unsafe-argument': 'error', | ||
'@typescript-eslint/no-unsafe-assignment': 'error', | ||
'@typescript-eslint/no-unsafe-call': 'error', | ||
'@typescript-eslint/no-unsafe-member-access': 'error', | ||
'@typescript-eslint/no-unsafe-return': 'error', | ||
'require-await': 'off', | ||
'@typescript-eslint/require-await': 'error', | ||
'@typescript-eslint/restrict-plus-operands': 'error', | ||
'@typescript-eslint/restrict-template-expressions': 'error', | ||
'@typescript-eslint/unbound-method': 'error', | ||
}, | ||
}, | ||
{ | ||
// https://github.com/jest-community/eslint-plugin-jest/blob/main/docs/rules/unbound-method.md | ||
files: ['**/__tests__/**/*.ts', '**/*.spec.ts', '**/*.test.ts'], | ||
plugins: ['jest'], | ||
rules: { | ||
// you should turn the original rule off *only* for test files | ||
'@typescript-eslint/unbound-method': 'off', | ||
'jest/unbound-method': 'error', | ||
}, | ||
}, | ||
], | ||
), | ||
@@ -69,6 +75,15 @@ rules: { | ||
// TS | ||
'@typescript-eslint/ban-ts-comment': ['error', { 'ts-ignore': 'allow-with-description' }], | ||
'@typescript-eslint/member-delimiter-style': ['error', { multiline: { delimiter: 'none' } }], | ||
'@typescript-eslint/ban-ts-comment': [ | ||
'error', | ||
{ 'ts-ignore': 'allow-with-description' }, | ||
], | ||
'@typescript-eslint/member-delimiter-style': [ | ||
'error', | ||
{ multiline: { delimiter: 'none' } }, | ||
], | ||
'@typescript-eslint/type-annotation-spacing': ['error', {}], | ||
'@typescript-eslint/consistent-type-imports': ['error', { prefer: 'type-imports', disallowTypeAnnotations: false }], | ||
'@typescript-eslint/consistent-type-imports': [ | ||
'error', | ||
{ prefer: 'type-imports', disallowTypeAnnotations: false }, | ||
], | ||
'@typescript-eslint/consistent-type-definitions': ['error', 'interface'], | ||
@@ -81,40 +96,44 @@ '@typescript-eslint/prefer-ts-expect-error': 'error', | ||
indent: 'off', | ||
'@typescript-eslint/indent': ['error', 2, { | ||
SwitchCase: 1, | ||
VariableDeclarator: 1, | ||
outerIIFEBody: 1, | ||
MemberExpression: 1, | ||
FunctionDeclaration: { parameters: 1, body: 1 }, | ||
FunctionExpression: { parameters: 1, body: 1 }, | ||
CallExpression: { arguments: 1 }, | ||
ArrayExpression: 1, | ||
ObjectExpression: 1, | ||
ImportDeclaration: 1, | ||
flatTernaryExpressions: false, | ||
ignoreComments: false, | ||
ignoredNodes: [ | ||
'TemplateLiteral *', | ||
'JSXElement', | ||
'JSXElement > *', | ||
'JSXAttribute', | ||
'JSXIdentifier', | ||
'JSXNamespacedName', | ||
'JSXMemberExpression', | ||
'JSXSpreadAttribute', | ||
'JSXExpressionContainer', | ||
'JSXOpeningElement', | ||
'JSXClosingElement', | ||
'JSXFragment', | ||
'JSXOpeningFragment', | ||
'JSXClosingFragment', | ||
'JSXText', | ||
'JSXEmptyExpression', | ||
'JSXSpreadChild', | ||
'TSTypeParameterInstantiation', | ||
'FunctionExpression > .params[decorators.length > 0]', | ||
'FunctionExpression > .params > :matches(Decorator, :not(:first-child))', | ||
'ClassBody.body > PropertyDefinition[decorators.length > 0] > .key', | ||
], | ||
offsetTernaryExpressions: true, | ||
}], | ||
'@typescript-eslint/indent': [ | ||
'error', | ||
2, | ||
{ | ||
SwitchCase: 1, | ||
VariableDeclarator: 1, | ||
outerIIFEBody: 1, | ||
MemberExpression: 1, | ||
FunctionDeclaration: { parameters: 1, body: 1 }, | ||
FunctionExpression: { parameters: 1, body: 1 }, | ||
CallExpression: { arguments: 1 }, | ||
ArrayExpression: 1, | ||
ObjectExpression: 1, | ||
ImportDeclaration: 1, | ||
flatTernaryExpressions: false, | ||
ignoreComments: false, | ||
ignoredNodes: [ | ||
'TemplateLiteral *', | ||
'JSXElement', | ||
'JSXElement > *', | ||
'JSXAttribute', | ||
'JSXIdentifier', | ||
'JSXNamespacedName', | ||
'JSXMemberExpression', | ||
'JSXSpreadAttribute', | ||
'JSXExpressionContainer', | ||
'JSXOpeningElement', | ||
'JSXClosingElement', | ||
'JSXFragment', | ||
'JSXOpeningFragment', | ||
'JSXClosingFragment', | ||
'JSXText', | ||
'JSXEmptyExpression', | ||
'JSXSpreadChild', | ||
'TSTypeParameterInstantiation', | ||
'FunctionExpression > .params[decorators.length > 0]', | ||
'FunctionExpression > .params > :matches(Decorator, :not(:first-child))', | ||
'ClassBody.body > PropertyDefinition[decorators.length > 0] > .key', | ||
], | ||
offsetTernaryExpressions: true, | ||
}, | ||
], | ||
'no-invalid-this': 'off', | ||
@@ -125,5 +144,12 @@ '@typescript-eslint/no-invalid-this': 'error', | ||
'no-use-before-define': 'off', | ||
'@typescript-eslint/no-use-before-define': ['error', { functions: false, classes: false, variables: true }], | ||
'@typescript-eslint/no-use-before-define': [ | ||
'error', | ||
{ functions: false, classes: false, variables: true }, | ||
], | ||
'brace-style': 'off', | ||
'@typescript-eslint/brace-style': ['error', 'stroustrup', { allowSingleLine: true }], | ||
'@typescript-eslint/brace-style': [ | ||
'error', | ||
'stroustrup', | ||
{ allowSingleLine: true }, | ||
], | ||
'comma-dangle': 'off', | ||
@@ -151,5 +177,11 @@ '@typescript-eslint/comma-dangle': ['error', 'always-multiline'], | ||
'keyword-spacing': 'off', | ||
'@typescript-eslint/keyword-spacing': ['error', { before: true, after: true }], | ||
'@typescript-eslint/keyword-spacing': [ | ||
'error', | ||
{ before: true, after: true }, | ||
], | ||
'comma-spacing': 'off', | ||
'@typescript-eslint/comma-spacing': ['error', { before: false, after: true }], | ||
'@typescript-eslint/comma-spacing': [ | ||
'error', | ||
{ before: false, after: true }, | ||
], | ||
'no-extra-parens': 'off', | ||
@@ -162,6 +194,8 @@ '@typescript-eslint/no-extra-parens': ['error', 'functions'], | ||
'lines-between-class-members': 'off', | ||
'@typescript-eslint/lines-between-class-members': ['error', 'always', { exceptAfterSingleLine: true }], | ||
'@typescript-eslint/lines-between-class-members': [ | ||
'error', | ||
'always', | ||
{ exceptAfterSingleLine: true }, | ||
], | ||
// off | ||
@@ -184,2 +218,2 @@ '@typescript-eslint/consistent-indexed-object-style': 'off', | ||
}, | ||
} | ||
} |
{ | ||
"name": "@alvarosabu/eslint-config-ts", | ||
"version": "0.2.2", | ||
"version": "0.2.3", | ||
"author": "Alvaro Saburido <hola@alvarosaburido.dev> (https://github.com/alvarosabu/)", | ||
@@ -24,3 +24,3 @@ "packageManager": "pnpm@8.5.1", | ||
"@typescript-eslint/parser": "^5.59.7", | ||
"@alvarosabu/eslint-config-base": "0.2.2" | ||
"@alvarosabu/eslint-config-base": "0.2.3" | ||
}, | ||
@@ -27,0 +27,0 @@ "devDependencies": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
9527
207
+ Added@alvarosabu/eslint-config-base@0.2.3(transitive)
- Removed@alvarosabu/eslint-config-base@0.2.2(transitive)