Closed FadhlanR closed 1 month ago
what's your eslint config look like?
I tried this config but it still didn't catch this.pauseTest()
.
module.exports = {
root: true,
env: {
browser: true,
},
overrides: [
{
files: ['**/*.{js,ts}'],
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
babelOptions: {
plugins: [
['@babel/plugin-proposal-decorators', { decoratorsBeforeExport: true }],
],
},
},
plugins: [
'ember',
'@typescript-eslint',
'simple-import-sort',
'typescript-sort-keys',
],
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
'plugin:typescript-sort-keys/recommended',
'plugin:prettier/recommended',
'plugin:ember/recommended',
],
rules: {
curly: 'error',
'simple-import-sort/exports': 'error',
'simple-import-sort/imports': 'error',
'prefer-const': 'off',
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-unused-vars': [
'error',
{ argsIgnorePattern: '^_', varsIgnorePattern: '^_' },
],
},
},
{
files: ['**/*.gts'],
parser: 'ember-eslint-parser',
plugins: ['ember'],
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:ember/recommended',
'plugin:ember/recommended-gts',
],
rules: {
curly: 'error',
'simple-import-sort/exports': 'error',
'simple-import-sort/imports': 'error',
'prefer-const': 'off',
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-unused-vars': [
'error',
{ argsIgnorePattern: '^_', varsIgnorePattern: '^_' },
],
},
},
// node files
{
files: [
'./.eslintrc.cjs',
'./.prettierrc.cjs',
'./.template-lintrc.cjs',
'./addon-main.cjs',
],
parserOptions: {
sourceType: 'script',
},
env: {
browser: false,
node: true,
},
extends: ['plugin:n/recommended'],
rules: {
'n/no-unpublished-require': 'off',
'@typescript-eslint/no-var-requires': 'off',
},
},
{
// typescript-eslint recommends turning off no-undef for Typescript files since
// Typescript will better analyse that:
// https://github.com/typescript-eslint/typescript-eslint/blob/5b0e577f2552e8b2c53a3fb22edc9d219589b937/docs/linting/Troubleshooting.mdx#i-get-errors-from-the-no-undef-rule-about-global-variables-not-being-defined-even-though-there-are-no-typescript-errors
files: ['**/*.ts', '**/*.gts'],
rules: {
'no-undef': 'off',
},
},
],
};
Thanks!
I've confirmed there is an issue on my polaris starter here: https://github.com/NullVoxPopuli/polaris-starter/tree/webpack
with only this repro:
import { module, test } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
module('...', function (hooks) {
setupRenderingTest(hooks);
test('...', async function (assert) {
await this.pauseTest();
assert.ok(true);
});
});
I would but that there is a bug in isTestFile
that eslint-plugin-ember uses:
if (!emberUtils.isTestFile(context.getFilename())) {
return {};
}
I just opened: https://github.com/ember-cli/eslint-plugin-ember/pull/2147
can you try that fix locally?
I just opened: #2147
can you try that fix locally?
I've tried it locally and it works. Thanks!
I identified this issue when I opened a PR and forgot to remove
this.pauseTest()
from the test and there was no error from lint check. After investigation, I realizedno-pause-test
is only applied for test files and the wayeslint-plugin-ember
identifies it using this functionisTestFile
. I think we should update conditions in that function to include test files with.gts
and.gjs
extension. If my understanding is correct, I'm happy to open a PR to fix it.