eslint

How can I disable the error (prettier/prettier) on eslint?

佐手、 提交于 2020-12-30 05:33:12
问题 While coding, I was not using eslint. Now I installed it and it has flooded my editor with prettier/prettier errors, which by no way seem like they make my code prettier. I am looking to find a way to solve this. prettierrc.js: module.exports = { bracketSpacing: true, jsxBracketSameLine: false, singleQuote: true, trailingComma: 'all', }; eslintrc.js: module.exports = { root: true, extends: '@react-native-community', }; And finally, some example code: import React, {Component} from 'react';

Eslint state already declared [Vuex]

╄→гoц情女王★ 提交于 2020-12-29 09:10:34
问题 I am running ESLint and I am currently running into the following ESLint error: error 'state' is already declared in the upper scope no-shadow const state = { date: '', show: false }; const getters = { date: state => state.date, show: state => state.show }; const mutations = { updateDate(state, payload) { state.date = payload.date; }, showDatePicker(state) { state.show = true; } }; export default { state, getters, mutations }; What would be the best way to fix this? 回答1: The best way to fix

Allow debugger; statements in certain files, using ESLint

可紊 提交于 2020-12-29 03:56:14
问题 Say I want to use this rule: https://eslint.org/docs/rules/no-debugger however, I have about 15 files where I want to keep debugger; statements. Is there something I can add at the top of the .ts/.js files, that can tell ESLint to ignore the no-debugger rule for this particular file? 回答1: You can do that like this: /* eslint-disable no-debugger */ ... code that violates rule ... /* eslint-enable no-debugger */ 回答2: You can also disable ESLint in the same line: debugger; // eslint-disable-line

vue前端实战注意事项

馋奶兔 提交于 2020-12-29 02:30:35
1. vue前端实战注意事项 1.1. 预备 1.1.1. Eslint 这是个语法检查工具,我用webstorm作为开发的ide,这个语法检查还是太严格了,一个空格啥的都会报错,对新手来讲还是建议关闭,需要关闭的地方主要有两个,webstorm自身设置,在settings里搜Eslint,如下 代码里找到 webpack.base.conf.js 文件,注掉如下 1.1.2. 接口基地址 因为我的基础代码是代码生成器生成,里面有easymock的测试地址,这里需要替换成我们实际项目后台地址,找打 dev.env.js 文件 1.1.3. config/index.js 找到 index.js 文件,如果项目在开发阶段,建议 devtool: 'source-map' 设置成这样,否则可能会造成你的调试困难 1.2. 权限 前后端分离通常要设置权限,也就是用前端来限制访问,不允许不经过登录页就访问其它界面 这个由路由的切面来完成,代码如下,提供一种思路 import router from './router' import store from './store' import NProgress from 'nprogress' // Progress 进度条 import 'nprogress/nprogress.css'// Progress 进度条样式 import {

Pylint with pre-commit and EsLlint with husky

你离开我真会死。 提交于 2020-12-26 19:56:52
问题 I have a project with a frontend in JS and backend in Python. Frontend had been configured with husky pre-commit hook. Today I've configured Pylint with pre-commit library but husky hooks had been overwritten by that move. Is it possible to combine pre-commit and husky libraries? If not... what's the best way to solve the problem? 回答1: pre-commit has a "migration mode" for running other existing hook frameworks. It seems that husky is slightly too clever in their hook implementation for

vue问题集锦

。_饼干妹妹 提交于 2020-12-25 16:42:50
1. vue报错: error ‘xxx‘ is defined but never used no-unused-vars 报错原因 : 因为vue项目选择了eslint校验规范->定义了某个变量,但是没有使用,eslint规范就是要么不定义,要么定义了就一定得用. 解决方法: 在package.json文件内加入如下代码(保存后重启项目!!!) "rules": { "no-unused-vars":"off", }, 来源: oschina 链接: https://my.oschina.net/u/3021599/blog/4840427

ESLint not reporting TypeScript compiler type checking errors

一笑奈何 提交于 2020-12-25 04:03:24
问题 Looking for help in getting the type errors, reported by the TypeScript compiler, into the output of ESLint. The library typescript-eslint (https://github.com/typescript-eslint/typescript-eslint/blob/master/docs/getting-started/linting/TYPED_LINTING.md) makes me think that this should be possible. File structure src/ ... source files tsconfig.json test/ ... testing files .eslintrc.js package.json tsconfig.json (symlink to src/tsconfig.json) .eslintrc.js module.exports = { 'env': { 'jest':

ESLint not reporting TypeScript compiler type checking errors

若如初见. 提交于 2020-12-25 04:00:47
问题 Looking for help in getting the type errors, reported by the TypeScript compiler, into the output of ESLint. The library typescript-eslint (https://github.com/typescript-eslint/typescript-eslint/blob/master/docs/getting-started/linting/TYPED_LINTING.md) makes me think that this should be possible. File structure src/ ... source files tsconfig.json test/ ... testing files .eslintrc.js package.json tsconfig.json (symlink to src/tsconfig.json) .eslintrc.js module.exports = { 'env': { 'jest':

JS 逆向高阶 | JS 逆向的噩梦

梦想与她 提交于 2020-12-24 16:00:05
点击上方“ 咸鱼学Python ”,选择“ 加为星标 ” 第一时间关注Python技术干货! 作者:yacan8 原文:https://github.com/yacan8/blog/blob/master/posts/JavaScript抽象语法树AST.md 前言 Babel为当前最流行的代码JavaScript编译器了,其使用的JavaScript解析器为 babel-parser [1] ,最初是从 Acorn 项目 fork 出来的。Acorn 非常快,易于使用,并且针对非标准特性(以及那些未来的标准特性) 设计了一个基于插件的架构。本文主要介绍 esprima [2] 解析生成的抽象语法树节点, esprima 的实现也是基于Acorn的。 解析器 Parser JavaScript Parser 是把js源码转化为抽象语法树(AST)的解析器。这个步骤分为两个阶段: 词法分析(Lexical Analysis) [3] 和 语法分析(Syntactic Analysis) [4] 。 常用的JavaScript Parser: • esprima [5] • uglifyJS2 [6] • traceur [7] • acorn [8] • espree [9] • @babel/parser [10] 词法分析 词法分析阶段把字符串形式的代码转换为 令牌(tokens

推荐几个大厂的前端代码规范,你也能写出诗一样的代码!

不问归期 提交于 2020-12-21 14:26:44
Python实战社群 Java实战社群 长按识别下方二维码, 按需求添加 扫码关注添加客服 进Python社群▲ 扫码关注添加客服 进Java社群 ▲ 作者丨前端章鱼猫 来源丨前端GitHub(ID:FrontEndGitHub) 今天给大家带来的是 几个大厂的前端代码规范 。 前端代码规范 代码千万行,安全第一行;前端不规范,同事两行泪。 腾讯 包含内容也挺多的: PC端专题 :快速上手、文件目录、页面头部、通用title、通用foot、统计代码、兼容测试 移动端专题 :快速上手、文件目录、页面头部、REM布局、通用foot、统计代码、分享组件、兼容要求 双端官网 :快速上手、页面跳转 http://tgideas.qq.com/doc/index.html 不过里面也有一些内容是针对其业务的,并不通用。 京东 对比腾讯的代码规范,我更推荐凹凸实验室的代码规范,比较齐全。 HTML规范 基于W3C、苹果开发者等官方文档,并结合团队日常业务需求以及团队在日常开发过程中总结提炼出的经验而约定。 图片规范 了解各种图片格式特性,根据特性制定图片规范,包括但不限于图片的质量约定、图片引入方式、图片合并处理等。 CSS 规范 统一团队 CSS 代码书写和 SASS 预编译语言的语法风格,提供常用媒体查询语句和浏览器私有属性引用,并从业务层面统一规范常用模块的引用。 命名规范 从 “目录命名