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

Commit 79e08cc

Browse files
committed
Breaking: No prefix on FnDec within namespace (fixes #127)
1 parent aec31cb commit 79e08cc

File tree

5 files changed

+46
-41
lines changed

5 files changed

+46
-41
lines changed

Diff for: lib/convert.js

-7
Original file line numberDiff line numberDiff line change
@@ -622,13 +622,6 @@ module.exports = function convert(config) {
622622
}
623623
}
624624

625-
/**
626-
* Prefix FunctionDeclarations within TypeScript namespaces with "TS"
627-
*/
628-
if (node.parent && node.parent.kind === SyntaxKind.ModuleBlock) {
629-
functionDeclarationType = AST_NODE_TYPES.TSNamespaceFunctionDeclaration;
630-
}
631-
632625
Object.assign(result, {
633626
type: functionDeclarationType,
634627
id: convertChild(node.name),

Diff for: tests/ast-alignment/fixtures-to-test.js

+2-7
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ let fixturesRequiringSourceTypeModule = [];
4040
/**
4141
* Utility to generate a FixturePatternConfig object containing the glob pattern for specific subsections of the fixtures/ directory,
4242
* including the capability to ignore specific nested patterns.
43-
*
43+
*
4444
* @param {string} fixturesSubPath the sub-path within the fixtures/ directory
4545
* @param {Object?} config an optional configuration object with optional sub-paths to ignore and/or parse with sourceType: module
4646
* @returns {FixturePatternConfig} an object containing the glob pattern and optional additional config
@@ -466,12 +466,7 @@ let fixturePatternConfigsToTest = [
466466
* Babylon: TSDeclareFunction
467467
* tsep: TSNamespaceFunctionDeclaration
468468
*/
469-
"declare-namespace-with-exported-function",
470-
/**
471-
* Babylon: FunctionDeclaration
472-
* tsep: TSNamespaceFunctionDeclaration
473-
*/
474-
"module-with-default-exports"
469+
"declare-namespace-with-exported-function"
475470
]
476471
})
477472
];

Diff for: tests/integration/typescript.spec.js

+34-17
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,40 @@ describe("TypeScript", () => {
157157
);
158158
});
159159

160+
it("should correctly apply no-unreachable on TS-constructs (#127)", () => {
161+
verifyAndAssertMessages(
162+
unpad(`
163+
export namespace foo {
164+
export function bar() {
165+
return;
166+
}
167+
}
168+
export type Qux = true;
169+
`),
170+
{
171+
"no-unreachable": 2
172+
},
173+
[]
174+
);
175+
});
176+
177+
it("should correctly apply no-unreachable on TS-constructs (#127)", () => {
178+
verifyAndAssertMessages(
179+
unpad(`
180+
export namespace foo {
181+
export function bar() {
182+
return;
183+
}
184+
}
185+
export type Qux = true;
186+
`),
187+
{
188+
"no-unreachable": 2
189+
},
190+
[]
191+
);
192+
});
193+
160194
// it("should not produce a false positive for no-restricted-globals rule (#350)", () => {
161195
// verifyAndAssertMessages(
162196
// unpad(`
@@ -171,23 +205,6 @@ describe("TypeScript", () => {
171205
// );
172206
// });
173207

174-
// it("should correctly apply no-unreachable on TS-constructs (#127)", () => {
175-
// verifyAndAssertMessages(
176-
// unpad(`
177-
// export namespace foo {
178-
// export function bar() {
179-
// return;
180-
// }
181-
// }
182-
// export type Qux = true;
183-
// `),
184-
// {
185-
// "no-unreachable": 2
186-
// },
187-
// []
188-
// );
189-
// });
190-
191208
// it("should not throw a TypeError in the indent rule for invalid code (#309)", () => {
192209
// verifyAndAssertMessages(
193210
// unpad(`

Diff for: tests/lib/__snapshots__/typescript.js.snap

+9-9
Original file line numberDiff line numberDiff line change
@@ -1179,7 +1179,7 @@ Object {
11791179
},
11801180
},
11811181
},
1182-
"type": "FunctionExpression",
1182+
"type": "TSEmptyBodyFunctionExpression",
11831183
},
11841184
},
11851185
],
@@ -2478,7 +2478,7 @@ Object {
24782478
},
24792479
},
24802480
},
2481-
"type": "FunctionExpression",
2481+
"type": "TSEmptyBodyFunctionExpression",
24822482
},
24832483
},
24842484
],
@@ -12300,7 +12300,7 @@ Object {
1230012300
18,
1230112301
21,
1230212302
],
12303-
"type": "FunctionExpression",
12303+
"type": "TSEmptyBodyFunctionExpression",
1230412304
},
1230512305
},
1230612306
Object {
@@ -12396,7 +12396,7 @@ Object {
1239612396
"type": "TSStringKeyword",
1239712397
},
1239812398
},
12399-
"type": "FunctionExpression",
12399+
"type": "TSEmptyBodyFunctionExpression",
1240012400
},
1240112401
},
1240212402
Object {
@@ -12493,7 +12493,7 @@ Object {
1249312493
"type": "TSStringKeyword",
1249412494
},
1249512495
},
12496-
"type": "FunctionExpression",
12496+
"type": "TSEmptyBodyFunctionExpression",
1249712497
},
1249812498
},
1249912499
],
@@ -19988,7 +19988,7 @@ Object {
1998819988
"type": "TSAnyKeyword",
1998919989
},
1999019990
},
19991-
"type": "FunctionExpression",
19991+
"type": "TSEmptyBodyFunctionExpression",
1999219992
},
1999319993
},
1999419994
],
@@ -20409,7 +20409,7 @@ Object {
2040920409
"type": "TSStringKeyword",
2041020410
},
2041120411
},
20412-
"type": "DeclareFunction",
20412+
"type": "TSEmptyBodyDeclareFunction",
2041320413
},
2041420414
],
2041520415
"loc": Object {
@@ -62800,7 +62800,7 @@ Object {
6280062800
},
6280162801
},
6280262802
},
62803-
"type": "TSNamespaceFunctionDeclaration",
62803+
"type": "TSEmptyBodyFunctionDeclaration",
6280462804
},
6280562805
"loc": Object {
6280662806
"end": Object {
@@ -63500,7 +63500,7 @@ Object {
6350063500
93,
6350163501
110,
6350263502
],
63503-
"type": "TSNamespaceFunctionDeclaration",
63503+
"type": "FunctionDeclaration",
6350463504
},
6350563505
"loc": Object {
6350663506
"end": Object {

Diff for: tools/test-utils.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ function createSnapshotTestBlock(code, config) {
4747
* @returns {Object} the AST object
4848
*/
4949
function parse() {
50-
const ast = parser.parse(code, config);
50+
const ast = parser.parseForESLint(code, config).ast;
5151
return getRaw(ast);
5252
}
5353

0 commit comments

Comments
 (0)