|
| 1 | + |
| 2 | +import eslint from '@eslint/js' |
| 3 | +import tseslint from 'typescript-eslint' |
| 4 | +import importPlugin from 'eslint-plugin-import' |
| 5 | +import jestPlugin from 'jest' |
| 6 | +import stylistic from '@stylistic/eslint-plugin' |
| 7 | + |
| 8 | + |
| 9 | +export default tseslint.config( |
| 10 | + eslint.configs.recommended, |
| 11 | + tseslint.configs.recommended, |
| 12 | + importPlugin.flatConfigs.recommended, |
| 13 | + { |
| 14 | + languageOptions: { |
| 15 | + parserOptions: { |
| 16 | + ecmaVersion: 2019, |
| 17 | + tsconfigRootDir: __dirname, |
| 18 | + project: ['./tsconfig.json', './tsconfig-test.json'], |
| 19 | + }, |
| 20 | + }, |
| 21 | + plugins: { |
| 22 | + jestPlugin, |
| 23 | + '@stylistic': stylistic, |
| 24 | + }, |
| 25 | + rules: { |
| 26 | + indent: 'off', |
| 27 | + '@stylistic/indent': [ |
| 28 | + 'error', |
| 29 | + 'tab', |
| 30 | + { |
| 31 | + FunctionDeclaration: { body: 1, parameters: 2 }, |
| 32 | + FunctionExpression: { body: 1, parameters: 2 }, |
| 33 | + SwitchCase: 1, |
| 34 | + }, |
| 35 | + ], |
| 36 | + 'linebreak-style': ['error', 'unix'], |
| 37 | + '@stylistic/quotes': [ |
| 38 | + 'error', |
| 39 | + 'single', |
| 40 | + { avoidEscape: true }, |
| 41 | + ], |
| 42 | + curly: ['error', 'all'], |
| 43 | + 'comma-dangle': [ |
| 44 | + 'error', |
| 45 | + 'always-multiline', |
| 46 | + ], |
| 47 | + 'no-console': 'error', |
| 48 | + 'no-process-exit': 'error', |
| 49 | + 'no-template-curly-in-string': 'error', |
| 50 | + 'require-await': 'off', |
| 51 | + '@stylistic/semi': ['error', 'never'], |
| 52 | + '@stylistic/member-delimiter-style': [ |
| 53 | + 'error', |
| 54 | + { |
| 55 | + multiline: { |
| 56 | + delimiter: 'none', |
| 57 | + requireLast: true, |
| 58 | + }, |
| 59 | + singleline: { |
| 60 | + delimiter: 'semi', |
| 61 | + requireLast: false, |
| 62 | + }, |
| 63 | + }, |
| 64 | + ], |
| 65 | + // Temporarily disabling while we switch from interface to type. |
| 66 | + // see https://github.com/SmartThingsCommunity/smartthings-core-sdk/issues/207 |
| 67 | + // '@typescript-eslint/consistent-type-definitions': ['error', 'type'], |
| 68 | + '@typescript-eslint/explicit-function-return-type': ['error', { |
| 69 | + allowExpressions: true, |
| 70 | + }], |
| 71 | + '@typescript-eslint/explicit-module-boundary-types': 'error', |
| 72 | + '@typescript-eslint/no-explicit-any': 'error', |
| 73 | + '@typescript-eslint/no-non-null-assertion': 'error', |
| 74 | + 'no-use-before-define': 'off', |
| 75 | + '@typescript-eslint/no-use-before-define': [ |
| 76 | + 'error', |
| 77 | + { functions: false, classes: false, enums: false, variables: true }, |
| 78 | + ], |
| 79 | + '@typescript-eslint/no-var-requires': 'error', |
| 80 | + '@typescript-eslint/ban-ts-comment': 'error', |
| 81 | + '@typescript-eslint/no-floating-promises': 'error', |
| 82 | + '@stylistic/space-infix-ops': 'error', |
| 83 | + '@stylistic/object-curly-spacing': ['error', 'always'], |
| 84 | + '@stylistic/comma-spacing': ['error'], |
| 85 | + '@stylistic/type-annotation-spacing': 'error', |
| 86 | + |
| 87 | + // disallow non-import statements appearing before import statements |
| 88 | + 'import/first': 'error', |
| 89 | + // Require a newline after the last import/require in a group |
| 90 | + 'import/newline-after-import': ['error', { 'count': 2 }], |
| 91 | + // Forbid import of modules using absolute paths |
| 92 | + 'import/no-absolute-path': 'error', |
| 93 | + // disallow AMD require/define |
| 94 | + 'import/no-amd': 'error', |
| 95 | + // Forbid the use of extraneous packages |
| 96 | + 'import/no-extraneous-dependencies': [ |
| 97 | + 'error', { |
| 98 | + devDependencies: true, |
| 99 | + peerDependencies: true, |
| 100 | + optionalDependencies: false, |
| 101 | + }, |
| 102 | + ], |
| 103 | + // Forbid mutable exports |
| 104 | + 'import/no-mutable-exports': 'error', |
| 105 | + // Prevent importing the default as if it were named |
| 106 | + 'import/no-named-default': 'error', |
| 107 | + // Prohibit named exports |
| 108 | + 'import/no-named-export': 'off', // we want everything to be a named export |
| 109 | + // Forbid a module from importing itself |
| 110 | + 'import/no-self-import': 'error', |
| 111 | + // Require modules with a single export to use a default export |
| 112 | + 'import/prefer-default-export': 'off', // we want everything to be named |
| 113 | + 'import/named': 'off', |
| 114 | + 'import/no-unresolved': ['off'], |
| 115 | + }, |
| 116 | + }, |
| 117 | +) |
0 commit comments