Refactor
This commit is contained in:
49
src/presets/eslint.ts
Normal file
49
src/presets/eslint.ts
Normal file
@ -0,0 +1,49 @@
|
||||
import { error, warn, off } from '../index';
|
||||
import { EslintRules } from 'eslint-define-config/src/rules/eslint';
|
||||
|
||||
export const eslintRules: Partial<EslintRules> = {
|
||||
'arrow-body-style': [error, 'as-needed'],
|
||||
'class-methods-use-this': off,
|
||||
'no-async-promise-executor': off,
|
||||
'no-case-declarations': off,
|
||||
'no-console': warn,
|
||||
'no-constant-condition': [error, { checkLoops: false }],
|
||||
'no-debugger': warn,
|
||||
'no-duplicate-imports': error,
|
||||
'no-empty': [error, { allowEmptyCatch: true }],
|
||||
'no-inner-declarations': off,
|
||||
'no-lonely-if': error,
|
||||
'no-restricted-globals': [error, 'event', 'name', 'length'],
|
||||
'no-restricted-imports': [
|
||||
error,
|
||||
{
|
||||
paths: [
|
||||
{
|
||||
name: 'crypto',
|
||||
importNames: ['webcrypto'],
|
||||
message: 'Use global `crypto` instead',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
'no-template-curly-in-string': error,
|
||||
'no-var': error,
|
||||
'object-shorthand': [error, 'always', { ignoreConstructors: true }],
|
||||
'one-var': [error, { var: 'never', let: 'never' }],
|
||||
'prefer-arrow-callback': error,
|
||||
'prefer-const': [error, { destructuring: 'all' }],
|
||||
'prefer-destructuring': [
|
||||
warn,
|
||||
{ AssignmentExpression: { array: false, object: false } },
|
||||
],
|
||||
'prefer-object-spread': error,
|
||||
'prefer-rest-params': warn,
|
||||
'prefer-spread': warn,
|
||||
'quote-props': [error, 'as-needed'],
|
||||
'sort-imports': [warn, { ignoreDeclarationSort: true }],
|
||||
'spaced-comment': [error, 'always', { markers: ['/', '#', '@'] }],
|
||||
complexity: [warn, { max: 100 }],
|
||||
curly: [error, 'multi-line', 'consistent'],
|
||||
eqeqeq: [error, 'smart'],
|
||||
yoda: [error, 'never', { exceptRange: true }],
|
||||
};
|
9
src/presets/react.ts
Normal file
9
src/presets/react.ts
Normal file
@ -0,0 +1,9 @@
|
||||
import { error, off } from '../index';
|
||||
import { ReactRules } from 'eslint-define-config/src/rules/react';
|
||||
|
||||
export const reactRules: Partial<ReactRules> = {
|
||||
'react/display-name': off,
|
||||
'react/no-children-prop': error,
|
||||
'react/prop-types': off,
|
||||
'react/react-in-jsx-scope': off,
|
||||
};
|
38
src/presets/typescript.ts
Normal file
38
src/presets/typescript.ts
Normal file
@ -0,0 +1,38 @@
|
||||
import { error, off } from '../index';
|
||||
import type { TypeScriptRules } from 'eslint-define-config/src/rules/typescript-eslint';
|
||||
|
||||
export const typescriptRules: Partial<TypeScriptRules> = {
|
||||
'@typescript-eslint/ban-ts-comment': [
|
||||
error,
|
||||
{
|
||||
'ts-expect-error': 'allow-with-description',
|
||||
'ts-check': false,
|
||||
'ts-ignore': 'allow-with-description',
|
||||
'ts-nocheck': 'allow-with-description',
|
||||
},
|
||||
],
|
||||
'@typescript-eslint/ban-types': [error, { extendDefaults: true }],
|
||||
'@typescript-eslint/consistent-type-imports': [
|
||||
error,
|
||||
{ disallowTypeAnnotations: false, fixStyle: 'inline-type-imports' },
|
||||
],
|
||||
'@typescript-eslint/no-empty-interface': [error, { allowSingleExtends: true }],
|
||||
'@typescript-eslint/no-explicit-any': off,
|
||||
'@typescript-eslint/no-extraneous-class': error,
|
||||
'@typescript-eslint/no-misused-promises': [error, { checksVoidReturn: false }],
|
||||
'@typescript-eslint/no-namespace': off,
|
||||
'@typescript-eslint/no-unnecessary-type-assertion': error,
|
||||
'@typescript-eslint/no-unsafe-argument': off,
|
||||
'@typescript-eslint/no-unsafe-assignment': off,
|
||||
'@typescript-eslint/no-unsafe-call': off,
|
||||
'@typescript-eslint/no-unsafe-member-access': off,
|
||||
'@typescript-eslint/no-unsafe-return': off,
|
||||
'@typescript-eslint/no-unused-vars': [
|
||||
error,
|
||||
{ ignoreRestSiblings: true, varsIgnorePattern: '^_' },
|
||||
],
|
||||
'@typescript-eslint/no-use-before-define': off,
|
||||
'@typescript-eslint/no-var-requires': off,
|
||||
'@typescript-eslint/triple-slash-reference': off,
|
||||
'@typescript-eslint/unbound-method': off,
|
||||
};
|
68
src/presets/unicorn.ts
Normal file
68
src/presets/unicorn.ts
Normal file
@ -0,0 +1,68 @@
|
||||
import { error, warn } from '../index';
|
||||
import { UnicornRules } from 'eslint-define-config/src/rules/unicorn';
|
||||
|
||||
const suggest = (suggest: string) => ({ suggest, fix: false });
|
||||
|
||||
// https://github.com/sindresorhus/eslint-plugin-unicorn/tree/28e7498ad06679bb92343db53bb40a7b5ba2990a
|
||||
export const unicornRules: Partial<UnicornRules> = {
|
||||
'unicorn/better-regex': error,
|
||||
'unicorn/consistent-function-scoping': warn,
|
||||
'unicorn/escape-case': error,
|
||||
'unicorn/no-array-for-each': warn,
|
||||
'unicorn/no-array-method-this-argument': error,
|
||||
'unicorn/no-array-push-push': warn,
|
||||
'unicorn/no-console-spaces': warn,
|
||||
'unicorn/no-for-loop': warn,
|
||||
'unicorn/no-instanceof-array': error,
|
||||
'unicorn/no-lonely-if': warn,
|
||||
'unicorn/no-static-only-class': error,
|
||||
'unicorn/no-typeof-undefined': error,
|
||||
// 'unicorn/no-unused-properties': warn,
|
||||
'unicorn/no-useless-fallback-in-spread': error,
|
||||
'unicorn/no-useless-promise-resolve-reject': error,
|
||||
'unicorn/no-useless-spread': error,
|
||||
'unicorn/no-useless-switch-case': error,
|
||||
'unicorn/number-literal-case': error,
|
||||
'unicorn/prefer-array-find': error,
|
||||
'unicorn/prefer-array-flat-map': error,
|
||||
'unicorn/prefer-array-some': error,
|
||||
'unicorn/prefer-at': error,
|
||||
'unicorn/prefer-blob-reading-methods': error,
|
||||
'unicorn/prefer-date-now': error,
|
||||
'unicorn/prefer-default-parameters': warn,
|
||||
'unicorn/prefer-dom-node-dataset': error,
|
||||
'unicorn/prefer-dom-node-remove': error,
|
||||
'unicorn/prefer-export-from': [error, { ignoreUsedVariables: false }],
|
||||
'unicorn/prefer-includes': error,
|
||||
'unicorn/prefer-keyboard-event-key': warn,
|
||||
'unicorn/prefer-logical-operator-over-ternary': warn,
|
||||
'unicorn/prefer-math-trunc': error,
|
||||
'unicorn/prefer-modern-math-apis': error,
|
||||
'unicorn/prefer-negative-index': error,
|
||||
'unicorn/prefer-node-protocol': error,
|
||||
'unicorn/prefer-object-from-entries': error,
|
||||
'unicorn/prefer-optional-catch-binding': error,
|
||||
'unicorn/prefer-reflect-apply': error,
|
||||
'unicorn/prefer-regexp-test': error,
|
||||
'unicorn/prefer-set-has': warn,
|
||||
'unicorn/prefer-string-slice': error,
|
||||
'unicorn/prefer-string-starts-ends-with': warn,
|
||||
'unicorn/prefer-string-trim-start-end': error,
|
||||
'unicorn/prefer-ternary': warn,
|
||||
'unicorn/string-content': [
|
||||
warn,
|
||||
{
|
||||
patterns: {
|
||||
'->': suggest('→'),
|
||||
'=>': suggest('⇒'),
|
||||
'<-': suggest('←'),
|
||||
'<=': suggest('≤'),
|
||||
'>=': suggest('≥'),
|
||||
'!=': suggest('≠'),
|
||||
'<=>': suggest('⇔'),
|
||||
'...': suggest('…'),
|
||||
},
|
||||
},
|
||||
],
|
||||
'unicorn/template-indent': warn,
|
||||
};
|
Reference in New Issue
Block a user