小编jfu*_*unk的帖子

Eslint glob (**) 不会递归地考虑所有目录

我正在使用 OSX,在我的package.json文件中我有脚本条目:

"lint": "eslint ./src/**/*.js"

但是,当我运行时,npm lint只考虑对第一级目录进行 linting,例如。./src/dir/*不是./src/dir/nested_dir/*

我的印象是**glob 表示递归搜索?

有谁知道我怎样才能让它按预期运行?

javascript lint eslint

18
推荐指数
2
解决办法
6012
查看次数

Babel [karma-babel-preprocessor]不转换ES6-> ES5用于Karma测试

我们安装了karma,它使用mocha和chai进行测试.我们正在尝试使用karma-babel-preprocessor将babel直接整合到业力中,以便将我们的ES6文件转换为ES5来运行.使用mocha单独使用babel,即mocha测试命令,但我们尝试使用karma而不是它不起作用.

karma.conf.js片段:

frameworks: ['mocha', 'chai'],

// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: {
   'src/**/*.js': ['babel'],
   'test/**/*_spec.js': ['babel']
},

"babelPreprocessor": {
    options: {
        presets: ['es2015'],
        sourceMap: 'inline'
    },   
    filename: function(file) {
        return file.originalPath.replace(/\.js$/, '.es5.js');
    },
    sourceFileName: function(file) {
        return file.originalPath;
    }
},

// list of files / patterns to load in the browser
files: [
  'src/**/*.js',
  'test/**/*_spec.js'
],
Run Code Online (Sandbox Code Playgroud)

package.json片段:

"scripts": {
  "test": "./node_modules/karma/bin/karma start karma.conf.js"
},

"babel": {
  "presets": ["es2015"]
},

"devDependencies": { …
Run Code Online (Sandbox Code Playgroud)

javascript testing mocha.js karma-runner babeljs

11
推荐指数
2
解决办法
8419
查看次数

标签 统计

javascript ×2

babeljs ×1

eslint ×1

karma-runner ×1

lint ×1

mocha.js ×1

testing ×1