Skip to content

feat(formatting): adding editor config, adding eslint and tslint #344

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 25, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# http://editorconfig.org

root = true

[*]
charset = utf-8
indent_style = space
indent_size = 2
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

[*.md]
insert_final_newline = false
trim_trailing_whitespace = false
11 changes: 11 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"ecmaFeatures": {
"modules": true,
"module": true
},
"env": {
"mocha": true,
"node": true,
"es6": true
}
}
7 changes: 4 additions & 3 deletions addon/ng2/blueprints/component-test/index.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
module.exports = {
description: '',

// ******************************************************
// ******************************************************
// LEAVE THIS HERE
// Must override install to prevent ember's component tests
// ******************************************************
// ******************************************************

install: function(options){}

install: function () {
}
};
13 changes: 6 additions & 7 deletions addon/ng2/blueprints/component/index.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,28 @@
var stringUtils = require('ember-cli/lib/utilities/string');
var dynamicPathParser = require('../../utilities/dynamic-path-parser');

module.exports = {
description: '',

normalizeEntityName: function(entityName) {
normalizeEntityName: function (entityName) {
var parsedPath = dynamicPathParser(this.project, entityName);

this.dynamicPath = parsedPath;
return parsedPath.name;
},

locals: function(options) {
locals: function () {
return {
dynamicPath: this.dynamicPath.dir
};
},

fileMapTokens: function(options) {
fileMapTokens: function () {
// Return custom template variables here.
return {
__name__: (options) => {
__name__: () => {
return this.dynamicPath.name;
},
__path__: (options) => {
__path__: () => {
return this.dynamicPath.dir;
}
};
Expand Down
13 changes: 6 additions & 7 deletions addon/ng2/blueprints/directive/index.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,28 @@
var stringUtils = require('ember-cli/lib/utilities/string');
var dynamicPathParser = require('../../utilities/dynamic-path-parser');

module.exports = {
description: '',

normalizeEntityName: function(entityName) {
normalizeEntityName: function (entityName) {
var parsedPath = dynamicPathParser(this.project, entityName);

this.dynamicPath = parsedPath;
return parsedPath.name;
},

locals: function(options) {
locals: function () {
return {
dynamicPath: this.dynamicPath.dir
};
},

fileMapTokens: function(options) {
fileMapTokens: function () {
// Return custom template variables here.
return {
__name__: (options) => {
__name__: () => {
return this.dynamicPath.name;
},
__path__: (options) => {
__path__: () => {
return this.dynamicPath.dir;
}
};
Expand Down
26 changes: 14 additions & 12 deletions addon/ng2/blueprints/ng2/files/karma-test-shim.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
/*global jasmine, __karma__, window*/
Error.stackTraceLimit = Infinity;

jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000;

__karma__.loaded = function() {};
__karma__.loaded = function () {
};

System.config({
packages: {
Expand All @@ -11,30 +13,30 @@ System.config({
format: 'register',
map: Object.keys(window.__karma__.files)
.filter(onlyAppFiles)
.reduce(function(pathsMapping, appPath) {
.reduce(function (pathsMapping, appPath) {
var moduleName = appPath.replace(/^\/base\/dist\/app\//, './').replace(/\.js$/, '');
pathsMapping[moduleName] = appPath + '?' + window.__karma__.files[appPath]
return pathsMapping;
}, {})
pathsMapping[moduleName] = appPath + '?' + window.__karma__.files[appPath];
return pathsMapping;
}, {})
}
}
});

System.import('angular2/testing').then(function(testing) {
return System.import('angular2/platform/testing/browser').then(function(providers) {
System.import('angular2/testing').then(function (testing) {
return System.import('angular2/platform/testing/browser').then(function (providers) {
testing.setBaseTestProviders(providers.TEST_BROWSER_PLATFORM_PROVIDERS,
providers.TEST_BROWSER_APPLICATION_PROVIDERS);
providers.TEST_BROWSER_APPLICATION_PROVIDERS);
});
}).then(function() {
}).then(function () {
return Promise.all(
Object.keys(window.__karma__.files)
.filter(onlySpecFiles)
.map(function(moduleName) {
.map(function (moduleName) {
return System.import(moduleName);
}));
}).then(function() {
}).then(function () {
__karma__.start();
}, function(error) {
}, function (error) {
__karma__.error(error.stack || error);
});

Expand Down
40 changes: 20 additions & 20 deletions addon/ng2/blueprints/ng2/files/karma.conf.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = function(config) {
module.exports = function (config) {
config.set({
basePath: '',
frameworks: ['jasmine'],
Expand All @@ -9,39 +9,39 @@ module.exports = function(config) {
customLaunchers: {
// chrome setup for travis CI using chromium
Chrome_travis_ci: {
base: 'Chrome',
flags: ['--no-sandbox']
},
base: 'Chrome',
flags: ['--no-sandbox']
}
},
files: [
{pattern: 'node_modules/systemjs/dist/system-polyfills.js', included: true, watched: true},
{pattern: 'node_modules/systemjs/dist/system.src.js', included: true, watched: true},
{pattern: 'node_modules/es6-shim/es6-shim.js', included: true, watched: true},
{pattern: 'node_modules/angular2/bundles/angular2-polyfills.js', included: true, watched: true},
{pattern: 'node_modules/rxjs/bundles/Rx.js', included: true, watched: true},
{pattern: 'node_modules/angular2/bundles/angular2.js', included: true, watched: true},
{pattern: 'node_modules/angular2/bundles/http.dev.js', included: true, watched: true},
{pattern: 'node_modules/angular2/bundles/router.dev.js', included: true, watched: true},
{pattern: 'node_modules/angular2/bundles/testing.dev.js', included: true, watched: true},
{ pattern: 'node_modules/systemjs/dist/system-polyfills.js', included: true, watched: true },
{ pattern: 'node_modules/systemjs/dist/system.src.js', included: true, watched: true },
{ pattern: 'node_modules/es6-shim/es6-shim.js', included: true, watched: true },
{ pattern: 'node_modules/angular2/bundles/angular2-polyfills.js', included: true, watched: true },
{ pattern: 'node_modules/rxjs/bundles/Rx.js', included: true, watched: true },
{ pattern: 'node_modules/angular2/bundles/angular2.js', included: true, watched: true },
{ pattern: 'node_modules/angular2/bundles/http.dev.js', included: true, watched: true },
{ pattern: 'node_modules/angular2/bundles/router.dev.js', included: true, watched: true },
{ pattern: 'node_modules/angular2/bundles/testing.dev.js', included: true, watched: true },


{pattern: 'karma-test-shim.js', included: true, watched: true},
{ pattern: 'karma-test-shim.js', included: true, watched: true },

// paths loaded via module imports
{pattern: 'dist/**/*.js', included: false, watched: true},
{ pattern: 'dist/**/*.js', included: false, watched: true },

// paths loaded via Angular's component compiler
// (these paths need to be rewritten, see proxies section)
{pattern: 'dist/**/*.html', included: false, watched: true},
{pattern: 'dist/**/*.css', included: false, watched: true},
{ pattern: 'dist/**/*.html', included: false, watched: true },
{ pattern: 'dist/**/*.css', included: false, watched: true },

// paths to support debugging with source maps in dev tools
{pattern: 'dist/**/*.ts', included: false, watched: false},
{pattern: 'dist/**/*.js.map', included: false, watched: false}
{ pattern: 'dist/**/*.ts', included: false, watched: false },
{ pattern: 'dist/**/*.js.map', included: false, watched: false }
],
proxies: {
// required for component assets fetched by Angular's compiler
"/app/": "/base/dist/app/"
'/app/': '/base/dist/app/'
},
exclude: [],
preprocessors: {},
Expand Down
3 changes: 2 additions & 1 deletion addon/ng2/blueprints/ng2/files/protractor.conf.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/*global jasmine */
var SpecReporter = require('jasmine-spec-reporter');

exports.config = {
Expand All @@ -24,5 +25,5 @@ exports.config = {
},
onPrepare: function() {
jasmine.getEnv().addReporter(new SpecReporter());
},
}
};
10 changes: 5 additions & 5 deletions addon/ng2/blueprints/ng2/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ module.exports = {
description: '',

locals: function(options) {
// Return custom template variables here.
return {
htmlComponentName: stringUtils.dasherize(options.entity.name),
jsComponentName: stringUtils.classify(options.entity.name)
};
// Return custom template variables here.
return {
htmlComponentName: stringUtils.dasherize(options.entity.name),
jsComponentName: stringUtils.classify(options.entity.name)
};
}

// afterInstall: function(options) {
Expand Down
17 changes: 7 additions & 10 deletions addon/ng2/blueprints/pipe/index.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,26 @@
var stringUtils = require('ember-cli/lib/utilities/string');
var dynamicPathParser = require('../../utilities/dynamic-path-parser');

module.exports = {
description: '',

normalizeEntityName: function(entityName) {
normalizeEntityName: function (entityName) {
var parsedPath = dynamicPathParser(this.project, entityName);

this.dynamicPath = parsedPath;
return parsedPath.name;
},

locals: function(options) {
return {
dynamicPath: this.dynamicPath.dir
};
locals: function () {
return { dynamicPath: this.dynamicPath.dir };
},

fileMapTokens: function(options) {
fileMapTokens: function () {
// Return custom template variables here.
return {
__name__: (options) => {
__name__: () => {
return this.dynamicPath.name;
},
__path__: (options) => {
__path__: () => {
return this.dynamicPath.dir;
}
};
Expand Down
24 changes: 12 additions & 12 deletions addon/ng2/blueprints/route-config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ module.exports = {
try {
fs.unlinkSync(routeConfigPath);
} catch (e) {
// doing nothing here
}
}
};
Expand All @@ -23,17 +24,16 @@ function generateLocals(options) {
var ngCliConfigPath = path.join(options.project.root, 'angular-cli.json');
var ngCliConfig = JSON.parse(fs.readFileSync(ngCliConfigPath, 'utf-8'));

imports = ngCliConfig.routes.map(route =>
`import {${route.component}} from '${route.componentPath}';`)
.join('\n');
imports =
ngCliConfig.routes.map(route => `import {${route.component}} from '${route.componentPath}';`)
.join('\n');

routeDefinitions = ngCliConfig.routes.map(route =>
`{path: '${route.routePath}', name: '${route.component}', component: ${route.component}},`
)
.join('\n');
routeDefinitions =
ngCliConfig.routes
.map(
route =>
`{path: '${route.routePath}', name: '${route.component}', component: ${route.component}},`)
.join('\n');

return {
imports,
routeDefinitions
}
}
return { imports, routeDefinitions }
}
9 changes: 4 additions & 5 deletions addon/ng2/blueprints/route-test/index.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
var stringUtils = require('ember-cli/lib/utilities/string');

module.exports = {
description: '',

// ******************************************************
// ******************************************************
// LEAVE THIS HERE
// Must override install to prevent ember's route tests
// ******************************************************
// ******************************************************

install: function(options){}

install: function () {
}
};
Loading