|
| 1 | +/** @type {import("eslint").ESLint.ConfigData}*/ |
| 2 | +module.exports = { |
| 3 | + root: true, |
| 4 | + parser: '@typescript-eslint/parser', |
| 5 | + parserOptions: { |
| 6 | + project: './tsconfig.json', |
| 7 | + }, |
| 8 | + extends: [ |
| 9 | + 'eslint:recommended', |
| 10 | + 'standard', |
| 11 | + 'plugin:import/errors', |
| 12 | + 'plugin:import/recommended', |
| 13 | + 'plugin:import/typescript', |
| 14 | + 'plugin:@typescript-eslint/stylistic', |
| 15 | + 'plugin:@typescript-eslint/recommended', |
| 16 | + "plugin:prettier/recommended", |
| 17 | + ], |
| 18 | + plugins: [ |
| 19 | + '@stylistic', |
| 20 | + '@typescript-eslint', |
| 21 | + 'unused-imports', |
| 22 | + 'import', |
| 23 | + 'jsdoc', |
| 24 | + ], |
| 25 | + env: { |
| 26 | + es6: true, |
| 27 | + node: true, |
| 28 | + }, |
| 29 | + ignorePatterns: [ |
| 30 | + 'dist', |
| 31 | + 'node_modules', |
| 32 | + '.eslintrc.*', |
| 33 | + 'rollup', |
| 34 | + 'rollup.config.*', |
| 35 | + 'setupTests.ts', |
| 36 | + 'jest.setup.*', |
| 37 | + 'jest.config.*', |
| 38 | + // temporarily disable lint on __tests__ |
| 39 | + '__tests__', |
| 40 | + // will enable lint by packages |
| 41 | + // 'adapter-nextjs', |
| 42 | + 'analytics', |
| 43 | + 'api', |
| 44 | + 'api-graphql', |
| 45 | + 'auth', |
| 46 | + 'aws-amplify', |
| 47 | + 'core', |
| 48 | + 'datastore', |
| 49 | + 'datastore-storage-adapter', |
| 50 | + 'geo', |
| 51 | + 'interactions', |
| 52 | + 'notifications', |
| 53 | + 'predictions', |
| 54 | + 'pubsub', |
| 55 | + 'react-native', |
| 56 | + 'rtn-push-notification', |
| 57 | + 'rtn-web-browser', |
| 58 | + 'storage', |
| 59 | + ], |
| 60 | + rules: { |
| 61 | + camelcase: [ |
| 62 | + 'error', |
| 63 | + { |
| 64 | + allow: [ |
| 65 | + 'graphql_headers', |
| 66 | + // exceptions for the legacy config |
| 67 | + /^(aws_|amazon_)/, |
| 68 | + 'access_key', |
| 69 | + 'secret_key', |
| 70 | + 'session_token', |
| 71 | + // exceptions for the auth package |
| 72 | + 'redirect_uri', |
| 73 | + 'response_type', |
| 74 | + 'client_id', |
| 75 | + 'identity_provider', |
| 76 | + 'code_challenge', |
| 77 | + 'code_challenge_method', |
| 78 | + 'grant_type', |
| 79 | + 'code_verifier', |
| 80 | + 'logout_uri', |
| 81 | + 'id_token', |
| 82 | + 'access_token', |
| 83 | + 'token_type', |
| 84 | + 'expires_in', |
| 85 | + 'error_description', |
| 86 | + // exceptions for the notifications package |
| 87 | + 'campaign_id', |
| 88 | + 'delivery_type', |
| 89 | + 'treatment_id', |
| 90 | + 'campaign_activity_id', |
| 91 | + ], |
| 92 | + }, |
| 93 | + ], |
| 94 | + 'import/no-deprecated': 'warn', |
| 95 | + 'import/no-empty-named-blocks': 'error', |
| 96 | + 'import/no-mutable-exports': 'error', |
| 97 | + 'import/no-relative-packages': 'error', |
| 98 | + 'import/newline-after-import': 'error', |
| 99 | + 'import/order': ['error', { 'newlines-between': 'always' }], |
| 100 | + 'no-eval': 'error', |
| 101 | + 'no-param-reassign': 'error', |
| 102 | + 'no-shadow': 'off', |
| 103 | + 'no-use-before-define': 'off', |
| 104 | + 'no-useless-constructor': 'off', |
| 105 | + 'no-trailing-spaces': 'error', |
| 106 | + 'no-return-await': 'error', |
| 107 | + 'object-shorthand': 'error', |
| 108 | + 'prefer-destructuring': 'off', |
| 109 | + 'promise/catch-or-return': [ |
| 110 | + 'error', |
| 111 | + { terminationMethod: ['then', 'catch', 'asCallback', 'finally'] }, |
| 112 | + ], |
| 113 | + 'space-before-function-paren': 'off', |
| 114 | + 'sort-imports': ['error', { ignoreDeclarationSort: true }], |
| 115 | + 'unused-imports/no-unused-imports': 'error', |
| 116 | + 'unused-imports/no-unused-vars': [ |
| 117 | + 'error', |
| 118 | + { |
| 119 | + vars: 'all', |
| 120 | + varsIgnorePattern: '^_', |
| 121 | + args: 'after-used', |
| 122 | + argsIgnorePattern: '^_', |
| 123 | + }, |
| 124 | + ], |
| 125 | + 'valid-typeof': ['error', { requireStringLiterals: false }], |
| 126 | + '@stylistic/comma-dangle': [ |
| 127 | + 'error', |
| 128 | + { |
| 129 | + arrays: 'always-multiline', |
| 130 | + objects: 'always-multiline', |
| 131 | + imports: 'always-multiline', |
| 132 | + exports: 'always-multiline', |
| 133 | + functions: 'always-multiline', |
| 134 | + enums: 'always-multiline', |
| 135 | + generics: 'always-multiline', |
| 136 | + tuples: 'always-multiline', |
| 137 | + }, |
| 138 | + ], |
| 139 | + '@stylistic/function-call-argument-newline': ['error', 'consistent'], |
| 140 | + '@stylistic/indent': 'off', |
| 141 | + '@stylistic/max-len': [ |
| 142 | + 'error', |
| 143 | + { |
| 144 | + code: 120, |
| 145 | + ignoreComments: true, |
| 146 | + ignoreUrls: true, |
| 147 | + ignoreStrings: true, |
| 148 | + ignoreTemplateLiterals: true, |
| 149 | + ignoreRegExpLiterals: true, |
| 150 | + }, |
| 151 | + ], |
| 152 | + '@stylistic/padding-line-between-statements': [ |
| 153 | + 'error', |
| 154 | + { blankLine: 'always', prev: '*', next: 'return' }, |
| 155 | + ], |
| 156 | + '@typescript-eslint/method-signature-style': ['error', 'method'], |
| 157 | + '@typescript-eslint/no-confusing-void-expression': 'error', |
| 158 | + '@typescript-eslint/no-explicit-any': 'off', |
| 159 | + '@typescript-eslint/no-namespace': ['error', { allowDeclarations: true }], |
| 160 | + '@typescript-eslint/no-shadow': 'error', |
| 161 | + '@typescript-eslint/no-var-requires': 'off', |
| 162 | + '@typescript-eslint/no-unused-vars': 'off', |
| 163 | + '@typescript-eslint/no-use-before-define': [ |
| 164 | + 'error', |
| 165 | + { functions: false, variables: false, classes: false }, |
| 166 | + ], |
| 167 | + '@typescript-eslint/no-useless-constructor': 'error', |
| 168 | + '@typescript-eslint/prefer-destructuring': [ |
| 169 | + 'error', |
| 170 | + { object: true, array: false }, |
| 171 | + ], |
| 172 | + '@typescript-eslint/space-before-function-paren': [ |
| 173 | + 'error', |
| 174 | + { anonymous: 'never', named: 'never', asyncArrow: 'always' }, |
| 175 | + ], |
| 176 | + 'jsdoc/no-undefined-types': 1, |
| 177 | + }, |
| 178 | + settings: { |
| 179 | + 'import/parsers': { |
| 180 | + '@typescript-eslint/parser': ['.ts', '.tsx'], |
| 181 | + }, |
| 182 | + 'import/resolver': { |
| 183 | + typescript: { |
| 184 | + alwaysTryTypes: true, |
| 185 | + project: ['packages/*/tsconfig.json', 'tsconfig.json'], |
| 186 | + }, |
| 187 | + }, |
| 188 | + 'import/ignore': ['react-native'], |
| 189 | + }, |
| 190 | +}; |
0 commit comments