Merge pull request #8 from wwelling/tslint-warnings

Looks good, merging
This commit is contained in:
Art Lowel
2016-12-05 14:24:16 +01:00
committed by GitHub
20 changed files with 69 additions and 66 deletions

View File

@@ -27,7 +27,3 @@ Currently this contains the [Angular 2 Universal Starter](https://github.com/ang
## AoT and Prod ## AoT and Prod
- `npm run build:prod:ngc` to compile the ngfactory files and build prod - `npm run build:prod:ngc` to compile the ngfactory files and build prod

View File

@@ -3,5 +3,5 @@
"dist", "dist",
"src/index.html" "src/index.html"
], ],
"ext" : "js ts json html" "ext": "js ts json html"
} }

View File

@@ -6,9 +6,9 @@
* found in the LICENSE file at https://angular.io/license * found in the LICENSE file at https://angular.io/license
*/ */
import {Injectable} from '@angular/core'; import { Injectable } from '@angular/core';
// es6-modules are used here // es6-modules are used here
import {DomAdapter, getDOM} from '@angular/platform-browser/src/dom/dom_adapter'; import { DomAdapter, getDOM } from '@angular/platform-browser/src/dom/dom_adapter';
/** /**
* Represent meta element. * Represent meta element.
@@ -69,7 +69,7 @@ export class Meta {
* @param tags * @param tags
* @returns {HTMLMetaElement[]} * @returns {HTMLMetaElement[]}
*/ */
addTags(...tags: Array<MetaDefinition|MetaDefinition[]>): HTMLMetaElement[] { addTags(...tags: Array<MetaDefinition | MetaDefinition[]>): HTMLMetaElement[] {
const presentTags = this._flattenArray(tags); const presentTags = this._flattenArray(tags);
if (presentTags.length === 0) return []; if (presentTags.length === 0) return [];
return presentTags.map((tag: MetaDefinition) => this._addInternal(tag)); return presentTags.map((tag: MetaDefinition) => this._addInternal(tag));

View File

@@ -8,7 +8,7 @@ import { AppComponent } from './app.component';
@NgModule({ @NgModule({
declarations: [ AppComponent ], declarations: [AppComponent],
imports: [ imports: [
SharedModule, SharedModule,
HomeModule, HomeModule,

View File

@@ -4,7 +4,7 @@ import { Component, ChangeDetectionStrategy, ViewEncapsulation } from '@angular/
changeDetection: ChangeDetectionStrategy.Default, changeDetection: ChangeDetectionStrategy.Default,
encapsulation: ViewEncapsulation.Emulated, encapsulation: ViewEncapsulation.Emulated,
selector: 'ds-home', selector: 'ds-home',
styleUrls: [ './home.component.css' ], styleUrls: ['./home.component.css'],
templateUrl: './home.component.html' templateUrl: './home.component.html'
}) })
export class HomeComponent { export class HomeComponent {

View File

@@ -4,7 +4,7 @@ import { Inject, Injectable, isDevMode } from '@angular/core';
export class CacheService { export class CacheService {
static KEY = 'CacheService'; static KEY = 'CacheService';
constructor(@Inject('LRU') public _cache: Map<string, any>) { constructor( @Inject('LRU') public _cache: Map<string, any>) {
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

View File

@@ -1,9 +1,9 @@
var util = require('util'); var util = require('util');
var {Router} = require('express'); var { Router } = require('express');
// Our API for demos only // Our API for demos only
import {fakeDataBase} from './db'; import { fakeDataBase } from './db';
import {fakeDemoRedisCache} from './cache'; import { fakeDemoRedisCache } from './cache';
// you would use cookies/token etc // you would use cookies/token etc
var USER_ID = 'f9d98cf1-1b96-464e-8755-bcc2a5c09077'; // hardcoded as an example var USER_ID = 'f9d98cf1-1b96-464e-8755-bcc2a5c09077'; // hardcoded as an example
@@ -51,7 +51,7 @@ export function createTodoApi() {
}) })
.post(function(req, res) { .post(function(req, res) {
console.log('POST', util.inspect(req.body, {colors: true})); console.log('POST', util.inspect(req.body, { colors: true }));
var todo = req.body; var todo = req.body;
if (todo) { if (todo) {
TODOS.push({ TODOS.push({
@@ -81,12 +81,12 @@ export function createTodoApi() {
router.route('/todos/:todo_id') router.route('/todos/:todo_id')
.get(function(req, res) { .get(function(req, res) {
console.log('GET', util.inspect(req.todo, {colors: true})); console.log('GET', util.inspect(req.todo, { colors: true }));
res.json(req.todo); res.json(req.todo);
}) })
.put(function(req, res) { .put(function(req, res) {
console.log('PUT', util.inspect(req.body, {colors: true})); console.log('PUT', util.inspect(req.body, { colors: true }));
var index = TODOS.indexOf(req.todo); var index = TODOS.indexOf(req.todo);
var todo = TODOS[index] = req.body; var todo = TODOS[index] = req.body;

View File

@@ -1,5 +1,6 @@
<!doctype html> <!doctype html>
<html> <html>
<head> <head>
<title>DSpace</title> <title>DSpace</title>
<meta charset="UTF-8"> <meta charset="UTF-8">
@@ -10,6 +11,7 @@
<base href="/"> <base href="/">
</head> </head>
<body> <body>
<ds-app> <ds-app>
@@ -18,4 +20,5 @@
<script async src="/main.bundle.js"></script> <script async src="/main.bundle.js"></script>
</body> </body>
</html> </html>

View File

@@ -55,10 +55,10 @@ app.set('json spaces', 2);
app.use(cookieParser('Angular 2 Universal')); app.use(cookieParser('Angular 2 Universal'));
app.use(bodyParser.json()); app.use(bodyParser.json());
app.use(interceptor((req, res)=>({ app.use(interceptor((req, res) => ({
// don't compress responses with this request header // don't compress responses with this request header
isInterceptable: () => (!req.headers['x-no-compression']), isInterceptable: () => (!req.headers['x-no-compression']),
intercept: ( body, send ) => { intercept: (body, send) => {
const encodings = new Set(accepts(req).encodings()); const encodings = new Set(accepts(req).encodings());
const bodyBuffer = new Buffer(body); const bodyBuffer = new Buffer(body);
// url specific key for response cache // url specific key for response cache
@@ -71,12 +71,12 @@ app.use(interceptor((req, res)=>({
// brotli // brotli
res.setHeader('Content-Encoding', 'br'); res.setHeader('Content-Encoding', 'br');
output = compressSync(bodyBuffer); output = compressSync(bodyBuffer);
mcache.put(key, {output, encoding: 'br'}); mcache.put(key, { output, encoding: 'br' });
} else if (encodings.has('gzip')) { } else if (encodings.has('gzip')) {
// gzip // gzip
res.setHeader('Content-Encoding', 'gzip'); res.setHeader('Content-Encoding', 'gzip');
output = gzipSync(bodyBuffer); output = gzipSync(bodyBuffer);
mcache.put(key, {output, encoding: 'gzip'}); mcache.put(key, { output, encoding: 'gzip' });
} }
} else { } else {
const { output, encoding } = mcache.get(key); const { output, encoding } = mcache.get(key);
@@ -87,7 +87,7 @@ app.use(interceptor((req, res)=>({
} }
}))); })));
const accessLogStream = fs.createWriteStream(ROOT + '/morgan.log', {flags: 'a'}) const accessLogStream = fs.createWriteStream(ROOT + '/morgan.log', { flags: 'a' })
app.use(morgan('common', { app.use(morgan('common', {
skip: (req, res) => res.statusCode < 400, skip: (req, res) => res.statusCode < 400,
@@ -100,8 +100,8 @@ function cacheControl(req, res, next) {
next(); next();
} }
// Serve static files // Serve static files
app.use('/assets', cacheControl, express.static(path.join(__dirname, 'assets'), {maxAge: 30})); app.use('/assets', cacheControl, express.static(path.join(__dirname, 'assets'), { maxAge: 30 }));
app.use(cacheControl, express.static(path.join(ROOT, 'dist/client'), {index: false})); app.use(cacheControl, express.static(path.join(ROOT, 'dist/client'), { index: false }));
// //
///////////////////////// /////////////////////////
@@ -120,7 +120,7 @@ function ngApp(req, res) {
preboot: false, preboot: false,
baseUrl: '/', baseUrl: '/',
requestUrl: req.originalUrl, requestUrl: req.originalUrl,
originUrl: `http://localhost:${ app.get('port') }` originUrl: `http://localhost:${app.get('port')}`
}); });
} }

View File

@@ -57,8 +57,8 @@ function cacheControl(req, res, next) {
next(); next();
} }
// Serve static files // Serve static files
app.use('/assets', cacheControl, express.static(path.join(__dirname, 'assets'), {maxAge: 30})); app.use('/assets', cacheControl, express.static(path.join(__dirname, 'assets'), { maxAge: 30 }));
app.use(cacheControl, express.static(path.join(ROOT, 'dist/client'), {index: false})); app.use(cacheControl, express.static(path.join(ROOT, 'dist/client'), { index: false }));
// //
///////////////////////// /////////////////////////
@@ -77,7 +77,7 @@ function ngApp(req, res) {
preboot: false, preboot: false,
baseUrl: '/', baseUrl: '/',
requestUrl: req.originalUrl, requestUrl: req.originalUrl,
originUrl: `http://localhost:${ app.get('port') }` originUrl: `http://localhost:${app.get('port')}`
}); });
} }

8
src/typings.d.ts vendored
View File

@@ -39,7 +39,7 @@ interface SystemJS {
// Extra variables that live on Global that will be replaced by webpack DefinePlugin // Extra variables that live on Global that will be replaced by webpack DefinePlugin
declare var ENV: string; declare var ENV: string;
declare var HMR: boolean; declare var HMR: boolean;
declare var Zone: {current: any}; declare var Zone: { current: any };
interface GlobalEnvironment { interface GlobalEnvironment {
ENV; ENV;
HMR; HMR;
@@ -68,6 +68,6 @@ interface WebpackRequire {
} }
// Extend typings // Extend typings
interface NodeRequire extends WebpackRequire {} interface NodeRequire extends WebpackRequire { }
interface NodeModule extends WebpackModule {} interface NodeModule extends WebpackModule { }
interface Global extends GlobalEnvironment {} interface Global extends GlobalEnvironment { }

View File

@@ -24,5 +24,7 @@
}, },
"compileOnSave": false, "compileOnSave": false,
"buildOnSave": false, "buildOnSave": false,
"atom": { "rewriteTsconfig": false } "atom": {
"rewriteTsconfig": false
}
} }

View File

@@ -23,5 +23,7 @@
}, },
"compileOnSave": false, "compileOnSave": false,
"buildOnSave": false, "buildOnSave": false,
"atom": { "rewriteTsconfig": false } "atom": {
"rewriteTsconfig": false
}
} }

View File

@@ -6,13 +6,13 @@
"directive-selector": [ "directive-selector": [
true, true,
"attribute", "attribute",
"dspace", "ds",
"camelCase" "camelCase"
], ],
"component-selector": [ "component-selector": [
true, true,
"element", "element",
"dspace", "ds",
"kebab-case" "kebab-case"
], ],
"use-input-property-decorator": true, "use-input-property-decorator": true,
@@ -27,7 +27,7 @@
"pipe-naming": [ "pipe-naming": [
true, true,
"camelCase", "camelCase",
"dspace" "ds"
], ],
"component-class-suffix": true, "component-class-suffix": true,
"directive-class-suffix": true, "directive-class-suffix": true,

View File

@@ -171,8 +171,8 @@ export const serverConfig = {
export default [ export default [
// Client // Client
webpackMerge(webpackConfig[0], clone(commonConfig), clientConfig, {plugins: webpackConfig[0].plugins.concat(commonPlugins, clientPlugins) }), webpackMerge(webpackConfig[0], clone(commonConfig), clientConfig, { plugins: webpackConfig[0].plugins.concat(commonPlugins, clientPlugins) }),
// Server // Server
webpackMerge(webpackConfig[1], clone(commonConfig), serverConfig, {plugins: webpackConfig[1].plugins.concat(commonPlugins, serverPlugins) }) webpackMerge(webpackConfig[1], clone(commonConfig), serverConfig, { plugins: webpackConfig[1].plugins.concat(commonPlugins, serverPlugins) })
]; ];