-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
1,283 additions
and
674 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,31 @@ | ||
{ | ||
"presets": ["module:metro-react-native-babel-preset"], | ||
"plugins": [ | ||
"import-graphql" | ||
] | ||
"presets": ["module:metro-react-native-babel-preset"], | ||
"plugins": [ | ||
"import-graphql", | ||
[ | ||
"@babel/plugin-proposal-decorators", | ||
{ | ||
"legacy": true | ||
} | ||
], | ||
[ | ||
"babel-plugin-root-import", | ||
{ | ||
"paths": [ | ||
{ | ||
"rootPathPrefix": "@apollo", | ||
"rootPathSuffix": "./src/apollo" | ||
}, | ||
{ | ||
"rootPathPrefix": "@utils", | ||
"rootPathSuffix": "./src/utils" | ||
}, | ||
{ | ||
"rootPathPrefix": "@store", | ||
"rootPathSuffix": "./src/store" | ||
} | ||
] | ||
} | ||
] | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# /node_modules/* and /bower_components/* ignored by default |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,184 @@ | ||
module.exports = { | ||
root: true, | ||
env: { | ||
es6: true, | ||
node: true, | ||
'react-native/react-native': true, | ||
}, | ||
globals: { | ||
Toast: true, | ||
Device: true, | ||
Theme: true, | ||
Font: true, | ||
PxDp: true, | ||
Config: true, | ||
TOKEN: true, | ||
}, | ||
extends: [ | ||
'eslint:recommended', | ||
'prettier', | ||
'prettier/react', | ||
'prettier/@typescript-eslint', | ||
'plugin:react-native/all', | ||
'plugin:@typescript-eslint/recommended', | ||
'plugin:prettier/recommended', | ||
'@react-native-community', | ||
], | ||
parser: '@typescript-eslint/parser', // 解析器 | ||
parserOptions: { | ||
ecmaFeatures: { | ||
experimentalObjectRestSpread: true, | ||
jsx: true, | ||
legacyDecorators: true, | ||
impliedStrict: true, | ||
}, | ||
project: './tsconfig.json', | ||
ecmaVersion: 2018, | ||
sourceType: 'module', | ||
}, | ||
plugins: ['react', 'react-native', 'react-hooks'], | ||
settings: { | ||
// ESLint 支持在配置文件添加共享设置 | ||
'import/resolver': { | ||
typescript: {}, | ||
'babel-plugin-root-import': [ | ||
{ | ||
rootPathPrefix: '@app', | ||
rootPathSuffix: './', | ||
}, | ||
{ | ||
rootPathPrefix: '@src', | ||
rootPathSuffix: './src', | ||
}, | ||
], | ||
node: { | ||
extensions: ['.js', '.jsx', 'ts', '.tsx'], | ||
}, | ||
react: { | ||
version: 'detect', // Tells eslint-plugin-react to automatically detect the version of React to use | ||
}, | ||
}, | ||
}, | ||
rules: { | ||
// 启用严格模式 | ||
strict: 'error', | ||
// 空格方式,使用tab | ||
|
||
// 处理器类型的转义 | ||
'linebreak-style': ['error', 'unix'], | ||
// 允许使用 单引号和es6的`` | ||
quotes: ['error', 'single', { allowTemplateLiterals: true }], | ||
// 禁止不必要的分号 | ||
semi: ['error', 'always'], | ||
// 禁止分号前后有空格 | ||
'semi-spacing': 2, | ||
// 尽可能使用`===` | ||
eqeqeq: 2, | ||
// 强制在代码块中开括号前和闭括号后有空格 | ||
'block-spacing': [2, 'always'], | ||
// 在代码块之前强制使用空格 | ||
'space-before-blocks': 2, | ||
// 要求操作符周围有空格 | ||
'space-infix-ops': 2, | ||
// 一元操作符必须要有空格 | ||
'space-unary-ops': 2, | ||
// 强制在注释中 // 或 /* 使用一致的空格 | ||
'spaced-comment': [2, 'always', { exceptions: ['-'] }], | ||
// 强制关键字周围空格的一致性 | ||
'keyword-spacing': [2, { before: true, after: true }], | ||
// 强制在箭头函数中 "xxx() => {}" | ||
'arrow-spacing': ['error', { before: true, after: true }], | ||
// 在冒号后要加上空格 | ||
'key-spacing': ['error', { beforeColon: false }], | ||
// 要求在逗号后使用一个或多个空格 | ||
'comma-spacing': ['error', { after: true }], | ||
// 禁止分号之前出现空格 | ||
'semi-spacing': ['error', { before: false, after: true }], | ||
// 如果一个变量不会被重新赋值,最好使用const进行声明。 | ||
'prefer-const': 'error', | ||
// 禁止空格和 tab 的混合缩进 | ||
'no-mixed-spaces-and-tabs': 0, | ||
// 不允许使用var | ||
'no-var': 2, | ||
// 不允许改变用const声明的变量 | ||
'no-const-assign': 'error', | ||
|
||
'no-extra-boolean-cast': 0, | ||
'no-useless-computed-key': 0, | ||
'no-console': [ | ||
'error', | ||
{ | ||
allow: ['warn', 'error', 'info', 'disableYellowBox'], | ||
}, | ||
], | ||
'no-param-reassign': [ | ||
'error', | ||
{ | ||
props: false, | ||
}, | ||
], | ||
'no-restricted-globals': 0, | ||
'no-unused-vars': 0, | ||
'no-use-before-define': 0, | ||
'no-underscore-dangle': 0, | ||
'no-useless-constructor': 0, | ||
'no-unused-expressions': 0, | ||
'no-plusplus': 0, | ||
|
||
'lines-between-class-members': [ | ||
1, | ||
'always', | ||
{ | ||
exceptAfterSingleLine: true, | ||
}, | ||
], | ||
'prefer-destructuring': [ | ||
2, | ||
{ | ||
array: false, | ||
object: true, | ||
}, | ||
], | ||
'import/prefer-default-export': 0, | ||
'jsx-a11y/accessible-emoji': 0, | ||
// 不允许使用行内样式 | ||
'react-native/no-inline-styles': 2, | ||
'react-native/no-color-literals': 0, | ||
'react-native/no-raw-text': 0, | ||
'react/prefer-stateless-function': 0, | ||
'react/destructuring-assignment': 0, | ||
'react/prop-types': 0, | ||
'react/react-in-jsx-scope': 0, | ||
'react/jsx-filename-extension': [ | ||
2, | ||
{ | ||
extensions: ['.js', '.ts', '.jsx', '.tsx'], | ||
}, | ||
], | ||
'react-hooks/rules-of-hooks': 'error', // Checks rules of Hooks | ||
'react-hooks/exhaustive-deps': 'warn', // Checks effect dependencies | ||
'@typescript-eslint/explicit-member-accessibility': 1, | ||
'@typescript-eslint/no-empty-interface': 1, | ||
'@typescript-eslint/explicit-function-return-type': [ | ||
'error', | ||
{ | ||
allowTypedFunctionExpressions: true, | ||
}, | ||
], | ||
'@typescript-eslint/no-explicit-any': 0, | ||
'@typescript-eslint/no-use-before-define': [ | ||
2, | ||
{ | ||
functions: true, | ||
classes: true, | ||
variables: false, | ||
}, | ||
], | ||
'@typescript-eslint/no-unused-vars': [ | ||
1, | ||
{ | ||
args: 'none', | ||
}, | ||
], | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
module.exports = { | ||
bracketSpacing: true, // 对象大括号直接是否有空格,默认为true,效果:{ foo: bar } | ||
jsxBracketSameLine: true, | ||
singleQuote: true, // 字符串是否使用单引号,默认为false,使用双引号 | ||
trailingComma: 'all', // 是否使用尾逗号,有三个可选值"<none|es5|all>" | ||
semi: true, // 行位是否使用分号,默认为true | ||
printWidth: 120, // 一行的字符数,如果超过会进行换行,默认为80 | ||
tabWidth: 4, // 一个tab代表几个空格数 | ||
endOfLine: 'auto', | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,8 @@ | ||
module.exports = { | ||
presets: ['module:metro-react-native-babel-preset'], | ||
module.exports = api => { | ||
api.cache(true); | ||
|
||
return { | ||
presets: ['module:metro-react-native-babel-preset'], | ||
plugins: ['babel-plugin-root-import'], | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.