Skip to content

Commit

Permalink
[Tests] named: Add direct test for export = assignment in TS
Browse files Browse the repository at this point in the history
Closes #1984.
  • Loading branch information
ProdigySim authored and ljharb committed Apr 7, 2022
1 parent 116af31 commit a8781f7
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 1 deletion.
5 changes: 5 additions & 0 deletions tests/files/typescript-export-assign-object/index.ts
@@ -0,0 +1,5 @@
const someObj = {
FooBar: 12,
};

export = someObj;
5 changes: 5 additions & 0 deletions tests/files/typescript-export-assign-object/tsconfig.json
@@ -0,0 +1,5 @@
{
"compilerOptions": {
"esModuleInterop": true
}
}
37 changes: 36 additions & 1 deletion tests/src/rules/named.js
@@ -1,5 +1,6 @@
import { test, SYNTAX_CASES, getTSParsers, testFilePath, testVersion, parsers } from '../utils';
import { RuleTester } from 'eslint';
import path from 'path';

import { CASE_SENSITIVE_FS } from 'eslint-module-utils/resolve';

Expand Down Expand Up @@ -388,7 +389,16 @@ context('TypeScript', function () {
'import/resolver': { 'eslint-import-resolver-typescript': true },
};

let valid = [];
let valid = [
test({
code: `import x from './typescript-export-assign-object'`,
parser,
parserOptions: {
tsconfigRootDir: path.resolve(__dirname, '../../files/typescript-export-assign-object/'),
},
settings,
}),
];
const invalid = [
// TODO: uncomment this test
// test({
Expand All @@ -400,6 +410,31 @@ context('TypeScript', function () {
// { message: 'a not found in ./export-star-3/b' },
// ],
// }),
test({
code: `import { NotExported } from './typescript-export-assign-object'`,
parser,
parserOptions: {
tsconfigRootDir: path.resolve(__dirname, '../../files/typescript-export-assign-object/'),
},
settings,
errors: [{
message: `NotExported not found in './typescript-export-assign-object'`,
type: 'Identifier',
}],
}),
test({
// `export =` syntax creates a default export only
code: `import { FooBar } from './typescript-export-assign-object'`,
parser,
parserOptions: {
tsconfigRootDir: path.resolve(__dirname, '../../files/typescript-export-assign-object/'),
},
settings,
errors: [{
message: `FooBar not found in './typescript-export-assign-object'`,
type: 'Identifier',
}],
}),
];

[
Expand Down

0 comments on commit a8781f7

Please sign in to comment.