Skip to content

Commit

Permalink
fix(config): do not process non-css/html by default
Browse files Browse the repository at this point in the history
Fix #181
Fix #186

Drop the `SyntaxKind`.
  • Loading branch information
mgechev committed Dec 10, 2016
1 parent 28059b1 commit d5f117e
Show file tree
Hide file tree
Showing 9 changed files with 66 additions and 2,490 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@
},
"homepage": "https://github.com/mgechev/codelyzer#readme",
"devDependencies": {
"@angular/compiler": "^2.2.0",
"@angular/core": "^2.2.0",
"@angular/compiler": "^2.3.0",
"@angular/core": "^2.3.0",
"@types/chai": "^3.4.33",
"@types/less": "0.0.31",
"@types/mocha": "^2.2.32",
Expand All @@ -62,7 +62,7 @@
"rxjs": "5.0.0-rc.4",
"ts-node": "1.2.2",
"tslint": "~4.0.0",
"typescript": "^2.0.3",
"typescript": "^2.1.4",
"zone.js": "^0.7.2"
},
"peerDependencies": {
Expand Down
10 changes: 8 additions & 2 deletions src/angular/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,17 @@ export const Config: Config = {
},

transformTemplate(code: string, url: string, d: ts.Decorator) {
return { code, url };
if (!url || url.endsWith('.html')) {
return { code, url };
}
return { code: '', url };
},

transformStyle(code: string, url: string, d: ts.Decorator) {
return { code, url };
if (!url || url.endsWith('.css')) {
return { code, url };
}
return { code: '', url };
},

predefinedDirectives: [
Expand Down
16 changes: 14 additions & 2 deletions src/angular/templates/templateParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export const parseTemplate = (template: string, directives: { selector: string,
const interpolation = Config.interpolation;

// Make sure it works with 2.2.x & 2.3.x
const summaryKind = ((compiler.CompileSummaryKind as any) || {}).Template;
const summaryKind = ((compiler as any).CompileSummaryKind || {}).Template;
const templateMetadata: compiler.CompileTemplateMetadata = {
encapsulation: 0,
template: template,
Expand All @@ -78,7 +78,19 @@ export const parseTemplate = (template: string, directives: { selector: string,
};

// Make sure it works with 2.2.x & 2.3.x
const type = { diDeps: [], lifecycleHooks: [], reference: null };
const type = {
diDeps: [],
lifecycleHooks: [],
reference: null,

// Used by Angular 2.2.x
isHost: false,
name: '',
prefix: '',
moduleUrl: '',
value: '',
identifier: null
};
return tmplParser.tryParse(
compiler.CompileDirectiveMetadata.create({ type, template: templateMetadata }),
template, defaultDirectives, [], [NO_ERRORS_SCHEMA], '').templateAst;
Expand Down
Loading

0 comments on commit d5f117e

Please sign in to comment.