Skip to content

Commit

Permalink
Fix TS Lint config
Browse files Browse the repository at this point in the history
  • Loading branch information
NullVoxPopuli committed Sep 30, 2024
1 parent 73679b5 commit e87af43
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 22 deletions.
5 changes: 5 additions & 0 deletions files-override/ts/app/app.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Application from '@ember/application';
// @ts-expect-error - TODO: add types to compatModules
import compatModules from '@embroider/core/entrypoint';
import Resolver from 'ember-resolver';
import loadInitializers from 'ember-load-initializers';
Expand All @@ -7,7 +8,11 @@ import config from './config/environment';
export default class App extends Application {
modulePrefix = config.modulePrefix;
podModulePrefix = config.podModulePrefix;
// TODO: remove lint disable when we have types for compatModules
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
Resolver = Resolver.withModules(compatModules);
}

// TODO: remove lint disable when we have types for compatModules
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
loadInitializers(App, config.modulePrefix, compatModules);
59 changes: 38 additions & 21 deletions files-override/ts/eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,27 @@ import n from 'eslint-plugin-n';
import emberParser from 'ember-eslint-parser';
import babelParser from '@babel/eslint-parser';

const esmParserOptions = {
ecmaFeatures: { modules: true },
ecmaVersion: 'latest',
const parserOptions = {
esm: {
js: {
ecmaFeatures: { modules: true },
ecmaVersion: 'latest',
},
ts: {
projectService: true,
tsconfigRootDir: import.meta.dirname,
},
},
};

export default [
export default ts.config(
js.configs.recommended,
prettier,
{
ignores: ['dist/', 'node_modules/', 'coverage/', '!**/.*'],
linterOptions: {
reportUnusedDisableDirectives: 'error',
},
},
{
files: ['**/*.js'],
languageOptions: {
parser: babelParser,
parserOptions: esmParserOptions,
parserOptions: parserOptions.esm.js,
globals: {
...globals.browser,
},
Expand All @@ -45,16 +47,19 @@ export default [
...emberRecommended.rules,
},
},
...ts.config({
{
files: ['**/*.ts'],
plugins: { ember },
extends: [...ts.configs.strictTypeChecked, emberRecommended],
}),
languageOptions: {
parserOptions: parserOptions.esm.ts,
},
extends: [...ts.configs.strictTypeChecked, ...emberRecommended],
},
{
files: ['**/*.gjs'],
languageOptions: {
parser: emberParser,
parserOptions: esmParserOptions,
parserOptions: parserOptions.esm.js,
globals: {
...globals.browser,
},
Expand All @@ -67,15 +72,18 @@ export default [
...gjsRecommended.rules,
},
},
...ts.config({
{
files: ['**/*.gts'],
plugins: { ember },
languageOptions: {
parserOptions: parserOptions.esm.ts,
},
extends: [
...ts.configs.strictTypeChecked,
emberRecommended,
gtsRecommended,
...emberRecommended,
...gtsRecommended,
],
}),
},
{
files: ['tests/**/*-test.{js,gjs}'],
plugins: {
Expand Down Expand Up @@ -120,10 +128,19 @@ export default [
languageOptions: {
sourceType: 'module',
ecmaVersion: 'latest',
parserOptions: esmParserOptions,
parserOptions: parserOptions.esm.js,
globals: {
...globals.node,
},
},
},
];
/**
* Settings
*/
{
ignores: ['dist/', 'node_modules/', 'coverage/', '!**/.*'],
linterOptions: {
reportUnusedDisableDirectives: 'error',
},
},
);
5 changes: 4 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,10 @@ module.exports = {
...(options.typescript
? [
'@babel/plugin-transform-typescript',
'typescript',
// TODO: see if there is a better way we can
// sync these libraries' versions
// typescript-eslint doesn't support typescript 5.6 yet
'typescript@~5.5.0',
'@glint/core@unstable',
'@glint/environment-ember-loose@unstable', // currently required :(
'@glint/environment-ember-template-imports@unstable',
Expand Down

0 comments on commit e87af43

Please sign in to comment.