安装famo.us之后,无论何时我尝试使用默认的SurfaceImage grunt以外的任何东西修改main.js文件,只会抛出一堆handler.js错误并且不会加载页面。
我可以添加不同的图像并修改imageSurface的大小而没有任何问题,但是当我尝试添加表面或向现有的imageSurface添加属性时,我会收到错误。
这也发生在GitHub上发布的所有示例中(从示例main.js文件运行)。以下错误是我修改main.js文件时看到的非常典型的错误:
>> File "app\src\main.js" changed.
Running "jscs:src" (jscs) task
Multiple var declaration at app/src/handler.js :
6 |var mainContext = Engine.createContext();
7 |
8 |var surfaceA, surfaceB;
--------^
9 |createSurfaces();
10 |
Illegal trailing whitespace at app/src/handler.js :
33 | }
34 | });
35 |
----------^
36 | surfaceB = new Surface({
37 | size: [100, 100],
Illegal trailing whitespace at app/src/handler.js :
43 | }
44 | });
45 |
----------^
46 | var modifierB = new StateModifier({
47 | origin: [1, 1]
Illegal trailing whitespace at app/src/handler.js :
47 | origin: [1, 1]
48 | });
49 |
----------^
50 | mainContext.add(surfaceA);
51 | mainContext.add(modifierB).add(surfaceB);
Missing line feed at file end at app/src/handler.js :
50 | mainContext.add(surfaceA);
51 | mainContext.add(modifierB).add(surfaceB);
52 |}
--------^
>> 5 code style errors found!
Warning: Task "jscs:src" failed. Use --force to continue
我仍然是新手,所以我确定我错过了一些非常愚蠢的东西,但不确定是什么。其他人有这样的问题吗?
答案 0 :(得分:0)
如果您有兴趣参与开源开发或构建社区插件,那么您遇到的风格指南是Famo.us希望您遵循的。
正如您所看到的,样式指南非常挑剔。如果您想快速启动并运行,您可以简单地禁用强制执行该样式的包。这些是eslint和jscs ..
进入你的Gruntfile.js并注释掉" THIS LINE"下的一组行。或者"这些线"使它看起来像以下..
希望这适合你!
/*global module:false*/
/*Generated initially from grunt-init, heavily inspired by yo webapp*/
module.exports = function(grunt) {
'use strict';
// Load grunt tasks automatically
require('load-grunt-tasks')(grunt);
// Time how long tasks take. Can help when optimizing build times
require('time-grunt')(grunt);
// Project configuration.
grunt.initConfig({
// Project settings
config: {
// Configurable paths
app: 'app',
dist: 'dist'
},
// THESE LINES ///////////////
// eslint: {
// options: {
// config: '.eslintrc'
// },
// target: ['<%= config.app %>/src/**/**.js']
// },
// THESE LINES ///////////////
// jscs: {
// src: ['<%= config.app %>/src/**/**.js', 'Gruntfile.js'],
// options: {
// config: '.jscsrc'
// }
// },
// Watches files for changes and runs tasks based on the changed files
watch: {
bower: {
files: ['bower.json'],
tasks: ['bower']
},
js: {
files: ['<%= config.app %>/src/**/**.js'],
// THIS LINE ///////////////
// tasks: ['jscs', 'eslint'],
options: {
livereload: true
}
},
gruntfile: {
files: ['Gruntfile.js']
},
css: {
files: ['<%= config.app %>/css/{,*/}*.css'],
options: {
livereload: true
}
},
livereload: {
options: {
livereload: '<%= connect.options.livereload %>'
},
files: [
'<%= config.app %>/{,*/}*.html',
'<%= config.app %>/styles/**/**.css',
'<%= config.app %>/images/{,*/}*'
]
}
},
// The actual grunt server settings
connect: {
options: {
port: grunt.option('port') || 5555,
livereload: 35729,
// Change this to '0.0.0.0' to access the server from outside
hostname: '0.0.0.0'
},
livereload: {
options: {
open: true,
base: [
'.tmp',
'<%= config.app %>'
]
}
},
dist: {
options: {
open: true,
base: '<%= config.dist %>',
livereload: false
}
}
},
// Empties folders to start fresh
clean: {
dist: {
files: [{
dot: true,
src: [
'.tmp',
'<%= config.dist %>/*',
'!<%= config.dist %>/.git*'
]
}]
},
server: '.tmp'
},
// Automagically wire-up installed Bower components into your RequireJS config
bower: {
raget: {
rjsConfig: '<%= config.app %>/src/requireConfig.js'
}
},
rev: {
dist: {
files: {
src: [
'<%= config.dist %>/src/{,*/}*.js',
'<%= config.dist %>/css/{,*/}*.css',
// '<%= config.dist %>/images/{,*/}*.*',
'<%= config.dist %>/css/fonts/{,*/}*.*',
'<%= config.dist %>/*.{ico,png}'
]
}
}
},
processhtml: {
dev: {
files: {
'.tmp/index.html': ['<%= config.app %>/index.html']
}
},
dist: {
files: {
'<%= config.dist %>/index.html': ['<%= config.app %>/index.html']
}
},
options: {
commentMarker: 'process'
}
},
// Reads HTML for usemin blocks to enable smart builds that automatically
// concat, uglify and revision files. Creates configurations in memory so
// additional tasks can operate on them
useminPrepare: {
options: {
dest: '<%= config.dist %>'
},
html: '<%= config.dist %>/index.html'
},
// Performs reqrite based on rev and the useminPrepare configuration
usemin: {
options: {
assetsDirs: ['<%= config.dist %>', '<%= config.dist %>/images']
},
html: ['<%= config.dist %>/{,*/}*.html'],
css: ['<%= config.dist %>/css/{,*/}*.css']
},
htmlmin: {
dist: {
options: {
collapseBooleanAttributes: true,
collapseWhitespace: true,
removeAttributeQuotes: true,
removeCommentsFromCDATA: true,
removeEmptyAttributes: true,
removeOptionalTags: true,
removeRedundantAttributes: true,
useShortDoctype: true
},
files: [{
expand: true,
cwd: '<%= config.dist %>',
src: '{,*/}*.html',
dest: '<%= config.dist %>'
}]
}
},
// Copies remaining files to places other tasks can use
copy: {
dist: {
files: [{
expand: true,
dot: true,
cwd: '<%= config.app %>',
dest: '<%= config.dist %>',
src: [
'**/**.{ico,png,txt,jpg}',
'.htaccess',
'images/{,*/}*.webp',
// '{,*/}*.html',
'styles/fonts/{,*/}*.*',
'lib/famous/**/**.css'
]
}]
}
},
requirejs: {
compile: {
options: {
optimize: 'uglify2',
uglify2: {
mangler: {
toplevel: true
}
},
baseUrl: '<%= config.app %>/src',
mainConfigFile: '<%= config.app %>/src/requireConfig.js',
name: 'almond',
include: 'main',
insertRequire: ['main'],
out: '<%= config.dist %>/src/main.js',
wrap: true
}
}
}
});
grunt.registerTask('serve', function(target) {
if (target === 'dist') {
return grunt.task.run(['build', 'connect:dist:keepalive']);
}
grunt.task.run([
'clean:server',
// THESE LINES ///////////////
// 'jscs',
// 'eslint',
'processhtml:dev',
'connect:livereload',
'watch'
]);
});
grunt.registerTask('build', [
'clean:dist',
// THESE LINES ///////////////
// 'jscs',
// 'eslint',
'processhtml:dist',
'useminPrepare',
'requirejs',
'concat',
'cssmin',
'uglify',
'copy:dist',
'rev',
'usemin',
'htmlmin'
]);
grunt.registerTask('default', [
'build'
]);
};
答案 1 :(得分:0)
强制它运行或构建的捷径是使用--force
选项。
喜欢:
grunt serve --force
或
grunt --force
确保没有非格式化问题。