我在可视代码中使用eslint格式化js文件,但是每次运行它都会给我错误,这是运行它的命令行
node ./node_modules/eslint/bin/eslint -- src --fix
错误消息
E:\PATH\src\reducers\roote-reducer.js
1:8 error There should be no space after '{' object-curly-spacing
1:26 error There should be no space before '}' object-curly-spacing
6:1 error Expected indentation of 1 tab but found 2 spaces indent
7:1 error Expected indentation of 1 tab but found 2 spaces indent
8:4 error Newline required at end of file but not found eol-last
E:\PATH\src\reducers\schedule-reducer.js
1:8 error There should be no space after '{' object-curly-spacing
1:22 error There should be no space before '}' object-curly-spacing
4:1 error Expected indentation of 1 tab but found 4 spaces indent
7:24 error Missing space before function parentheses space-before-function-paren
7:54 error Missing space before opening brace space-before-blocks
8:1 error Expected indentation of 1 tab but found 4 spaces indent
9:1 error Expected indentation of 1 tab but found 4 spaces indent
E:\PATH\src\register-service-worker.js
12:1 error Expected indentation of 1 tab but found 2 spaces indent
17:1 error Expected indentation of 5 tabs but found 6 spaces indent
17:7 error Use regex shorthands to improve readability unicorn/regex-shorthand
22:1 error Expected indentation of 1 tab but found 2 spaces indent
✖ 309 problems (309 errors, 0 warnings)
309 errors, 0 warnings potentially fixable with the `--fix` option.
我如何自动修复它们?
答案 0 :(得分:3)
在新终端中运行以下命令:
./node_modules/.bin/eslint --fix . --ext .js,.vue src
答案 1 :(得分:2)
要使用--fix
选项,您需要直接运行eslint。
尝试一下
./node_modules/.bin/eslint src --fix
答案 2 :(得分:2)
如果没有
extend(config, ctx) {
// Run ESLint on save
if (ctx.isDev && ctx.isClient) {
config.module.rules.push({
enforce: 'pre',
test: /\.(js|vue)$/,
loader: 'eslint-loader',
exclude: /(node_modules)/,
options: {
fix: true
}
})
}
}
You. You can use this on the first page
const colors = require('vuetify/es5/util/colors').default
const pkg = require('./package')
require('dotenv').config()
module.exports = {
mode: 'universal',
/*
** Headers of the page
*/
head: {
titleTemplate: '%s - ' + process.env.npm_package_name,
title: process.env.npm_package_name || '',
meta: [
{ charset: 'utf-8' },
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
{
hid: 'description',
name: 'description',
content: process.env.npm_package_description || ''
}
],
link: [{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }]
},
/*
** Customize the progress-bar color
*/
loading: { color: '#fff' },
/*
** Global CSS
*/
css: [],
/*
** Plugins to load before mounting the App
*/
plugins: [],
/*
** Nuxt.js dev-modules
*/
buildModules: [
// Doc: https://github.com/nuxt-community/eslint-module
'@nuxtjs/eslint-module',
'@nuxtjs/vuetify'
],
/*
** Nuxt.js modules
*/
modules: [
// Doc: https://axios.nuxtjs.org/usage
'@nuxtjs/axios',
'@nuxtjs/pwa',
// Doc: https://github.com/nuxt-community/dotenv-module
'@nuxtjs/dotenv'
],
/*
** Axios module configuration
** See https://axios.nuxtjs.org/options
*/
axios: {},
/*
** vuetify module configuration
** https://github.com/nuxt-community/vuetify-module
*/
/*
** Build configuration
*/
build: {
extend(config, ctx) {
// Run ESLint on save
if (ctx.isDev && ctx.isClient) {
config.module.rules.push({
enforce: 'pre',
test: /\.(js|vue)$/,
loader: 'eslint-loader',
exclude: /(node_modules)/,
options: {
fix: true
}
})
}
}
}
}
答案 3 :(得分:2)
尝试运行
eslint --fix
您必须先安装eslint
npm install -g eslint
答案 4 :(得分:2)
使用命令行终端,在 Visual Studio Code 中运行以下命令。
确保为工作项目配置了 .eslintrc.yml 文件
修复文件中的 lint 问题
npx eslint file1.js --fix
修复文件夹中所有文件的lint问题
npx eslint ./folder_name --fix
答案 5 :(得分:1)
--fix
时遇到了困难./node_modules/.bin/eslint --fix
但是,我更喜欢在 package.json
"lint": "eslint --ext \".js,.vue\" --ignore-path .gitignore .", "lint-fix": "npm run lint -- --fix"
然后运行 yarn lint-fix
或 npm run lint-fix
答案 6 :(得分:0)
答案 7 :(得分:0)
我遇到了同样的问题
loans = pd.read_csv(r'C:\Users\train\Downloads\accepted-200000-new.csv',low_memory=True)
.....(more preprocessing code)
loans_train = loans.loc[loans['issue_d'] < loans['issue_d'].quantile(0.9)]
loans_test = loans.loc[loans['issue_d'] >= loans['issue_d'].quantile(0.9)]
loans_test.shape[0] / loans.shape[0]
loans_train.drop('issue_d', axis=1, inplace=True)
loans_test.drop('issue_d', axis=1, inplace=True)
y_train = loans_train['charged_off']
y_test = loans_test['charged_off']
X_train = loans_train.drop('charged_off', axis=1)
X_test = loans_test.drop('charged_off', axis=1)
del loans_train, loans_test
linear_dep = pd.DataFrame()
**for col in X_train.columns:
linear_dep.loc[col, 'pearson_corr'] = X_train[col].corr(y_train)
linear_dep['abs_pearson_corr'] = abs(linear_dep['pearson_corr'])**
from sklearn.feature_selection import f_classif
for col in X_train.columns:
mask = X_train[col].notnull()
(linear_dep.loc[col, 'F'], linear_dep.loc[col, 'p_value']) = f_classif(pd.DataFrame(X_train.loc[mask, col]), y_train.loc[mask])
linear_dep.sort_values('abs_pearson_corr', ascending=False, inplace=True)
linear_dep.drop('abs_pearson_corr', axis=1, inplace=True)
linear_dep.reset_index(inplace=True)
linear_dep.rename(columns={'index':'variable'}, inplace=True)
答案 8 :(得分:0)
首次安装软件包: npm install -g eslint
和
运行: eslint --fix
答案 9 :(得分:0)
如果还没有,请先安装eslint
npm install -g eslint
然后运行
eslint --fix path/to/file.extension
注意:对特定文件进行更改后,您每次都必须运行上述命令。
答案 10 :(得分:0)
在您存在代码的目录中运行:
eslint --fix .
代替
eslint --fix
因为命令需要一个参数,该参数指示代码所在的目录或您要在其上应用lint的文件本身