Skip to content

Commit de4861d

Browse files
committed
Apply typescript-eslint's recommended config to gts files
"Patch" `typescript-eslint`'s recommended config to allow us to extend it to `gts` files, and also add test cases to verify that we're applying the ruleset to both `ts` and `gts` files. This is the equivalent of ember-cli/ember-addon-blueprint#120 for this repo
1 parent 415b14c commit de4861d

File tree

4 files changed

+45
-1
lines changed

4 files changed

+45
-1
lines changed

files/_ts_eslint.config.mjs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,15 @@ export default defineConfig([
7777
parser: ember.parser,
7878
parserOptions: parserOptions.esm.ts,
7979
},
80-
extends: [...ts.configs.recommendedTypeChecked, ember.configs.gts],
80+
extends: [
81+
...ts.configs.recommendedTypeChecked,
82+
// https://github.com/ember-cli/ember-addon-blueprint/issues/119
83+
{
84+
...ts.configs.eslintRecommended,
85+
files: undefined,
86+
},
87+
ember.configs.gts,
88+
],
8189
},
8290
{
8391
files: ['tests/**/*-test.{js,gjs,ts,gts}'],
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/**
2+
* This file is used to ensure that `eslint.config.mjs` is properly configured
3+
* to apply `typescript-eslint`'s recommended rules to `.gts` files. It ensures
4+
* that:
5+
*
6+
* - `no-undef` is disabled (otherwise the undefined symbol would cause a
7+
* linting error)
8+
* - `@typescript-eslint/no-unsafe-return` is enabled (otherwise the
9+
* `eslint-disable-next-line` comment would cause a linting error)
10+
*/
11+
export default function () {
12+
// @ts-expect-error testing lint
13+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
14+
return notDefined;
15+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/**
2+
* This file is used to ensure that `eslint.config.mjs` is properly configured
3+
* to apply `typescript-eslint`'s recommended rules to `.ts` files. It ensures
4+
* that:
5+
*
6+
* - `no-undef` is disabled (otherwise the undefined symbol would cause a
7+
* linting error)
8+
* - `@typescript-eslint/no-unsafe-return` is enabled (otherwise the
9+
* `eslint-disable-next-line` comment would cause a linting error)
10+
*/
11+
export default function () {
12+
// @ts-expect-error testing lint
13+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
14+
return notDefined;
15+
}

tests/lint.test.mjs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { beforeAll, describe, it, expect } from 'vitest';
22

33
import { generateApp } from './helpers.mjs';
4+
import fixturify from 'fixturify';
45

56
describe('linting & formatting', function () {
67
describe('JavaScript', function () {
@@ -39,6 +40,11 @@ describe('linting & formatting', function () {
3940
flags: ['--typescript', '--pnpm'],
4041
skipNpm: false,
4142
});
43+
44+
fixturify.writeSync(
45+
app.dir,
46+
fixturify.readSync('./tests/fixtures/lint-ts'),
47+
);
4248
});
4349

4450
it('yields output without errors', async function (context) {

0 commit comments

Comments
 (0)