UNPKG

1.95 kBJavaScriptView Raw
1/**
2 * TypeScript Configs:
3 * Extends Airbnb and uses Prettier for all formatting related linting.
4 * TypeScript parser is specified for ESLint and Prettier, rules that are better
5 * handled by TS compiler are turned off.
6 */
7const config = {
8 extends: ['airbnb', 'prettier', 'prettier/react'],
9 parserOptions: {
10 ecmaVersion: 8,
11 sourceType: 'module',
12 ecmaFeatures: {
13 jsx: true,
14 },
15 },
16 parser: 'typescript-eslint-parser',
17 plugins: ['prettier'],
18 // NOTE: Currently we are turning off the eslint-plugin-import rules. If the TS
19 // parser and the plugin are updated to the point that they work well together,
20 // these settings need to be included to override the Airbnb settings.
21 // settings: {
22 // 'import/resolver': {
23 // node: {
24 // extensions: ['.js', '.jsx', '.ts', '.tsx']
25 // }
26 // },
27 // 'import/extensions': ['.js', '.jsx', '.ts', '.tsx'],
28 // 'import/parsers': {
29 // 'typescript-eslint-parser': ['.ts', '.tsx']
30 // }
31 // },
32 env: {
33 browser: true,
34 node: true,
35 },
36 rules: {
37 // Allow use of named functions before declared, they are hoisted and this makes
38 // it possible to declare propTypes at top of component files
39 'no-use-before-define': ['error', { functions: false }],
40 // Allow console logs in development, and upgrade them to error in test
41 'no-console': 'off',
42
43 // Turn off ESLint rules handled by TypeScript compiler
44 'no-unused-vars': 'off',
45 'no-undef': 'off',
46
47 // Turn off eslint-plugin-import rules handled by TypeScript compiler
48 'import/no-unresolved': 'off',
49 'import/extensions': 'off',
50 'import/no-duplicates': 'off',
51 },
52}
53
54// Lint for prettier only in TEST envs
55if (process.env.NODE_ENV === 'test') {
56 Object.assign(config.rules, {
57 'prettier/prettier': [
58 'error',
59 { singleQuote: true, printWidth: 84, semi: false },
60 ],
61 'no-console': 'error',
62 })
63}
64
65module.exports = config