Skip to content
This repository was archived by the owner on Jun 13, 2023. It is now read-only.

Commit 9c71e5f

Browse files
author
Will Sabransky
committed
Update styles to match BFE
1 parent 6feabae commit 9c71e5f

File tree

9 files changed

+51
-97
lines changed

9 files changed

+51
-97
lines changed

packages/eslint-config-base/rules/best-practices.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ module.exports = {
2626
curly: ['error', 'multi-line'],
2727

2828
// require default case in switch statements
29-
'default-case': ['error', { commentPattern: '^no default$' }],
29+
'default-case': 'off',
3030

3131
// encourages use of dot notation whenever possible
3232
'dot-notation': ['error', { allowKeywords: true }],
@@ -260,7 +260,7 @@ module.exports = {
260260
'no-sequences': 'error',
261261

262262
// restrict what can be thrown as an exception
263-
'no-throw-literal': 'error',
263+
'no-throw-literal': 'off',
264264

265265
// disallow unmodified conditions of loops
266266
// https://eslint.org/docs/rules/no-unmodified-loop-condition

packages/eslint-config-base/rules/errors.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ module.exports = {
9393

9494
// disallow use of Object.prototypes builtins directly
9595
// https://eslint.org/docs/rules/no-prototype-builtins
96-
'no-prototype-builtins': 'error',
96+
'no-prototype-builtins': 'off',
9797

9898
// disallow multiple spaces in a regular expression literal
9999
'no-regex-spaces': 'error',

packages/eslint-config-base/rules/es6.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@ module.exports = {
2121

2222
// require parens in arrow function arguments
2323
// https://eslint.org/docs/rules/arrow-parens
24-
'arrow-parens': ['error', 'as-needed', {
25-
requireForBlockBody: true,
26-
}],
24+
'arrow-parens': 'off',
2725

2826
// require space before/after arrow function's arrow
2927
// https://eslint.org/docs/rules/arrow-spacing

packages/eslint-config-base/rules/imports.js

Lines changed: 5 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -69,28 +69,7 @@ module.exports = {
6969
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-extraneous-dependencies.md
7070
// paths are treated both as absolute paths, and relative to process.cwd()
7171
'import/no-extraneous-dependencies': ['error', {
72-
devDependencies: [
73-
'test/**', // tape, common npm pattern
74-
'tests/**', // also common npm pattern
75-
'spec/**', // mocha, rspec-like pattern
76-
'**/__tests__/**', // jest pattern
77-
'**/__mocks__/**', // jest pattern
78-
'test.{js,jsx}', // repos with a single test file
79-
'test-*.{js,jsx}', // repos with multiple top-level test files
80-
'**/*{.,_}{test,spec}.{js,jsx}', // tests where the extension or filename suffix denotes that it is a test
81-
'**/jest.config.js', // jest config
82-
'**/vue.config.js', // vue-cli config
83-
'**/webpack.config.js', // webpack config
84-
'**/webpack.config.*.js', // webpack config
85-
'**/rollup.config.js', // rollup config
86-
'**/rollup.config.*.js', // rollup config
87-
'**/gulpfile.js', // gulp config
88-
'**/gulpfile.*.js', // gulp config
89-
'**/Gruntfile{,.js}', // grunt config
90-
'**/protractor.conf.js', // protractor config
91-
'**/protractor.conf.*.js', // protractor config
92-
],
93-
optionalDependencies: false,
72+
devDependencies: ['**/*{.,_}{test,spec}.{js,jsx,ts,tsx}'],
9473
}],
9574

9675
// Forbid mutable exports
@@ -134,10 +113,11 @@ module.exports = {
134113

135114
// Ensure consistent use of file extension within the import path
136115
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/extensions.md
137-
'import/extensions': ['error', 'ignorePackages', {
116+
'import/extensions': ['error', 'always', {
138117
js: 'never',
139-
mjs: 'never',
140118
jsx: 'never',
119+
ts: 'never',
120+
tsx: 'never',
141121
}],
142122

143123
// ensure absolute imports are above relative imports and that unassigned imports are ignored
@@ -184,7 +164,7 @@ module.exports = {
184164

185165
// Forbid Webpack loader syntax in imports
186166
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-webpack-loader-syntax.md
187-
'import/no-webpack-loader-syntax': 'error',
167+
'import/no-webpack-loader-syntax': 'off',
188168

189169
// Prevent unassigned imports
190170
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-unassigned-import.md

packages/eslint-config-base/rules/style.js

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ module.exports = {
273273

274274
// disallow use of the continue statement
275275
// https://eslint.org/docs/rules/no-continue
276-
'no-continue': 'error',
276+
'no-continue': 'off',
277277

278278
// disallow comments inline after code
279279
'no-inline-comments': 'off',
@@ -331,25 +331,7 @@ module.exports = {
331331

332332
// disallow certain syntax forms
333333
// https://eslint.org/docs/rules/no-restricted-syntax
334-
'no-restricted-syntax': [
335-
'error',
336-
{
337-
selector: 'ForInStatement',
338-
message: 'for..in loops iterate over the entire prototype chain, which is virtually never what you want. Use Object.{keys,values,entries}, and iterate over the resulting array.',
339-
},
340-
{
341-
selector: 'ForOfStatement',
342-
message: 'iterators/generators require regenerator-runtime, which is too heavyweight for this guide to allow them. Separately, loops should be avoided in favor of array iterations.',
343-
},
344-
{
345-
selector: 'LabeledStatement',
346-
message: 'Labels are a form of GOTO; using them makes code confusing and hard to maintain and understand.',
347-
},
348-
{
349-
selector: 'WithStatement',
350-
message: '`with` is disallowed in strict mode because it makes code impossible to predict and optimize.',
351-
},
352-
],
334+
'no-restricted-syntax': 'off',
353335

354336
// disallow space between function identifier and application
355337
'no-spaced-func': 'error',

packages/eslint-config/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ module.exports = {
44
'@postmates/eslint-config-base/rules/strict',
55
'./rules/react',
66
'./rules/react-a11y',
7+
'./rules/typescript',
78
].map(require.resolve),
89
rules: {}
910
};

packages/eslint-config/package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,15 @@
5555
"in-publish": "^2.0.0",
5656
"react": ">= 0.13.0",
5757
"safe-publish-latest": "^1.1.2",
58-
"tape": "^4.9.1"
58+
"tape": "^4.9.1",
59+
"typescript-eslint-parser": "^21.0.2"
5960
},
6061
"peerDependencies": {
6162
"eslint": "^4.19.1 || ^5.3.0",
6263
"eslint-plugin-import": "^2.14.0",
6364
"eslint-plugin-jsx-a11y": "^6.1.1",
64-
"eslint-plugin-react": "^7.10.0"
65+
"eslint-plugin-react": "^7.10.0",
66+
"typescript-eslint-parser": "^21.0.2"
6567
},
6668
"engines": {
6769
"node": ">= 4"

packages/eslint-config/rules/react.js

Lines changed: 4 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -227,47 +227,7 @@ module.exports = {
227227

228228
// Enforce component methods order
229229
// https://github.com/yannickcr/eslint-plugin-react/blob/843d71a432baf0f01f598d7cf1eea75ad6896e4b/docs/rules/sort-comp.md
230-
'react/sort-comp': ['error', {
231-
order: [
232-
'static-methods',
233-
'instance-variables',
234-
'lifecycle',
235-
'/^on.+$/',
236-
'getters',
237-
'setters',
238-
'/^(get|set)(?!(InitialState$|DefaultProps$|ChildContext$)).+$/',
239-
'instance-methods',
240-
'everything-else',
241-
'rendering',
242-
],
243-
groups: {
244-
lifecycle: [
245-
'displayName',
246-
'propTypes',
247-
'contextTypes',
248-
'childContextTypes',
249-
'mixins',
250-
'statics',
251-
'defaultProps',
252-
'constructor',
253-
'getDefaultProps',
254-
'getInitialState',
255-
'state',
256-
'getChildContext',
257-
'componentWillMount',
258-
'componentDidMount',
259-
'componentWillReceiveProps',
260-
'shouldComponentUpdate',
261-
'componentWillUpdate',
262-
'componentDidUpdate',
263-
'componentWillUnmount',
264-
],
265-
rendering: [
266-
'/^render.+$/',
267-
'render'
268-
],
269-
},
270-
}],
230+
'react/sort-comp': 'off',
271231

272232
// Prevent missing parentheses around multilines JSX
273233
// https://github.com/yannickcr/eslint-plugin-react/blob/843d71a432baf0f01f598d7cf1eea75ad6896e4b/docs/rules/jsx-wrap-multilines.md
@@ -299,7 +259,7 @@ module.exports = {
299259

300260
// only .jsx files may have JSX
301261
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-filename-extension.md
302-
'react/jsx-filename-extension': ['error', { extensions: ['.jsx'] }],
262+
'react/jsx-filename-extension': ['error', { extensions: ['.jsx', '.tsx'] }],
303263

304264
// prevent accidental JS comments from being injected into JSX as text
305265
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-comment-textnodes.md
@@ -339,7 +299,7 @@ module.exports = {
339299

340300
// Require style prop value be an object or var
341301
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/style-prop-object.md
342-
'react/style-prop-object': 'error',
302+
'react/style-prop-object': 'off',
343303

344304
// Prevent invalid characters from appearing in markup
345305
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-unescaped-entities.md
@@ -365,7 +325,7 @@ module.exports = {
365325

366326
// Prevent usage of Array index in keys
367327
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-array-index-key.md
368-
'react/no-array-index-key': 'warn',
328+
'react/no-array-index-key': 'off',
369329

370330
// Enforce a defaultProps definition for every prop that is not a required prop
371331
// https://github.com/yannickcr/eslint-plugin-react/blob/843d71a432baf0f01f598d7cf1eea75ad6896e4b/docs/rules/require-default-props.md
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
module.exports = {
2+
env: {
3+
typescript: true
4+
},
5+
6+
overrides: [{
7+
parser: 'typescript-eslint-parser',
8+
files: ['*.ts', '*.tsx'],
9+
rules: {
10+
'no-useless-constructor': 'off',
11+
'no-undef': 'off',
12+
'no-unused-vars': 'off',
13+
'typescript/no-unused-vars': 'off',
14+
'react/prop-types': 'off',
15+
'no-param-reassign': 'off',
16+
'space-infix-ops': 'off',
17+
'import/export': 'off',
18+
'import/no-duplicates': 'off',
19+
'no-use-before-define': 'off',
20+
'no-shadow': 'off',
21+
'require-yield': 'off',
22+
'consistent-return': 'off',
23+
24+
'arrow-parens': 'error',
25+
'typescript/adjacent-overload-signatures': 'error',
26+
'typescript/member-delimiter-style': 'error',
27+
'typescript/no-angle-bracket-type-assertion': 'error',
28+
'typescript/type-annotation-spacing': 'error',
29+
}
30+
}]
31+
};

0 commit comments

Comments
 (0)