eslint

Eslint does not allow static class properties

一世执手 提交于 2021-02-04 17:05:30
问题 I'm current developing an API on Node 12.14.1 and using Eslint to help me write the code. Unfortunately it does not allow me to set static class properties as shown below: class AuthManager { static PROP = 'value' } The following error is given: Parsing error: Unexpected token =eslint Static class properties are already supported on JS and on Node. How can this rule be disable? I also have the following .eslintrc.json file: { "env": { "es6": true, "node": true }, "extends": "eslint

Eslint rule to put a new line inside import

旧城冷巷雨未停 提交于 2021-02-04 14:51:13
问题 The rule that I'm looking should show error in this case: import {MY_CONSTANT1, MY_CONSTANT2, MY_CONSTANT3} And considered as fine in this case: import { MY_CONSTANT1, MY_CONSTANT2, MY_CONSTANT3 } Is there such eslint rule? 回答1: I was looking for such a rule for both import and export declaration. As a result I've made a plugin with autofix. So plugin transforms the code import { k1, k2 } from 'something' into import { k1, k2 } from 'something' and code export { name1, name2, nameN } into

Eslint rule to put a new line inside import

点点圈 提交于 2021-02-04 14:51:05
问题 The rule that I'm looking should show error in this case: import {MY_CONSTANT1, MY_CONSTANT2, MY_CONSTANT3} And considered as fine in this case: import { MY_CONSTANT1, MY_CONSTANT2, MY_CONSTANT3 } Is there such eslint rule? 回答1: I was looking for such a rule for both import and export declaration. As a result I've made a plugin with autofix. So plugin transforms the code import { k1, k2 } from 'something' into import { k1, k2 } from 'something' and code export { name1, name2, nameN } into

京东扫描平台EOS—JS扫描落地与实践

十年热恋 提交于 2021-02-03 12:04:20
"程序是写给人读的,只是偶尔让计算机执行一下。—— Donald Knuth" 引言 随着前端应用的大型化和复杂化,越来越多的前端工程师和团队开始重视 JavaScript 代码规范。得益于前端开源社区的繁盛,当下已经有几种较为成熟的 JavaScript 代码规范检查工具,包括 JSLint、JSHint、ESLint、FECS 等等。EOS-JS,它是一款插件化的JavaScript 代码静态检查工具,具备全套的热修复、增量更新方案,集各类代码规范检查工具优势于一体,其核心是通过对代码解析得到的 AST(Abstract Syntax Tree,抽象语法树)进行模式匹配,定位不符合约定规范的代码、给出修改意见并支持一键修复,在降低维护成本、提升执行效率的同时,也保障了代码规范的统一。 为实现规范编码、提高编码质量,目前较为通用的是直接使用开源生态中提供的一些标准方案,可以用较低成本来实现 JavaScript 代码规范的落地。如果再搭配一些辅助工具(例如 husky 和 lint-staged),整个流程会更加顺畅。但是对于大型企业开发团队而言,数十人甚至上千人面对数万个工程,规模化地应用统一的 JavaScript 代码规范,并且有效落地执行,问题就会变得较为复杂。 痛点分析 设计初期,我们收集了大量前端开发人员的编码痛点,可以归纳为以下几点: 人员角度 公司部门团队较多

antd pro 新增模块的步骤

杀马特。学长 韩版系。学妹 提交于 2021-02-02 06:57:21
index.js是整个项目的入口文件。 // 1. Initialize const app = dva({ history: createHistory(), }); // 2. Plugins app.use(createLoading()); // 3. Register global model app.model(require('./models/global').default); // 4. Router app.router(require('./router').default); // 5. Start app.start('#root'); export default app._store; // eslint-disable-line 找到/src/common/menu.js中进行菜单配置, 在/src/common/router.js的routerConfig中配置路由,其中第一个参数是一个DvaInstance的实例,是index.js文件中定义的;第二个参数是该页面对应的model,即数据存储的地方;第三个参数是一个函数,返回对应的页面。 '/': { component: dynamicWrapper(app, ['user', 'login'], () => import('../layouts/BasicLayout')), },

Import typescript file in FlowJS (eslit: Flow: Cannot resolve module)

柔情痞子 提交于 2021-01-29 14:29:44
问题 I trying incrementaly migration from Flow to Typescript . I use webpack with babel for transpile flow and typescript. ('@babel/preset-flow', '@babel/typescript') I have this import in FLOW file test.js /* @flow */ import MyComponent from 'components/myComponent' on path: src/components/myComponent/index.tsx is class MyComponent extends Component<Props> { render() {} } export default MyComponent My WebStorm IDE display eslint error Flow : Cannot resolve module components/myComponent For

Suppress ESLint warnings in VSCode

依然范特西╮ 提交于 2021-01-29 06:58:45
问题 I am using ESLint extension in VSCode to format and check my JavaScript code. However, I don't want ESLint to show me warnings (red lines below code), esp. the ones related to code formatting, but still do the formatting every time I save the file. Is it possible to do this? Here is my VSCode config: { "editor.fontSize": 14, "explorer.openEditors.visible": 0, "files.autoSave": "onFocusChange", "terminal.integrated.fontSize": 14, "terminal.integrated.lineHeight": 1.3, "terminal.integrated

Suppress ESLint warnings in VSCode

我的未来我决定 提交于 2021-01-29 06:53:02
问题 I am using ESLint extension in VSCode to format and check my JavaScript code. However, I don't want ESLint to show me warnings (red lines below code), esp. the ones related to code formatting, but still do the formatting every time I save the file. Is it possible to do this? Here is my VSCode config: { "editor.fontSize": 14, "explorer.openEditors.visible": 0, "files.autoSave": "onFocusChange", "terminal.integrated.fontSize": 14, "terminal.integrated.lineHeight": 1.3, "terminal.integrated

ESLint rule for camelCased argument names

痴心易碎 提交于 2021-01-29 03:05:17
问题 I want to use camelCase function argument names: myFunc(goodArg, BadArg) { ... } I found ESLint's camelcase rule. Unfortunately it does not apply to argument names, just variables and properties. Is there a way to automatically just function argument names? I don't mind using another linter if it helps. 来源: https://stackoverflow.com/questions/36777168/eslint-rule-for-camelcased-argument-names

Remove ESLint from React project

陌路散爱 提交于 2021-01-28 14:01:16
问题 I configured ESLint to my project using eslint --init , it's configured to my project. Now I want to remove that from my project because it's showing unnecessary errors over the project. How to remove the initiated ESLint from my project? 回答1: Basically, just delete .eslintrc and any other eslint config files(if any) from the project. Also, check your package.json and delete all eslint packages and do npm install on your project. Also, if you are using vscode, you can disable it with a simple