Skip to content
This repository has been archived by the owner on Jan 19, 2019. It is now read-only.

Commit

Permalink
Breaking: No prefix on FnDec within namespace (fixes #127) (#413)
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesHenry committed Dec 13, 2017
1 parent aec31cb commit 6698042
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 41 deletions.
7 changes: 0 additions & 7 deletions lib/convert.js
Expand Up @@ -622,13 +622,6 @@ module.exports = function convert(config) {
}
}

/**
* Prefix FunctionDeclarations within TypeScript namespaces with "TS"
*/
if (node.parent && node.parent.kind === SyntaxKind.ModuleBlock) {
functionDeclarationType = AST_NODE_TYPES.TSNamespaceFunctionDeclaration;
}

Object.assign(result, {
type: functionDeclarationType,
id: convertChild(node.name),
Expand Down
9 changes: 2 additions & 7 deletions tests/ast-alignment/fixtures-to-test.js
Expand Up @@ -40,7 +40,7 @@ let fixturesRequiringSourceTypeModule = [];
/**
* Utility to generate a FixturePatternConfig object containing the glob pattern for specific subsections of the fixtures/ directory,
* including the capability to ignore specific nested patterns.
*
*
* @param {string} fixturesSubPath the sub-path within the fixtures/ directory
* @param {Object?} config an optional configuration object with optional sub-paths to ignore and/or parse with sourceType: module
* @returns {FixturePatternConfig} an object containing the glob pattern and optional additional config
Expand Down Expand Up @@ -466,12 +466,7 @@ let fixturePatternConfigsToTest = [
* Babylon: TSDeclareFunction
* tsep: TSNamespaceFunctionDeclaration
*/
"declare-namespace-with-exported-function",
/**
* Babylon: FunctionDeclaration
* tsep: TSNamespaceFunctionDeclaration
*/
"module-with-default-exports"
"declare-namespace-with-exported-function"
]
})
];
Expand Down
34 changes: 17 additions & 17 deletions tests/integration/typescript.spec.js
Expand Up @@ -157,6 +157,23 @@ describe("TypeScript", () => {
);
});

it("should correctly apply no-unreachable on TS-constructs (#127)", () => {
verifyAndAssertMessages(
unpad(`
export namespace foo {
export function bar() {
return;
}
}
export type Qux = true;
`),
{
"no-unreachable": 2
},
[]
);
});

// it("should not produce a false positive for no-restricted-globals rule (#350)", () => {
// verifyAndAssertMessages(
// unpad(`
Expand All @@ -171,23 +188,6 @@ describe("TypeScript", () => {
// );
// });

// it("should correctly apply no-unreachable on TS-constructs (#127)", () => {
// verifyAndAssertMessages(
// unpad(`
// export namespace foo {
// export function bar() {
// return;
// }
// }
// export type Qux = true;
// `),
// {
// "no-unreachable": 2
// },
// []
// );
// });

// it("should not throw a TypeError in the indent rule for invalid code (#309)", () => {
// verifyAndAssertMessages(
// unpad(`
Expand Down
18 changes: 9 additions & 9 deletions tests/lib/__snapshots__/typescript.js.snap
Expand Up @@ -1179,7 +1179,7 @@ Object {
},
},
},
"type": "FunctionExpression",
"type": "TSEmptyBodyFunctionExpression",
},
},
],
Expand Down Expand Up @@ -2478,7 +2478,7 @@ Object {
},
},
},
"type": "FunctionExpression",
"type": "TSEmptyBodyFunctionExpression",
},
},
],
Expand Down Expand Up @@ -12300,7 +12300,7 @@ Object {
18,
21,
],
"type": "FunctionExpression",
"type": "TSEmptyBodyFunctionExpression",
},
},
Object {
Expand Down Expand Up @@ -12396,7 +12396,7 @@ Object {
"type": "TSStringKeyword",
},
},
"type": "FunctionExpression",
"type": "TSEmptyBodyFunctionExpression",
},
},
Object {
Expand Down Expand Up @@ -12493,7 +12493,7 @@ Object {
"type": "TSStringKeyword",
},
},
"type": "FunctionExpression",
"type": "TSEmptyBodyFunctionExpression",
},
},
],
Expand Down Expand Up @@ -19988,7 +19988,7 @@ Object {
"type": "TSAnyKeyword",
},
},
"type": "FunctionExpression",
"type": "TSEmptyBodyFunctionExpression",
},
},
],
Expand Down Expand Up @@ -20409,7 +20409,7 @@ Object {
"type": "TSStringKeyword",
},
},
"type": "DeclareFunction",
"type": "TSEmptyBodyDeclareFunction",
},
],
"loc": Object {
Expand Down Expand Up @@ -62800,7 +62800,7 @@ Object {
},
},
},
"type": "TSNamespaceFunctionDeclaration",
"type": "TSEmptyBodyFunctionDeclaration",
},
"loc": Object {
"end": Object {
Expand Down Expand Up @@ -63500,7 +63500,7 @@ Object {
93,
110,
],
"type": "TSNamespaceFunctionDeclaration",
"type": "FunctionDeclaration",
},
"loc": Object {
"end": Object {
Expand Down
2 changes: 1 addition & 1 deletion tools/test-utils.js
Expand Up @@ -47,7 +47,7 @@ function createSnapshotTestBlock(code, config) {
* @returns {Object} the AST object
*/
function parse() {
const ast = parser.parse(code, config);
const ast = parser.parseForESLint(code, config).ast;
return getRaw(ast);
}

Expand Down

0 comments on commit 6698042

Please sign in to comment.