简体   繁体   English

如何为eslint时尚模式编写配置文件?

[英]How to write config file for eslint stylish mode?

I'm using Eslint for a react application. 我正在将Eslint用于React应用程序。 This is a part of my webpack config: 这是我的webpack配置的一部分:

 { enforce: 'pre', test: /\\.(js|jsx)$/, loader: 'eslint-loader', exclude: /node_modules/, options: { formatter: require('eslint/lib/cli-engine/formatters/stylish'), } }, { test: /\\.(js|jsx)$/, use: 'babel-loader', exclude: /node_modules/ } 

I've set stylish as formatter, but when I start my application I get this error : 我已经将时尚设置为格式化程序,但是当我启动应用程序时出现此错误:

ERROR in ./src/index.js Module build failed (from ./node_modules/eslint-loader/index.js): Error: No ESLint configuration found in D:\\react\\src.

But apparently stylish is default mode of eslint, but I should create config file ? 但是显然时尚是eslint的默认模式,但是我应该创建配置文件吗?

What I should write into config file ? 我应该写什么配置文件?

Thanks 谢谢

This has nothing to do with webpack. 这与webpack无关。 Webpack can run eslint as part of the build process to do some logic related to linting, but eslint is a separate program. Webpack可以在构建过程中运行eslint来执行一些与linting相关的逻辑,但是eslint是一个单独的程序。

As such, it requires its own configuration. 因此,它需要自己的配置。 Its configuration is in a file called .eslintrc . 其配置位于名为.eslintrc的文件中。

Here's how to configure it: Configuring ESLint 配置方法如下: 配置ESLint

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM