This repository was archived by the owner on Jul 15, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +6
-3
lines changed Expand file tree Collapse file tree 3 files changed +6
-3
lines changed Original file line number Diff line number Diff line change 1
1
import * as ts from 'typescript' ;
2
2
import * as Lint from 'tslint' ;
3
3
4
+ import { AstUtils } from './utils/AstUtils' ;
4
5
import { ErrorTolerantWalker } from './utils/ErrorTolerantWalker' ;
5
6
import { ExtendedMetadata } from './utils/ExtendedMetadata' ;
6
7
@@ -37,7 +38,8 @@ class NoFunctionExpressionRuleWalker extends ErrorTolerantWalker {
37
38
38
39
constructor ( sourceFile : ts . SourceFile , options : Lint . IOptions ) {
39
40
super ( sourceFile , options ) ;
40
- if ( sourceFile . fileName . endsWith ( 'tsx' ) ) {
41
+
42
+ if ( AstUtils . getLanguageVariant ( sourceFile ) === ts . LanguageVariant . JSX ) {
41
43
this . allowGenericFunctionExpression = true ;
42
44
}
43
45
}
Original file line number Diff line number Diff line change 1
1
import * as ts from 'typescript' ;
2
2
import * as Lint from 'tslint' ;
3
3
4
+ import { AstUtils } from './utils/AstUtils' ;
4
5
import { ErrorTolerantWalker } from './utils/ErrorTolerantWalker' ;
5
6
import { ExtendedMetadata } from './utils/ExtendedMetadata' ;
6
7
@@ -34,7 +35,7 @@ export class Rule extends Lint.Rules.AbstractRule {
34
35
35
36
class PreferTypeCastRuleWalker extends ErrorTolerantWalker {
36
37
protected visitSourceFile ( node : ts . SourceFile ) : void {
37
- if ( / . * \. t s x / . test ( node . fileName ) === false ) {
38
+ if ( AstUtils . getLanguageVariant ( node ) === ts . LanguageVariant . Standard ) {
38
39
super . visitSourceFile ( node ) ;
39
40
}
40
41
}
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ import * as ts from 'typescript';
6
6
export module AstUtils {
7
7
8
8
export function getLanguageVariant ( node : ts . SourceFile ) : ts . LanguageVariant {
9
- if ( / . * \. t s x / i . test ( node . fileName ) ) {
9
+ if ( node . fileName . endsWith ( '.tsx' ) ) {
10
10
return ts . LanguageVariant . JSX ;
11
11
} else {
12
12
return ts . LanguageVariant . Standard ;
You can’t perform that action at this time.
0 commit comments