From 1281e4ea39c973d28d032fbfa6aac9a16c7ee0e1 Mon Sep 17 00:00:00 2001 From: Javi Gallego Date: Fri, 7 Oct 2016 10:13:03 +0200 Subject: [PATCH] prueba eslint --- .eslintrc.js | 10 +++ .vscode/settings.json | 5 ++ @salix/app/src/routes.js | 46 ++++++-------- @salix/app/src/spliting.js | 11 +++- @salix/crud/src/crud.js | 8 ++- @salix/crud/src/customer/index/add.html | 2 +- @salix/crud/src/customer/index/add.js | 27 ++++---- @salix/crud/src/customer/index/index.html | 3 +- @salix/crud/src/customer/index/index.js | 8 ++- @salix/crud/src/customer/index/list.html | 4 ++ @salix/crud/src/customer/index/list.js | 13 ++++ @salix/crud/src/customer/routes.js | 14 ++--- npm-debug.log | 27 -------- package.json | 23 ++++--- webpack.config.js | 76 +++++++++++------------ 15 files changed, 145 insertions(+), 132 deletions(-) create mode 100644 .eslintrc.js create mode 100644 .vscode/settings.json create mode 100644 @salix/crud/src/customer/index/list.html create mode 100644 @salix/crud/src/customer/index/list.js delete mode 100644 npm-debug.log diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 000000000..e1945c778 --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1,10 @@ +module.exports = { + "extends": "google", + "installedESLint": true, + "rules":{ + "indent": ["error", 4], + "require-jsdoc": 0 + } + + +}; \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 000000000..1396806be --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,5 @@ +// Coloque su configuración en este archivo para sobrescribir la configuración predeterminada y de usuario. +{ + // Carácter predeterminado de final de línea. + "files.eol": "\n" +} \ No newline at end of file diff --git a/@salix/app/src/routes.js b/@salix/app/src/routes.js index d0f3817f3..f39b5bf78 100644 --- a/@salix/app/src/routes.js +++ b/@salix/app/src/routes.js @@ -1,34 +1,24 @@ import * as core from '@salix/core'; - import * as spliting from './spliting'; -import {routes} from './fake'; +// import {routes} from './fake'; -core.module.config(function($stateProvider, $urlRouterProvider) { - - - core.splitingRegister.registerGraph('hello'); - - function xxx(route){ - return function loader($ocLazyLoad, $q){ - return $q((resolve) => { - core.splitingRegister.execute(route.module) - spliting[route.module](() => { - //resolve($ocLazyLoad.load({name: route.module})); - - }); +function config($stateProvider, $urlRouterProvider) { + function loader($ocLazyLoad, $q) { + return $q(resolve => { + spliting.crud(() => { + resolve($ocLazyLoad.load({name: 'crud'})); }); - }; + }); } - + $urlRouterProvider.otherwise("/"); - - routes.forEach(function(route) { - $stateProvider.state(route.state, { - url: route.url, - template :route.template, - resolve: { - loader: xxx(route) - } - }) - }, this); -}); + $stateProvider.state("index", { + url: '/index', + template: '', + resolve: { + loader: loader + } + }); +} + +core.module.config(config); diff --git a/@salix/app/src/spliting.js b/@salix/app/src/spliting.js index f60b2d5c3..5bc1ccd85 100644 --- a/@salix/app/src/spliting.js +++ b/@salix/app/src/spliting.js @@ -1,7 +1,16 @@ -import * as core from '@salix/core'; +//import * as core from '@salix/core'; +//TODO:quitar +export const crud = (cb) => { + require.ensure([], () => { + require('@salix/crud'); + cb(); + }, "salix.crud"); +}; +//END TODO + export const compras = (cb) => { require.ensure([], () => { require('@salix/compras') diff --git a/@salix/crud/src/crud.js b/@salix/crud/src/crud.js index 806f1c41a..44b4ad186 100644 --- a/@salix/crud/src/crud.js +++ b/@salix/crud/src/crud.js @@ -1,5 +1,9 @@ export * from './module'; export * from './customer/routes'; -export {NAME as CUSTOMER_INDEX, COMPONENT as CUSTOMER_INDEX_COMPONENT} from './customer/index' -export {NAME as CUSTOMER_ADD, COMPONENT as CUSTOMER_ADD_COMPONENT} from './customer/index/add' \ No newline at end of file +export {NAME as CUSTOMER_INDEX, + COMPONENT as CUSTOMER_INDEX_COMPONENT} from './customer/index'; +export {NAME as CUSTOMER_ADD, + COMPONENT as CUSTOMER_ADD_COMPONENT} from './customer/index/add'; +export {NAME as CUSTOMER_LIST, + COMPONENT as CUSTOMER_LIST_COMPONENT} from './customer/index/list'; diff --git a/@salix/crud/src/customer/index/add.html b/@salix/crud/src/customer/index/add.html index 308197934..abac96439 100644 --- a/@salix/crud/src/customer/index/add.html +++ b/@salix/crud/src/customer/index/add.html @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/@salix/crud/src/customer/index/add.js b/@salix/crud/src/customer/index/add.js index 903b4606f..cc38d08b9 100644 --- a/@salix/crud/src/customer/index/add.js +++ b/@salix/crud/src/customer/index/add.js @@ -1,16 +1,13 @@ -import template from './add.html'; -import {module} from '../../module'; - -export const NAME = 'customerAdd'; - -export const COMPONENT = { - template: template, - bindings :{ - users: '<' - }, - controller :function($scope, $element, $attrs){ - console.log(this.users); - } -}; - +import template from './add.html'; +import {module} from '../../module'; + +export const NAME = 'customerAdd'; + +export const COMPONENT = { + template: template, + bindings: { + search: '&' + } +}; + module.component(NAME, COMPONENT); \ No newline at end of file diff --git a/@salix/crud/src/customer/index/index.html b/@salix/crud/src/customer/index/index.html index 1f45f7a81..fa3f9a6c3 100644 --- a/@salix/crud/src/customer/index/index.html +++ b/@salix/crud/src/customer/index/index.html @@ -1 +1,2 @@ - \ No newline at end of file + + \ No newline at end of file diff --git a/@salix/crud/src/customer/index/index.js b/@salix/crud/src/customer/index/index.js index 31b48466b..92adbe333 100644 --- a/@salix/crud/src/customer/index/index.js +++ b/@salix/crud/src/customer/index/index.js @@ -4,10 +4,12 @@ import {module} from '../../module'; export const NAME = 'customerIndex'; export const COMPONENT = { template: template, - controller :function(){ - this.users = {id:10,name:"xxxx"}; + controller: function() { + this.users = [{id: 10, name: "xxxx"}]; + this.search = function() { + this.users.push({id: 2, name: 'yyyyy'}); + }; } }; module.component(NAME, COMPONENT); - diff --git a/@salix/crud/src/customer/index/list.html b/@salix/crud/src/customer/index/list.html new file mode 100644 index 000000000..35ca40283 --- /dev/null +++ b/@salix/crud/src/customer/index/list.html @@ -0,0 +1,4 @@ +
+ {{item.id}} + {{item.name}} +
\ No newline at end of file diff --git a/@salix/crud/src/customer/index/list.js b/@salix/crud/src/customer/index/list.js new file mode 100644 index 000000000..240f43d50 --- /dev/null +++ b/@salix/crud/src/customer/index/list.js @@ -0,0 +1,13 @@ +import template from './list.html'; +import {module} from '../../module'; + +export const NAME = 'customerList'; + +export const COMPONENT = { + template: template, + bindings: { + users: '<' + } +}; + +module.component(NAME, COMPONENT); diff --git a/@salix/crud/src/customer/routes.js b/@salix/crud/src/customer/routes.js index 92032b153..60e935b45 100644 --- a/@salix/crud/src/customer/routes.js +++ b/@salix/crud/src/customer/routes.js @@ -2,19 +2,18 @@ import * as core from '@salix/core'; import * as index from './index'; core.module.config(function($stateProvider, $urlRouterProvider) { - $urlRouterProvider.otherwise("/"); $stateProvider .state('index', { url: "/index", - component: index.CUSTOMER_INDEX, - resolve:{ - load:function(){ - console.log('hello'); + component: index.CUSTOMER_INDEX, + resolve: { + load: function() { + console.log('hello'); } } - }) + }) .state('add', { url: "/add", template: "
add
" @@ -26,6 +25,5 @@ core.module.config(function($stateProvider, $urlRouterProvider) { .state('delete', { url: "/delete", template: "
delete
" - }) - + }); }); diff --git a/npm-debug.log b/npm-debug.log deleted file mode 100644 index 9d648ec6b..000000000 --- a/npm-debug.log +++ /dev/null @@ -1,27 +0,0 @@ -0 info it worked if it ends with ok -1 verbose cli [ '/usr/local/Cellar/node/6.3.1/bin/node', -1 verbose cli '/usr/local/bin/npm', -1 verbose cli 'run', -1 verbose cli 'dev' ] -2 info using npm@3.10.3 -3 info using node@v6.3.1 -4 verbose stack Error: missing script: dev -4 verbose stack at run (/usr/local/lib/node_modules/npm/lib/run-script.js:151:19) -4 verbose stack at /usr/local/lib/node_modules/npm/lib/run-script.js:61:5 -4 verbose stack at /usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:356:5 -4 verbose stack at checkBinReferences_ (/usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:320:45) -4 verbose stack at final (/usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:354:3) -4 verbose stack at then (/usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:124:5) -4 verbose stack at /usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:311:12 -4 verbose stack at /usr/local/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:78:16 -4 verbose stack at tryToString (fs.js:455:3) -4 verbose stack at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:442:12) -5 verbose cwd /Users/nelo/Documents/node/salix -6 error Darwin 16.0.0 -7 error argv "/usr/local/Cellar/node/6.3.1/bin/node" "/usr/local/bin/npm" "run" "dev" -8 error node v6.3.1 -9 error npm v3.10.3 -10 error missing script: dev -11 error If you need help, you may report this error at: -11 error -12 verbose exit [ 1, true ] diff --git a/package.json b/package.json index df20f4e4b..889915f8a 100644 --- a/package.json +++ b/package.json @@ -16,18 +16,25 @@ "oclazyload": "^0.6.3" }, "devDependencies": { + "babel-core": "*", + "babel-loader": "*", + "babel-preset-es2015": "*", + "css-loader": "^0.25.0", + "eslint": "^3.7.1", + "eslint-config-angular": "^0.5.0", + "eslint-config-google": "^0.6.0", + "eslint-plugin-angular": "^1.4.1", "gulp": "^3.9.1", "gulp-jsoncombine": "^1.0.3", - "webpack": "*", - "webpack-dev-server": "*", + "pre-commit": "^1.1.3", "raw-loader": "*", - "css-loader": "^0.25.0", "style-loader": "^0.13.1", - "babel-loader": "*", - "babel-core": "*", - "babel-preset-es2015": "*" + "webpack": "*", + "webpack-dev-server": "*" }, "scripts": { - "build": "webpack --progress --colors --watch" - } + "build": "webpack --progress --colors --watch", + "lint": "eslint ./ --cache --ignore-pattern .gitignore" + }, + "pre-commit": [ "lint" ] } diff --git a/webpack.config.js b/webpack.config.js index 6ff905c05..19548deaa 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,43 +1,43 @@ -var webpack = require ('webpack'); -var path = require ('path'); +// var webpack = require('webpack'); +var path = require('path'); module.exports = { - entry: { - 'salix.app': ['@salix/app'] - }, - output: { - path: path.join(__dirname, 'build'), - filename: '[name].js', - publicPath: 'build/', - chunkFilename: "[name].js" - }, - module: { - loaders: [ - { - test: /\.js$/, - loader: 'babel', - exclude: /node_modules/, - query: { - presets: ['es2015'] - } - },{ - test: /\.html$/, - loader: 'raw' - },{ - test: /\.json$/, - loader: 'json' - },{ - test: /\.css$/, - loader: 'style!css' - } - ] - }, - resolve: { - modulesDirectories: [ - __dirname, - 'node_modules' - ] - } + entry: { + 'salix.app': ['@salix/app'] + }, + output: { + path: path.join(__dirname, 'build'), + filename: '[name].js', + publicPath: 'build/', + chunkFilename: "[name].js" + }, + module: { + loaders: [ + { + test: /\.js$/, + loader: 'babel', + exclude: /node_modules/, + query: { + presets: ['es2015'] + } + }, { + test: /\.html$/, + loader: 'raw' + }, { + test: /\.json$/, + loader: 'json' + }, { + test: /\.css$/, + loader: 'style!css' + } + ] + }, + resolve: { + modulesDirectories: [ + __dirname, + 'node_modules' + ] + } };