|
| 1 | +/** |
| 2 | + * Debugging: |
| 3 | + * https://eslint.org/docs/latest/use/configure/debug |
| 4 | + * ---------------------------------------------------- |
| 5 | + * |
| 6 | + * Print a file's calculated configuration |
| 7 | + * |
| 8 | + * npx eslint --print-config path/to/file.js |
| 9 | + * |
| 10 | + * Inspecting the config |
| 11 | + * |
| 12 | + * npx eslint --inspect-config |
| 13 | + * |
| 14 | + */ |
| 15 | +import babelParser from '@babel/eslint-parser'; |
| 16 | +import js from '@eslint/js'; |
| 17 | +import prettier from 'eslint-config-prettier'; |
| 18 | +import ember from 'eslint-plugin-ember/recommended'; |
| 19 | +import importPlugin from 'eslint-plugin-import'; |
| 20 | +import n from 'eslint-plugin-n'; |
| 21 | +import globals from 'globals'; |
| 22 | +import ts from 'typescript-eslint'; |
| 23 | + |
| 24 | +const parserOptions = { |
| 25 | + esm: { |
| 26 | + js: { |
| 27 | + ecmaFeatures: { modules: true }, |
| 28 | + ecmaVersion: 'latest', |
| 29 | + }, |
| 30 | + ts: { |
| 31 | + projectService: true, |
| 32 | + project: true, |
| 33 | + tsconfigRootDir: import.meta.dirname, |
| 34 | + }, |
| 35 | + }, |
| 36 | +}; |
| 37 | + |
| 38 | +export default ts.config( |
| 39 | + js.configs.recommended, |
| 40 | + ember.configs.base, |
| 41 | + ember.configs.gjs, |
| 42 | + ember.configs.gts, |
| 43 | + prettier, |
| 44 | + /** |
| 45 | + * Ignores must be in their own object |
| 46 | + * https://eslint.org/docs/latest/use/configure/ignore |
| 47 | + */ |
| 48 | + { |
| 49 | + ignores: ['dist/', 'declarations/', 'node_modules/', 'coverage/', '!**/.*'], |
| 50 | + }, |
| 51 | + /** |
| 52 | + * https://eslint.org/docs/latest/use/configure/configuration-files#configuring-linter-options |
| 53 | + */ |
| 54 | + { |
| 55 | + linterOptions: { |
| 56 | + reportUnusedDisableDirectives: 'error', |
| 57 | + }, |
| 58 | + }, |
| 59 | + { |
| 60 | + files: ['**/*.js'], |
| 61 | + languageOptions: { |
| 62 | + parser: babelParser, |
| 63 | + }, |
| 64 | + }, |
| 65 | + { |
| 66 | + files: ['**/*.{js,gjs}'], |
| 67 | + languageOptions: { |
| 68 | + parserOptions: parserOptions.esm.js, |
| 69 | + globals: { |
| 70 | + ...globals.browser, |
| 71 | + }, |
| 72 | + }, |
| 73 | + }, |
| 74 | + { |
| 75 | + files: ['**/*.{ts,gts}'], |
| 76 | + languageOptions: { |
| 77 | + parser: ember.parser, |
| 78 | + parserOptions: parserOptions.esm.ts, |
| 79 | + }, |
| 80 | + extends: [...ts.configs.recommendedTypeChecked, ember.configs.gts], |
| 81 | + }, |
| 82 | + { |
| 83 | + files: ['src/**/*'], |
| 84 | + plugins: { |
| 85 | + import: importPlugin, |
| 86 | + }, |
| 87 | + rules: { |
| 88 | + // require relative imports use full extensions |
| 89 | + 'import/extensions': ['error', 'always', { ignorePackages: true }], |
| 90 | + }, |
| 91 | + }, |
| 92 | + /** |
| 93 | + * CJS node files |
| 94 | + */ |
| 95 | + { |
| 96 | + files: [ |
| 97 | + '**/*.cjs', |
| 98 | + '.prettierrc.js', |
| 99 | + '.stylelintrc.js', |
| 100 | + '.template-lintrc.js', |
| 101 | + 'addon-main.cjs', |
| 102 | + ], |
| 103 | + plugins: { |
| 104 | + n, |
| 105 | + }, |
| 106 | + |
| 107 | + languageOptions: { |
| 108 | + sourceType: 'script', |
| 109 | + ecmaVersion: 'latest', |
| 110 | + globals: { |
| 111 | + ...globals.node, |
| 112 | + }, |
| 113 | + }, |
| 114 | + }, |
| 115 | + /** |
| 116 | + * ESM node files |
| 117 | + */ |
| 118 | + { |
| 119 | + files: ['**/*.mjs'], |
| 120 | + plugins: { |
| 121 | + n, |
| 122 | + }, |
| 123 | + |
| 124 | + languageOptions: { |
| 125 | + sourceType: 'module', |
| 126 | + ecmaVersion: 'latest', |
| 127 | + parserOptions: parserOptions.esm.js, |
| 128 | + globals: { |
| 129 | + ...globals.node, |
| 130 | + }, |
| 131 | + }, |
| 132 | + }, |
| 133 | +); |
0 commit comments