如何在vue-cli中禁用ESLint?

时间:2016-08-04 01:25:23

标签: javascript webpack vue.js vue-cli

如何在使用ESlint生成的项目中停用vue-cli

preLoaders: [
  {
    test: /\.vue$/,
    loader: 'eslint',
    include: projectRoot,
    exclude: /node_modules/
  },
  {
    test: /\.js$/,
    loader: 'eslint',
    include: projectRoot,
    exclude: /node_modules/
  }
]

如果我删除loader: 'eslint'行,它将无法编译,与将其设置为空字符串相同。我知道我可以在初始化阶段退出ESLint,但是如何在创建项目后禁用它?

15 个答案:

答案 0 :(得分:20)

从当前版本(^ 3.0?)开始,您只需设置:

useEslint:false,

在config / index.js

答案 1 :(得分:19)

package.json中更改构建步骤:

...
"scripts": {
    "build": "vue-cli-service build --skip-plugins @vue/cli-plugin-eslint",
    ...
},

答案 2 :(得分:12)

Vue的初学者项目本身就是用模板语言构建的。

查看the templates{{#lint}}位),您可以删除整个preLoaders块。

答案 3 :(得分:10)

2019, March起:

vue.config.js中:

module.exports = {
  ...
  lintOnSave: false
  ...
}

祝你好运...

答案 4 :(得分:2)

在最新版本中,打开“ .eslintrc.js”文件,并设置“ root:false”。enter image description here

答案 5 :(得分:2)

在Vue CLI 4.5上 编辑package.json

寻找:

"eslintConfig": {
    "root": true,
    "env": {
        "node": true
    },
    ...
}

更改为:

"eslintConfig": {
    "root": false,
    "env": {
        "node": false
    },
    ...
}

答案 6 :(得分:1)

这里有很多解决方案: https://github.com/vuejs-templates/webpack/issues/73

但是最好的是:
向.eslintignore添加一行**/*,它将忽略所有文件。 如果是Web应用程序,然后重新运行!

答案 7 :(得分:1)

设置 <?php namespace common\models; use Yii; use yii\base\Model; use yii\db\Expression; use machour\yii2\notifications\models\Notification as BaseNotification; class Notification extends BaseNotification { /** * A new message notification */ const KEY_NEW_MESSAGE = 'new_message'; /** * A meeting reminder notification */ const KEY_MEETING_REMINDER = 'meeting_reminder'; /** * No disk space left ! */ const KEY_NO_DISK_SPACE = 'no_disk_space'; /** * @var array Holds all usable notifications */ public static $keys = [ self::KEY_NEW_MESSAGE, self::KEY_MEETING_REMINDER, self::KEY_NO_DISK_SPACE, ]; /** * @inheritdoc */ public function getTitle() { switch ($this->key) { case self::KEY_MEETING_REMINDER: return Yii::t('app', 'Meeting reminder'); case self::KEY_NEW_MESSAGE: return Yii::t('app', 'You got a new message'); case self::KEY_NO_DISK_SPACE: return Yii::t('app', 'No disk space left'); } } /** * @inheritdoc */ public function getDescription() { switch ($this->key) { case self::KEY_NO_DISK_SPACE: // We don't have a key_id here return 'Please buy more space immediately'; } } /** * @inheritdoc */ public function getRoute() { switch ($this->key) { case self::KEY_NO_DISK_SPACE: return 'https://aws.amazon.com/'; }; } } 中的'modules' => [ 'redactor' => 'yii\redactor\RedactorModule', 'notifications' => [ 'class' => 'machour\yii2\notifications\NotificationsModule', // Point this to your own Notification class // See the "Declaring your notifications" section below 'notificationClass' => 'common\models\Notification', // Allow to have notification with same (user_id, key, key_id) // Default to FALSE 'allowDuplicate' => false, // Allow custom date formatting in database 'dbDateFormat' => 'Y-m-d H:i:s', // This callable should return your logged in user Id 'userId' => function() { return \Yii::$app->user->id; } ], ],

Yii2 notification widget class not found

答案 8 :(得分:1)

这里有一些过时的答案。

因为vue-cli 3使用零配置方法,所以禁用它的方法是仅卸载模块:

npm remove @vue/cli-plugin-eslint

答案 9 :(得分:1)

const array = [ { id: '12', parentId: '0', text: 'one-1' }, { id: '6', parentId: '12', text: 'one-1-6' }, { id: '7', parentId: '12', text: 'one-1-7' }, { id: '9', parentId: '0', text: 'one-2' }, { id: '11', parentId: '9', text: 'one-2-11' } ]; // Prevent changes to the original data const arrayCopy = array.map(item => ({ ...item })); const listToTree = list => { const map = {}; const roots = []; list.forEach((v, i) => { map[v.id] = i; list[i].children = []; }); list.forEach(v => (v.parentId !== '0' ? list[map[v.parentId]].children.push(v) : roots.push(v))); return roots; }; console.log(listToTree(arrayCopy)); 为我工作!

setEslint: false

答案 10 :(得分:0)

进入文件“ tslint.json”,并排除linterOptions中的所有文件。默认设置仅排除文件夹node_modules。您还可以在tsconfig.json中设置“ strict”:false

  "linterOptions": {
    "exclude": [
      "*/**"
    ]
  },

代替

  "linterOptions": {
    "exclude": [
      "node_modules/**"
    ]
  },

答案 11 :(得分:0)

最简单的方法之一就是只设置一个.eslintignore文件,以禁用文件夹和文件。

  

演示

/build/
/config/
/dist/
/*.js
/test/unit/coverage/

/000-xyz/

裁判

https://github.com/vuejs-templates/webpack/issues/73#issuecomment-355149342

答案 12 :(得分:0)

转到.eslintrc.js并添加以下内容:

dev: {
   useEslint: false
},

答案 13 :(得分:0)

vue3 用户只需将 eslintrc.js 文件中的 parserOptions 注释掉即可。它对我有用,因为有时 linting 会变得令人沮丧

module.exports = {
  root: true,
  env: {
    node: true
  },
  'extends': [
    'plugin:vue/vue3-essential',
    'eslint:recommended'
  ],
  // parserOptions: {
  //   parser: 'babel-eslint'
  // },
  rules: {
    'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
    'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off'
  }
}

答案 14 :(得分:0)

在 vueCli 中,转到 package json 从依赖项中删除 eslint 最后你的 package json 必须像这样

{
  "name": "vuecompesation",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "serve": "vue-cli-service serve",
    "build": "vue-cli-service build"

  },
  "dependencies": {
    "core-js": "^3.6.5",
    "vue": "^3.0.0"
  },
  "devDependencies": {
    "@vue/cli-plugin-babel": "~4.5.0",
    "@vue/cli-plugin-eslint": "~4.5.0",
    "@vue/cli-service": "~4.5.0",
    "@vue/compiler-sfc": "^3.0.0",
    "babel-eslint": "^10.1.0"
  
  },
  "eslintConfig": {
    "root": true,
    "env": {
      "node": true
    },
    "extends": [
      "plugin:vue/vue3-essential",
      "eslint:recommended"
    ],
    "parserOptions": {
      "parser": "babel-eslint"
    },
    "rules": {}
  },
  "browserslist": [
    "> 1%",
    "last 2 versions",
    "not dead"
  ]
}