|
| 1 | +/* [object Object]*/ module.exports = { |
| 2 | + root: true, |
| 3 | + parser: '@typescript-eslint/parser', |
| 4 | + parserOptions: { |
| 5 | + ecmaVersion: 'latest', |
| 6 | + sourceType: 'module', |
| 7 | + requireConfigFile: false, |
| 8 | + }, |
| 9 | + env: { |
| 10 | + node: true, |
| 11 | + mocha: true, |
| 12 | + es2024: true, |
| 13 | + }, |
| 14 | + plugins: ['@typescript-eslint', '@stylistic', 'unicorn', 'header', 'security-node'], |
| 15 | + extends: [ |
| 16 | + 'eslint:recommended', |
| 17 | + 'plugin:@typescript-eslint/eslint-recommended', |
| 18 | + 'plugin:@typescript-eslint/recommended', |
| 19 | + 'plugin:prettier/recommended', |
| 20 | + ], |
| 21 | + rules: { |
| 22 | + curly: 2, // Enforce braces on "if"/"for"/etc. |
| 23 | + 'id-length': [ |
| 24 | + 'error', |
| 25 | + { |
| 26 | + min: 1, |
| 27 | + max: 40, |
| 28 | + exceptionPatterns: [ |
| 29 | + '^INSERT_TO_CURSOR_POSITION_NOTIFICATION_METHOD$', |
| 30 | + '^DID_CHANGE_DEPENDENCY_PATHS_NOTIFICATION_METHOD$', |
| 31 | + ], |
| 32 | + }, |
| 33 | + ], |
| 34 | + // https://typescript-eslint.io/rules/naming-convention/ |
| 35 | + '@typescript-eslint/naming-convention': [ |
| 36 | + 'error', |
| 37 | + { |
| 38 | + selector: 'default', |
| 39 | + format: ['camelCase', 'PascalCase'], |
| 40 | + // Allow underscores. |
| 41 | + leadingUnderscore: 'allowSingleOrDouble', |
| 42 | + trailingUnderscore: 'allowSingleOrDouble', |
| 43 | + }, |
| 44 | + // Allow object properties, enums, and methods to have any format |
| 45 | + { |
| 46 | + selector: ['objectLiteralProperty', 'classMethod', 'enumMember'], |
| 47 | + format: null, |
| 48 | + }, |
| 49 | + // Allow constants to use UPPER_CASE |
| 50 | + { |
| 51 | + selector: 'variable', |
| 52 | + modifiers: ['const'], |
| 53 | + format: ['camelCase', 'PascalCase', 'UPPER_CASE'], |
| 54 | + }, |
| 55 | + ], |
| 56 | + // Avoid accidental use of "==" instead of "===". |
| 57 | + eqeqeq: 'error', |
| 58 | + '@typescript-eslint/no-namespace': 'error', |
| 59 | + '@typescript-eslint/no-floating-promises': 'off', // Temporarily disabled |
| 60 | + '@typescript-eslint/no-redundant-type-constituents': 'off', // Temporarily disabled |
| 61 | + '@typescript-eslint/no-unused-vars': 'error', |
| 62 | + '@typescript-eslint/no-explicit-any': 'off', // Temporarily disabled |
| 63 | + // Do not check loops so while(true) works. |
| 64 | + 'no-constant-condition': ['error', { checkLoops: false }], |
| 65 | + |
| 66 | + // https://eslint.style/rules/default/spaced-comment |
| 67 | + // Require space after // comment. |
| 68 | + '@stylistic/spaced-comment': [ |
| 69 | + 'error', |
| 70 | + 'always', |
| 71 | + { |
| 72 | + block: { |
| 73 | + markers: ['!'], // Allow the /*!…*/ license header. |
| 74 | + }, |
| 75 | + }, |
| 76 | + ], |
| 77 | + |
| 78 | + // Rules from https://github.com/sindresorhus/eslint-plugin-unicorn |
| 79 | + 'unicorn/no-abusive-eslint-disable': 'error', |
| 80 | + 'unicorn/no-null': 'off', // Temporarily disabled |
| 81 | + 'unicorn/no-unnecessary-polyfills': 'error', |
| 82 | + 'unicorn/no-useless-spread': 'error', |
| 83 | + 'unicorn/prefer-array-some': 'error', |
| 84 | + 'unicorn/prefer-blob-reading-methods': 'error', |
| 85 | + 'unicorn/prefer-code-point': 'error', |
| 86 | + 'unicorn/prefer-date-now': 'error', |
| 87 | + 'unicorn/prefer-dom-node-text-content': 'error', |
| 88 | + 'unicorn/prefer-includes': 'error', |
| 89 | + 'unicorn/prefer-keyboard-event-key': 'error', |
| 90 | + 'unicorn/prefer-modern-dom-apis': 'error', |
| 91 | + 'unicorn/prefer-modern-math-apis': 'error', |
| 92 | + 'unicorn/prefer-native-coercion-functions': 'error', |
| 93 | + 'unicorn/prefer-reflect-apply': 'error', |
| 94 | + 'unicorn/prefer-string-trim-start-end': 'error', |
| 95 | + 'unicorn/prefer-type-error': 'error', |
| 96 | + // Discourage `.forEach` because it can lead to accidental, incorrect use of async callbacks. |
| 97 | + 'unicorn/no-array-for-each': 'error', |
| 98 | + 'security-node/detect-child-process': 'error', |
| 99 | + |
| 100 | + // TODO: do we want to enable this? |
| 101 | + // 'header/header': [ |
| 102 | + // 'error', |
| 103 | + // 'block', |
| 104 | + // { |
| 105 | + // pattern: |
| 106 | + // 'Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\\r?\\n \\* SPDX-License-Identifier: Apache-2.0', |
| 107 | + // }, |
| 108 | + // { lineEndings: 'unix' }, |
| 109 | + // ], |
| 110 | + |
| 111 | + 'prettier/prettier': ['error', { endOfLine: 'auto' }], |
| 112 | + }, |
| 113 | + ignorePatterns: ['node_modules/**', 'dist/**', 'out/**', 'coverage/**', '.vscode/**', '.git/**'], |
| 114 | +} |
0 commit comments