eslint

How to configure @typescript-eslint rules

北城余情 提交于 2020-01-24 10:29:27
问题 I'm trying to convert to @typescript-eslint but the documentation seems sorely lacking. For example, I'm getting errors like this: Line 58: Expected a semicolon @typescript-eslint/member-delimiter-style I want to enforce no semicolons or commas. I found the documentation for that rule. https://github.com/bradzacher/eslint-plugin-typescript/blob/master/docs/rules/member-delimiter-style.md But it doesn't seem to give any examples of how to configure it in a real eslint file! Anyone know how?

[AST Eslint] No console with schema options && isPrimitive

霸气de小男生 提交于 2020-01-23 21:48:11
// eslint exercise 4 (no-console) // When you're finished with this exercise, run // "npm start exercise.eslint.5" // to move on to the next exercise const disallowedMethods = ['log', 'info', 'warn', 'error', 'dir'] module.exports = { meta: { schema: [ { type: 'object', properties: { allowedMethods: { type: 'array', items: { enum: ['log', 'info', 'warn', 'error', 'dir'], }, minItems: 1, uniqueItems: true, }, }, }, ], }, create(context) { const config = context.options[0] || {} const allowedMethods = config.allowedMethods || [] return { Identifier(node) { if ( !looksLike(node, { name: 'console'

create-react-app安装react项目,yurn一直报错 create-react-app安装react项目,yurn一直报错,错误如下图

一世执手 提交于 2020-01-23 18:44:16
create-react-app client --typescript 报错信息如下 error @typescript-eslint/eslint-plugin@2.10.0: The engine "node" is incompatible with this module. Expected version "^8.10.0 || ^10.13.0 || >=11.10.1". Got "10.0.0" error Found incompatible module. info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command. 解决方法是: 设置yarn如下: yarn config set ignore-engines true 来源: CSDN 作者: after you 链接: https://blog.csdn.net/gwdgwd123/article/details/104075536

VUE项目开发流程

社会主义新天地 提交于 2020-01-23 03:30:19
前期准备 安装npm 安装webpack\vue-cli( 2.9.6版本 --版本不同可能会导致以下一些目录结构以及错误解决办法不符合实际情况) 创建项目 初始化创建项目,项目名称、项目描述、拥有者等等信息, D:\code\self>vue init webpack common-component ? Project name common-component # 项目名称 ? Project description A Vue.js project # 项目描述 ? Author XXX <lingxi_danx@sina.com> # 项目拥有者 ? Vue build standalone ? Install vue-router? Yes # 路由配置 ? Use ESLint to lint your code? Yes # 启用eslint检测 ? Pick an ESLint preset Standard ? Set up unit tests No # 单元测试 ? Setup e2e tests with Nightwatch? No # e2e测试 ? Should we run `npm install` for you after the project has been created? (recommended) npm #

VScode配置prettier和eslint

拈花ヽ惹草 提交于 2020-01-22 18:11:56
前端工具中如果使用prettier进行代码格式化,eslint进行错误检测。对前端工作有极大的帮助 原则: prettier和eslint配置可以分成两种,一种是本地配置,一种是全局配置。VScode会检测文件夹根目录下有没有用户自定义的配置文件 .prettierrc.json和.eslintrc.js。如果有则会优先加载用户自定义的配置,如果没有则会加载VScode中的setting.json配置文件内的配置。 现在vscode安装prettier和eslint的插件,装使用人数最多的就行。注意的是,这个只是插件哦,在本地使用npm安装prettier和eslint .prettierrc.json文件配置: { "tabWidth" : 2 , "vetur.format.defaultFormatter.html" : "prettier" , "singleQuote" : true , "semi" : false } .eslintrc.js文件配置: module . exports = { root : true , parserOptions : { ecmaVersion : 6 , sourceType : 'module' , ecmaFeatures : { jsx : true , globalReturn : true , impliedStrict

SaaS-多租户SaaS平台的数据库方案(前端框架)

|▌冷眼眸甩不掉的悲伤 提交于 2020-01-22 13:25:29
3 前端框架 3.1 脚手架工程 技术栈 vue 2.5++ elementUI 2.2.2 vuex axios vue-router vue-i18n 前端环境 node 8.++ npm 5.++ 3.2 启动与安装 (1)解压提供的资源包 (2)在命令提示符进入该目录,输入命令: cnpm install 通过淘宝镜像下载安装所有的依赖,几分钟后下载完成 如果没有安装淘宝镜像,请使用npm install (3)关闭语法检查 打开 config/index.js 将useEslint的值改为false。 useEslint: false, 此配置作用: 是否开启语法检查,语法检查是通过ESLint 来实现的。我们现在科普一下,什么是ESLint : ESLint是一个语法规则和代码风格的检查工具,可以用来保证写出语法正确、风格统一的代码。如果我们开启了Eslint , 也就意味着要接受它非常苛刻的语法检查,包括空格不能少些或多些,必须单引不能双引,语句后不可以写分号等等,这些规则其实是可以设置的。我们作为前端的初学者,最好先关闭这种校验,否则会浪费很多精力在语法的规范性上。如果以后做真正的企业级开发,建议开启 (4)输入命令: npm run dev 3.3 工程结构 整个前端工程的工程目录结构如下: ├── assets | 资源 ├── build |

Expected 'this' to be used by class method

泪湿孤枕 提交于 2020-01-22 13:05:27
问题 In my class, eslint is complaining "Expected 'this' to be used by class method 'getUrlParams' Here is my class: class PostSearch extends React.Component { constructor(props) { super(props); this.getSearchResults(); } getUrlParams(queryString) { const hashes = queryString.slice(queryString.indexOf('?') + 1).split('&'); const params = {}; hashes.forEach((hash) => { const [key, val] = hash.split('='); params[key] = decodeURIComponent(val); }); return params; } getSearchResults() { const { terms,

ESLint error trying to deploy functions Firebase

喜欢而已 提交于 2020-01-20 04:09:08
问题 I'm try to deploy fireabase example , but when I try to deploy it , CLI launches an error: [CODE] const functions = require('firebase-functions'); //to activate firebase functions const admin = require('firebase-admin'); //to active firebase database permissions admin.initializeApp(functions.config().firebase); exports.addMessage = functions.https.onRequest((req, res) => { // [END addMessageTrigger] // Grab the text parameter. const original = req.query.text; // [START adminSdkPush] // Push

vue编译报错:Do not use 'new' for side effects (no-new)

為{幸葍}努か 提交于 2020-01-20 02:01:42
有时候eslint会在我们使用了new的地方,报一个 Do not use 'new' for side effects (no-new) 的错误,如下图所示: 通过查找eslint的官方文档,官方对 no-new 规则的解释是:disallow new operators outside of assignments or comparisons,翻译过来就是: 不允许在赋值或比较之外使用new操作 ,知道原因就好说了,有三种解决方式: 1,直接禁用no-new规则 直接修改eslint的配置文件,在rules中关闭所有的 no-new 规则检查,这种方法是最不靠谱的,不推荐 2,定义一个变量接收new出来的对象 既然官方说要在赋值或者比较中使用new,那我们定义一个变量接收new出来的对象就行了(推荐这种方式): let pro = new Promise ( ) 3,使用/* eslint-disable no-new */ 可以通过在使用new的句子上加上 /* eslint-disable no-new */ 注释来绕开语法检查对注释下的语句的检查: /* eslint-disable no-new */ new Promise ( ) 注意:该注释只对注释下的一行代码有效,如果项目中其它地方违反了 no-new 规则,仍然会报错 来源: CSDN 作者:

Vue2.0搭建脚手架流程

眉间皱痕 提交于 2020-01-19 03:01:53
介绍 Vue.js是一套构建用户界面的渐进式框架。 Vue 只关注视图层,采用自底向上增量开发的设计。 Vue 的目标是通过尽可能简单的 API 实现响应的数据绑定和组合的视图组件。 安装node.js 从 node官网 下载并安装node,安装步骤很简单,只要一路“next”就可以了。 安装完成后,打开命令行工具输入命令 node -v ,如下图,如果出现对应版本号,就说明安装成功了。 我们所需要的npm包管理器,是集成在node中的,所以,直接输入 npm -v 就会如下图所示,显示出npm的版本信息。 到这里node的环境已经安装完了,npm包管理工具也有了,但是由于npm的有些资源被墙,为了更快更稳定,所以我们需要切换到淘宝的npm镜像——cnpm。 安装cnpm 点击进入淘宝的 cnpm 网站,里面有详细的配置方法。 或者直接在命令行输入: $ npm install -g cnpm --registry=https://registry.npm.taobao.org   然后等待,安装完成。 输入cnpm -v,可以查看当前cnpm版本,这个和npm的版本还是不一样的。 使用cnpm的方法就是,需要用到npm的地方直接使用cnpm替换就可以了 vue安装 安装vue-cli脚手架构建工具 vue-cli 提供一个官方命令行工具,可用于快速搭建大型单页应用