Socket
Book a DemoInstallSign in
Socket

@megalo/cli-plugin-eslint

Package Overview
Dependencies
Maintainers
7
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@megalo/cli-plugin-eslint

eslint plugin for megalo-cli

1.0.0-beta.2
latest
Source
npmnpm
Version published
Maintainers
7
Created
Source

@megalo/cli-plugin-mp

eslint plugin for megalo-cli

注入的命令

  • megalo-cli-service lint

    Usage: megalo-cli-service lint [options] [...files]
    
    Options:
    
      --format [formatter] specify formatter (default: codeframe)
      --no-fix             do not fix errors
      --max-errors         specify number of errors to make build failed (default: 0)
      --max-warnings       specify number of warnings to make build failed (default: Infinity)
    

    检查提示以及修复文件格式。 如果没有特别指定文件或目录,默认情况下它会检查 srctest 目录下的所有文件

    另外 ESLint CLI options 这里的选项也是支持的.

配置

ESLint可以通过 .eslintrcpackage.json 中的 eslintConfig 字段进行配置。

默认情况下启用 eslint-loader 进行开发时的保存。 可以使用 megalo.config.js 中的 lintOnSave 选项禁用它:

module.exports = {
  lintOnSave: false
}

设置为 true 时,eslint-loader 会将 lint 错误输出为编译警告。默认情况下,警告仅仅会被输出到命令行,且不会使得编译失败。

如果你希望让 lint 错误在开发时直接显示在浏览器中,你可以使用 lintOnSave: 'error'。这会强制 eslint-loaderlint 错误输出为编译错误,同时也意味着 lint 错误将会导致编译失败。

或者,你也可以通过设置让浏览器 overlay 同时显示警告和错误:

// megalo.config.js
module.exports = {
  // 编译小程序不支持该选项
  devServer: {
    overlay: {
      warnings: true,
      errors: true
    }
  }
}

lintOnSave 是一个 truthy 的值时,eslint-loader 在开发和生产构建下都会被启用。如果你想要在生产构建时禁用 eslint-loader,你可以用如下配置:

// megalo.config.js
module.exports = {
  lintOnSave: process.env.NODE_ENV !== 'production'
}

注入的 webpack-chain 规则

  • config.module.rule('eslint')
  • config.module.rule('eslint').use('eslint-loader')

Keywords

megalo

FAQs

Package last updated on 17 Sep 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.