Skip to content

Commit

Permalink
Updated lint and code format config
Browse files Browse the repository at this point in the history
  • Loading branch information
ipakhomov committed May 31, 2023
1 parent b062777 commit e0bdfcb
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 55 deletions.
4 changes: 2 additions & 2 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# Editor configuration, see https://editorconfig.org
root = true

[*]
Expand All @@ -7,7 +6,8 @@ indent_style = space
indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true
end_of_line = lf
max_line_length = 120

[*.md]
max_line_length = off
trim_trailing_whitespace = false
97 changes: 50 additions & 47 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,7 @@ module.exports = {
jsx: true
}
},
ignorePatterns: [
'node_modules',
'dist',
'coverage',
'**/*.js',
'.expo',
'.expo-shared',
'web-build'
],
ignorePatterns: ['node_modules', 'dist', 'coverage', '.eslintrc.js', '.expo', '.expo-shared', 'web-build'],
settings: {
react: {
version: 'detect'
Expand All @@ -30,21 +22,14 @@ module.exports = {
},
'import/resolver': {
typescript: {
alwaysTryTypes: true,
alwaysTryTypes: true
},
node: {
extensions: ['.js', '.jsx', '.ts', '.tsx']
}
}
},
plugins: [
'@typescript-eslint',
'unused-imports',
'react',
'react-hooks',
'react-native',
'import'
],
plugins: ['@typescript-eslint', 'unused-imports', 'react', 'react-hooks', 'react-native', 'import'],
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/eslint-recommended',
Expand All @@ -53,11 +38,11 @@ module.exports = {
'prettier'
],
rules: {
'indent': ['warn', 2, { SwitchCase: 1 }],
'quotes': ['warn', 'single'],
indent: ['warn', 2, { SwitchCase: 1 }],
quotes: ['warn', 'single', { allowTemplateLiterals: true }],
'arrow-parens': ['warn', 'always'],
'comma-dangle': ['warn', 'never'],
'no-var': 'error',
'no-var': 'warn',
'no-dupe-class-members': 'off',
'import/prefer-default-export': 'off',
'implicit-arrow-linebreak': ['warn', 'beside'],
Expand All @@ -66,21 +51,28 @@ module.exports = {
'function-paren-newline': ['warn', 'consistent'],
'array-element-newline': ['warn', 'consistent'],
'array-bracket-newline': ['warn', { multiline: true }],
'padding-line-between-statements': ['warn', { blankLine: 'always', prev: '*', next: 'return' }],
'padding-line-between-statements': [
'warn',
{ blankLine: 'always', prev: '*', next: 'return' },
{ blankLine: 'always', prev: '*', next: 'multiline-block-like' }
],
'@typescript-eslint/no-use-before-define': ['warn', { variables: false }],
'@typescript-eslint/lines-between-class-members': ['warn', { exceptAfterSingleLine: true }],
'@typescript-eslint/no-inferrable-types': ['warn', { ignoreParameters: true }],
'@typescript-eslint/explicit-module-boundary-types': ['warn', { allowArgumentsExplicitlyTypedAsAny: true }],
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/explicit-member-accessibility': ['warn', { accessibility: 'explicit', overrides: { constructors: 'no-public' } }],
'@typescript-eslint/explicit-member-accessibility': [
'warn',
{ accessibility: 'explicit', overrides: { constructors: 'no-public' } }
],
'@typescript-eslint/explicit-function-return-type': ['warn', { allowExpressions: true }],
'@typescript-eslint/no-var-requires': 'off',
'@typescript-eslint/no-unused-vars': 'off',
'@typescript-eslint/array-type': ['warn', { default: 'generic', readonly: 'generic' }],
'@typescript-eslint/member-ordering': [
'warn',
{
'default': [
default: [
'public-static-field',
'protected-static-field',
'private-static-field',
Expand All @@ -102,40 +94,40 @@ module.exports = {
'@typescript-eslint/naming-convention': [
'warn',
{
'selector': 'typeLike',
'format': ['PascalCase']
selector: 'typeLike',
format: ['PascalCase']
},
{
'selector': ['parameter'],
'format': ['camelCase', 'PascalCase'],
selector: ['parameter'],
format: ['camelCase', 'PascalCase'],
leadingUnderscore: 'allow'
},
{
'selector': ['classProperty'],
'format': ['camelCase', 'snake_case'],
selector: ['classProperty'],
format: ['camelCase', 'snake_case'],
leadingUnderscore: 'allow'
},
{
'selector': ['method', 'accessor'],
'format': ['camelCase']
selector: ['method', 'accessor'],
format: ['camelCase']
},
{
'selector': ['function', 'typeProperty'],
'format': ['camelCase', 'PascalCase']
selector: ['function', 'typeProperty'],
format: ['camelCase', 'PascalCase']
},
{
'selector': 'variable',
'format': ['camelCase', 'PascalCase', 'UPPER_CASE']
selector: 'variable',
format: ['camelCase', 'PascalCase', 'UPPER_CASE']
},
{
'selector': 'enumMember',
'format': ['UPPER_CASE']
selector: 'enumMember',
format: ['UPPER_CASE']
}
],
'unused-imports/no-unused-imports-ts': 'warn',
'unused-imports/no-unused-vars-ts': [
'warn',
{ vars: 'all', varsIgnorePattern: '^_', argsIgnorePattern: '^_', ignoreRestSiblings: true },
{ vars: 'all', varsIgnorePattern: '^_', argsIgnorePattern: '^_', ignoreRestSiblings: true }
],
'jsx-quotes': ['warn', 'prefer-single'],
'react/jsx-boolean-value': 'off',
Expand All @@ -146,24 +138,35 @@ module.exports = {
'react-native/no-unused-styles': 'warn',
'react-native/no-inline-styles': 'warn',
'react-native/no-single-element-style-arrays': 'warn',
'import/newline-after-import': 'warn',
'import/no-unresolved': 'warn',
'import/order': ['warn', {
groups: ['builtin', 'external', 'internal', 'parent', 'sibling', 'index', 'object', 'type'],
alphabetize: { order: 'asc' }
}],
'import/order': [
'warn',
{
groups: ['builtin', 'external', 'internal', 'parent', 'sibling', 'index', 'object', 'type'],
alphabetize: { order: 'asc' }
}
],
'import/no-duplicates': 'warn'
},
overrides: [
{
'files': ['*actions.ts'],
'rules': {
files: ['*.js'],
rules: {
'@typescript-eslint/explicit-member-accessibility': 'off',
'@typescript-eslint/explicit-function-return-type': 'off'
}
},
{
files: ['*actions.ts'],
rules: {
'function-call-argument-newline': ['warn', 'always'],
'function-paren-newline': ['warn', { minItems: 1 }]
}
},
{
'files': ['*selectors.ts'],
'rules': {
files: ['*selectors.ts'],
rules: {
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'function-call-argument-newline': ['warn', 'always'],
Expand Down
10 changes: 4 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
"submit:ios:dev": "cross-env APP_ENV=development eas submit --no-wait -p ios --profile=development",
"submit:ios:prod": "cross-env APP_ENV=production eas submit --no-wait -p ios --profile=production",
"eject": "expo eject",
"lint": "eslint --ext .ts,.tsx ./",
"format": "npx prettier --write **/*.{ts,tsx} && npx prettier --write *.{ts,tsx} && npm run lint -- --fix",
"lint": "eslint ./",
"format": "npx prettier --write . && npm run lint -- --fix",
"verify": "npm run verify:ts && npm run verify:cycles",
"verify:ts": "npx tsc",
"verify:cycles": "dpdm --no-warning --no-tree --transform --progress false index.js --exclude \".*?/?models/.*\\.tsx?|node_modules\" --exit-code circular:1",
Expand Down Expand Up @@ -126,9 +126,7 @@
"typescript": "^4.9.4"
},
"lint-staged": {
"*.{ts,tsx}": [
"prettier --write",
"eslint --cache --fix"
]
"*.{ts,tsx,js,html,json,md}": "prettier --write",
"*.{ts,tsx,js}": "eslint --cache --fix"
}
}

0 comments on commit e0bdfcb

Please sign in to comment.