Skip to content

Commit

Permalink
feat: update js/ts rules
Browse files Browse the repository at this point in the history
  • Loading branch information
lvjiaxuan committed Sep 22, 2023
1 parent e279608 commit a90711b
Show file tree
Hide file tree
Showing 2 changed files with 94 additions and 24 deletions.
77 changes: 55 additions & 22 deletions packages/javascript/index.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,30 @@ module.exports = {
rules: {
// https://eslint.org/docs/rules/

// My custom rules
// Possible Problems which are not included in recommended rules
'array-callback-return': [ 'error', { allowImplicit: true, checkForEach: false } ],
'no-await-in-loop': 'error',
'no-constant-binary-expression': 'warn',
'no-constructor-return': 'error',
'no-duplicate-imports': 'warn',
'no-new-native-nonconstructor': 'error',
'no-promise-executor-return': 'warn',
'no-self-compare': 'error',
'no-template-curly-in-string': 'warn',
'no-unmodified-loop-condition': 'off',
'no-unreachable-loop': 'error',
'no-unused-private-class-members': 'off',
'no-use-before-define': [
'error', {
functions: false,
classes: false,
variables: false,
allowNamedExports: true,
},
],
'require-atomic-updates': 'error',

// My custom
indent: [
'warn', 2, {
SwitchCase: 1,
Expand Down Expand Up @@ -32,8 +55,9 @@ module.exports = {
'sort-imports': [
'warn',
{
// The default setting.
ignoreCase: false,
ignoreDeclarationSort: true,
ignoreDeclarationSort: false,
ignoreMemberSort: false,
memberSyntaxSortOrder: [ 'none', 'all', 'multiple', 'single' ],
allowSeparatedGroups: false,
Expand All @@ -46,32 +70,41 @@ module.exports = {
'comma-dangle': [ 'warn', 'always-multiline' ], // prettier like trailingComma: 'es5'
'arrow-parens': [ 'warn', 'as-needed' ], // prettier arrowParens: 'avoid'
'eol-last': [ 'warn', 'always' ], // prettier endOfLine: 'lf'
'no-extra-parens': 'warn',
'arrow-body-style': [ 'warn', 'as-needed', { requireReturnForObjectLiteral: false } ],

// Possible Problems which are not included in recommended rules
'array-callback-return': 'error',
'no-await-in-loop': 'warn',
'no-constant-binary-expression': 'warn',
'no-constructor-return': 'warn',
'no-duplicate-imports': 'warn',
'no-promise-executor-return': 'off',
'no-self-compare': 'error',
'no-unmodified-loop-condition': 'error',
'no-unreachable-loop': 'warn',
'no-unused-private-class-members': 'off',
'no-use-before-define': [
'error', {
functions: false,
classes: false,
variables: false,
allowNamedExports: true,
// 'default-param-last': 'off',
'no-invalid-this': 'error',
'no-loop-func': 'error',
'no-magic-numbers': [
'warn', {
ignore: [ 0, 1 ],
// ignoreArrayIndexes: false,
// ignoreDefaultValues: false,
// ignoreClassFieldInitialValues: false,
enforceConst: true,
// detectObjects: false,
},
],
'no-restricted-imports': 'off',
'no-shadow': [
'warn', {
builtinGlobals: true,
// hoist: 'functions',
// allow: [],
// ignoreOnInitialization: false,
},
],
'no-unused-expressions': [
'warn', {
allowShortCircuit: true,
allowTernary: true,
allowTaggedTemplates: true,
enforceForJSX: false,
},
],
'require-atomic-updates': 'error',

// Layout & Formatting
'no-multiple-empty-lines': [ 'warn', { max: 2 } ],
'no-extra-parens': 'warn',

// object-*
'object-curly-spacing': [ 'warn', 'always' ],
Expand Down
41 changes: 39 additions & 2 deletions packages/typescript/index.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,47 @@ module.exports = {
},

rules: {
// turn off js rules
// https://typescript-eslint.io/rules/

// turn off js rules.
...tsRules,

// https://typescript-eslint.io/rules/

// Rules that are not grouped.
// '@typescript-eslint/explicit-function-return-type': 'off',
// '@typescript-eslint/explicit-module-boundary-types': 'off',
// '@typescript-eslint/member-ordering': 'off',
'@typescript-eslint/no-require-imports': 'warn',
// "@typescript-eslint/parameter-properties": "off",
// '@typescript-eslint/typedef': 'off',
'@typescript-eslint/no-dupe-class-members': 'error',
'@typescript-eslint/no-magic-numbers': [
'warn', {
ignore: [ 0, 1 ],
// ignoreArrayIndexes: false,
// ignoreDefaultValues: false,
// ignoreClassFieldInitialValues: false,
enforceConst: true,
// detectObjects: false,
ignoreEnums: true,
ignoreNumericLiteralTypes: true,
ignoreReadonlyClassProperties: true,
ignoreTypeIndexes: true,
},
],
'@typescript-eslint/no-redeclare': 'off',
'@typescript-eslint/no-shadow': [
'warn', {
builtinGlobals: true,
// hoist: 'functions',
// allow: [],
// ignoreOnInitialization: false,
ignoreTypeValueShadow: true,
ignoreFunctionTypeParameterNameValueShadow: false,
},
],

// My custom.
'@typescript-eslint/ban-ts-comment': [
'warn', {
'ts-check': 'allow-with-description',
Expand Down

0 comments on commit a90711b

Please sign in to comment.