2017-02-22 8 views
1

ESLintをGulpを使用して認識して実行することはできません。 gulpfile.jsのコードは次のとおりです。エラー:ESLint設定が見つかりません

"use strict"; 
 

 
var gulp = require('gulp'); 
 
var connect = require('gulp-connect'); //Runs a local dev server 
 
var open = require('gulp-open'); //Open a URL in a web browser 
 
var browserify = require('browserify'); // Bundles JS 
 
var reactify = require('reactify'); // Transforms React JSX to JS 
 
var source = require('vinyl-source-stream'); // Use conventional text streams with Gulp 
 
var concat = require('gulp-concat'); //Concatenates files 
 
var lint = require('gulp-eslint'); //Lint JS files, including JSX 
 

 
var config = { 
 
\t port: 9005, 
 
\t devBaseUrl: 'http://localhost', 
 
\t paths: { 
 
\t \t html: './src/*.html', 
 
\t \t js: './src/**/*.js', 
 
\t \t css: [ 
 
     \t \t 'node_modules/bootstrap/dist/css/bootstrap.min.css', 
 
     \t \t 'node_modules/bootstrap/dist/css/bootstrap-theme.min.css' 
 
    \t ], 
 
\t \t dist: './dist', 
 
\t \t mainJs: './src/main.js' 
 
\t } 
 
} 
 

 
//Start a local development server 
 
gulp.task('connect', function() { 
 
\t connect.server({ 
 
\t \t root: ['dist'], 
 
\t \t port: config.port, 
 
\t \t base: config.devBaseUrl, 
 
\t \t livereload: true 
 
\t }); 
 
}); 
 

 
gulp.task('open', ['connect'], function() { 
 
\t gulp.src('dist/index.html') 
 
\t \t .pipe(open({ url: config.devBaseUrl + ':' + config.port + '/'})); 
 
}); 
 

 
gulp.task('html', function() { 
 
\t gulp.src(config.paths.html) 
 
\t \t .pipe(gulp.dest(config.paths.dist)) 
 
\t \t .pipe(connect.reload()); 
 
}); 
 

 
gulp.task('js', function() { 
 
\t browserify(config.paths.mainJs) 
 
\t \t .transform(reactify) 
 
\t \t .bundle() 
 
\t \t .on('error', console.error.bind(console)) 
 
\t \t .pipe(source('bundle.js')) 
 
\t \t .pipe(gulp.dest(config.paths.dist + '/scripts')) 
 
\t \t .pipe(connect.reload()); 
 
}); 
 

 
gulp.task('css', function() { 
 
\t gulp.src(config.paths.css) 
 
\t \t .pipe(concat('bundle.css')) 
 
\t \t .pipe(gulp.dest(config.paths.dist + '/css')); 
 
}); 
 

 
gulp.task('lint', function() { 
 
\t return gulp.src(config.paths.js) 
 
\t \t .pipe(lint({config: 'eslint.config.json'})) 
 
\t \t .pipe(lint.format()); 
 
}); 
 

 
gulp.task('watch', function() { 
 
\t gulp.watch(config.paths.html, ['html']); 
 
\t gulp.watch(config.paths.js, ['js', 'lint']); 
 
}); 
 

 
gulp.task('default', ['html', 'js', 'css', 'lint', 'open', 'watch']);

とeslint.config.jsonです:

{ 
 
    "ecmaFeatures": { 
 
    "jsx": true 
 
    }, 
 
    "env": { 
 
    "browser": true, 
 
    "node": true, 
 
    "jquery": true 
 
    }, 
 
    "rules": { 
 
    "quotes": 0, 
 
    "no-trailing-spaces": 0, 
 
    "eol-last": 0, 
 
    "no-unused-vars": 0, 
 
    "no-underscore-dangle": 0, 
 
    "no-alert": 0, 
 
    "no-lone-blocks": 0 
 
    }, 
 
    "globals": { 
 
    jQuery: true, 
 
    $: true 
 
    } 
 
}

、最終的にpackage.jsonの依存関係は次のとおりです。

"dependencies": { 
 
    "bootstrap": "^3.3.7", 
 
    "browserify": "^14.1.0", 
 
    "gulp": "^3.9.1", 
 
    "gulp-concat": "^2.6.1", 
 
    "gulp-connect": "^5.0.0", 
 
    "gulp-eslint": "^3.0.1", 
 
    "gulp-open": "^2.0.0", 
 
    "jquery": "^3.1.1", 
 
    "reactify": "^1.1.1", 
 
    "vinyl-source-stream": "^1.1.0" 
 
    }

私は三つのファイルの1つ以上が仕事を得るために編集することができますか?

+0

あなたは' .pipe()糸くず({「./eslint.config.json」設定})のようなルートパスを設定しようとしたことがありますか? – JoseAPL

答えて

1

あなたはhttps://github.com/adametry/gulp-eslint#optionsconfigfile

で読むことができるように、キー名は.eslintrceslint.config.jsonファイル名の名前を変更してくださいconfigFile

+0

私はPluralsight Reactコースにも参加していましたが、この日現在の最新のノードパッケージを使用しており、これは私のために修正されました – Tyler

3

に変更されました。
次に、lint gulpタスクを次のように変更します。私は両方のファイルが同じディレクトリに正しいと仮定しているため、 `:

 

    gulp.task('lint', function() { 
     return gulp.src(config.paths.js) 
      .pipe(lint.format()); 
    }); 

+0

完全に私のために働いています。私は、この質問をしている人が、自分のファイルが私の瞬間のように見えるので、私と同じPluralsightトレーニングビデオに従っていると信じています。それにもかかわらず、このソリューションは私のために働いた。 – MattD

関連する問題