React Or Taro 项目配置Eslint校验
npm install --save-dev eslint-plugin-prettier eslint-plugin-jsx-a11y eslint-config-airbnb
注意:由于eslint-config-airbnb目前版本已经超过19,会出现一个小问题,箭头函数和命名函数会被Eslint 提示冲突,这是由于19版本的升级导致的解决方案目前有两个
1,在.eslintrc.js 文件中添加了以下规则
'react/function-component-definition': [2, { namedComponents: 'arrow-function', unnamedComponents: 'arrow-function' }],
这样,eslint 将只接受组件的箭头函数,而不是函数表达式(默认情况下);
2,可以改变函数写法来解决冲突,这样是最简单的
箭头函数:const Demo = () : ReactNode => <div>demo</div>;
function Demo () {
return <div>demo</div>
}
3,通过改变版本去解决冲突,
直接下载指定的版本的包就可以解决,现在自测18.1.0可以满足当下需求;
// .eslintrc.js 如果编辑器module.exports报错,可尝试重启编辑器
module.exports = {
root: true,
extends: ['taro/react', 'airbnb', 'airbnb/hooks'],
parser: '@typescript-eslint/parser', // ESLint 默认使用 esprima 作为其解析器,也可以在配置文件中指定一个不同的解析器(它必须是一个 Node 模块,且它必须符合 parser interface)
plugins: [
'react',
'react-hooks',
'import',
'jsx-a11y'
],
rules: {
'react/function-component-definition': [2, { namedComponents: 'arrow-function', unnamedComponents: 'arrow-function' }],
'react/jsx-uses-react': 'off',
'react/react-in-jsx-scope': 'off',
'no-undef': 'off',
'import/no-extraneous-dependencies': 'off',
'import/prefer-default-export': 'off',
'import/no-unresolved': 'off',
'no-unused-vars': 'off',
'import/extensions': 'off',
'react/jsx-filename-extension': [1, { extensions: ['.js', '.jsx', '.ts', '.tsx'] }],
indent: ['error', 2, { SwitchCase: 1 }],
'linebreak-style': 'off',
quotes: ['error', 'single'],
semi: ['error', 'always'],
'dot-notation': 'off',
'spaced-comment': 'off',
'comma-dangle': 'off',
'space-before-function-paren': ['error', 'never'],
'one-var': 'off',
'one-var-declaration-per-line': 'off',
'no-use-before-define': 'off',
'no-restricted-globals': ['error', 'history'],
'class-methods-use-this': 'off',
radix: 'off',
'global-require': 'error',
'default-case': 'off',
'no-param-reassign': 'error',
'consistent-return': 'off',
'no-script-url': 'error',
'no-else-return': 'error',
'no-restricted-syntax': 'error',
'no-extend-native': 'error',
'no-return-assign': 'off',
'no-underscore-dangle': 'off',
'no-unused-expressions': ['error', {
allowShortCircuit: true,
allowTernary: true,
allowTaggedTemplates: true
}],
'max-len': ['error', {
code: 200,
ignoreComments: true,
ignoreUrls: true,
ignoreTemplateLiterals: true
}],
'jsx-quotes': ['error', 'prefer-single'],
'jsx-a11y/alt-text': 'off',
'jsx-a11y/no-autofocus': 'off',
'jsx-a11y/label-has-for': 'off',
'jsx-a11y/label-has-associated-control': 'off',
'jsx-a11y/media-has-caption': 'off',
'jsx-a11y/click-events-have-key-events': 'off',
'jsx-a11y/no-noninteractive-element-interactions': 'off',
'jsx-a11y/no-static-element-interactions': 'off',
'jsx-a11y/anchor-is-valid': 'off',
'prefer-destructuring': 'off',
'no-plusplus': 'off',
'no-trailing-spaces': 'off',
'react/prop-types': 'off',
'react/jsx-tag-spacing': 'off',
'import/no-duplicates': 'off',
'import/order': 'off',
'import/no-dynamic-require': 'off',
'react/no-did-update-set-state': 'error',
'react/no-unused-state': 'error',
'react/no-find-dom-node': 'error',
'react/forbid-prop-types': 'off',
'react/jsx-indent-props': 'off',
'react/no-array-index-key': 'off',
'react/require-default-props': 'off',
'react/sort-comp': 'off',
'react/jsx-wrap-multilines': 'off',
'react/destructuring-assignment': 'off',
'react/jsx-closing-bracket-location': 'off',
'react/jsx-first-prop-new-line': 'off',
'react/no-multi-comp': 'off',
'react/jsx-one-expression-per-line': 'off',
'react/no-access-state-in-setstate': 'off',
'react/jsx-no-bind': 'off',
'react/jsx-indent': [2, 2],
'react/no-unescaped-entities': 'off',
'no-prototype-builtins': 'error',
'no-nested-ternary': 'error',
'react-hooks/exhaustive-deps': 'off',
'react/jsx-no-target-blank': 'error',
'no-console': ['off'],
'react/jsx-props-no-spreading': 'off',
'react-hooks/rules-of-hooks': 'error',
'no-useless-constructor': 'off',
'no-empty-function': 'off',
'object-curly-newline': 'off',
'react/no-danger': 'off',
'react/button-has-type': 'off',
'no-multiple-empty-lines': 'off',
'no-useless-escape': 'off',
'react/no-unused-prop-types': 'off',
'react/default-props-match-prop-types': 'off',
camelcase: 'off',
},
};
// 没啥好讲的,直接将不需要检测的路径或文件丢在这里就ok
/.git/
/.Vscode/
node_modules//
dist/
module.exports = {
tabWidth: 4,
singleQuote: true,
jsxSingleQuote: true,
printWidth: 140,
endOfLine: 'auto',
};
# http://editorconfig.org
root = true
[*]
indent_style = space
indent_size = 4
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
end_of_line = crlf
[*.md]
trim_trailing_whitespace = false
// jsx自动修复
"editor.formatOnSave": true,
// 保存自动修复
"eslint.autoFixOnSave": true,
"eslint.run": "onSave",
"javascript.format.enable": false,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
},
"editor.formatOnPaste": false,
"editor.formatOnType": true,
"files.autoSave": "onFocusChange",
"eslint.nodePath": "",
"files.trimTrailingWhitespace": true,
"eslint.validate": [
"javascript",
"javascriptreact",
{
"language": "html",
"autoFix": true
},
{
"language": "react",
"autoFix": true
}
]
如何在buildr项目中使用Ruby?我在很多不同的项目中使用过Ruby、JRuby、Java和Clojure。我目前正在使用我的标准Ruby开发一个模拟应用程序,我想尝试使用Clojure后端(我确实喜欢功能代码)以及JRubygui和测试套件。我还可以看到在未来的不同项目中使用Scala作为后端。我想我要为我的项目尝试一下buildr(http://buildr.apache.org/),但我注意到buildr似乎没有设置为在项目中使用JRuby代码本身!这看起来有点傻,因为该工具旨在统一通用的JVM语言并且是在ruby中构建的。除了将输出的jar包含在一个独特的、仅限ruby
我有一个在Linux服务器上运行的ruby脚本。它不使用rails或任何东西。它基本上是一个命令行ruby脚本,可以像这样传递参数:./ruby_script.rbarg1arg2如何将参数抽象到配置文件(例如yaml文件或其他文件)中?您能否举例说明如何做到这一点?提前谢谢你。 最佳答案 首先,您可以运行一个写入YAML配置文件的独立脚本:require"yaml"File.write("path_to_yaml_file",[arg1,arg2].to_yaml)然后,在您的应用中阅读它:require"yaml"arg
我在我的Rails项目中使用Pow和powifygem。现在我尝试升级我的ruby版本(从1.9.3到2.0.0,我使用RVM)当我切换ruby版本、安装所有gem依赖项时,我通过运行railss并访问localhost:3000确保该应用程序正常运行以前,我通过使用pow访问http://my_app.dev来浏览我的应用程序。升级后,由于错误Bundler::RubyVersionMismatch:YourRubyversionis1.9.3,butyourGemfilespecified2.0.0,此url不起作用我尝试过的:重新创建pow应用程序重启pow服务器更新战俘
我已经像这样安装了一个新的Rails项目:$railsnewsite它执行并到达:bundleinstall但是当它似乎尝试安装依赖项时我得到了这个错误Gem::Ext::BuildError:ERROR:Failedtobuildgemnativeextension./System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/rubyextconf.rbcheckingforlibkern/OSAtomic.h...yescreatingMakefilemake"DESTDIR="cleanmake"DESTDIR="
我已经在Sinatra上创建了应用程序,它代表了一个简单的API。我想在生产和开发上进行部署。我想在部署时选择,是开发还是生产,一些方法的逻辑应该改变,这取决于部署类型。是否有任何想法,如何完成以及解决此问题的一些示例。例子:我有代码get'/api/test'doreturn"Itisdev"end但是在部署到生产环境之后我想在运行/api/test之后看到ItisPROD如何实现? 最佳答案 根据SinatraDocumentation:EnvironmentscanbesetthroughtheRACK_ENVenvironm
假设我有这个范围:("aaaaa".."zzzzz")如何在不事先/每次生成整个项目的情况下从范围中获取第N个项目? 最佳答案 一种快速简便的方法:("aaaaa".."zzzzz").first(42).last#==>"aaabp"如果出于某种原因你不得不一遍又一遍地这样做,或者如果你需要避免为前N个元素构建中间数组,你可以这样写:moduleEnumerabledefskip(n)returnto_enum:skip,nunlessblock_given?each_with_indexdo|item,index|yieldit
之前在培训新生的时候,windows环境下配置opencv环境一直教的都是网上主流的vsstudio配置属性表,但是这个似乎对新生来说难度略高(虽然个人觉得完全是他们自己的问题),加之暑假之后对cmake实在是爱不释手,且这样配置确实十分简单(其实都不需要配置),故斗胆妄言vscode下配置CV之法。其实极为简单,图比较多所以很长。如果你看此文还配不好,你应该思考一下是不是自己的问题。闲话少说,直接开始。0.CMkae简介有的人到大二了都不知道cmake是什么,我不说是谁。CMake是一个开源免费并且跨平台的构建工具,可以用简单的语句来描述所有平台的编译过程。它能够根据当前所在平台输出对应的m
注意:本文主要掌握DCN自研无线产品的基本配置方法和注意事项,能够进行一般的项目实施、调试与运维AP基本配置命令AP登录用户名和密码均为:adminAP默认IP地址为:192.168.1.10AP默认情况下DHCP开启AP静态地址配置:setmanagementstatic-ip192.168.10.1AP开启/关闭DHCP功能:setmanagementdhcp-statusup/downAP设置默认网关:setstatic-ip-routegeteway192.168.10.254查看AP基本信息:getsystemgetmanagementgetmanaged-apgetrouteAP配
1.1.1 YARN的介绍 为克服Hadoop1.0中HDFS和MapReduce存在的各种问题⽽提出的,针对Hadoop1.0中的MapReduce在扩展性和多框架⽀持⽅⾯的不⾜,提出了全新的资源管理框架YARN. ApacheYARN(YetanotherResourceNegotiator的缩写)是Hadoop集群的资源管理系统,负责为计算程序提供服务器计算资源,相当于⼀个分布式的操作系统平台,⽽MapReduce等计算程序则相当于运⾏于操作系统之上的应⽤程序。 YARN被引⼊Hadoop2,最初是为了改善MapReduce的实现,但是因为具有⾜够的通⽤性,同样可以⽀持其他的分布式计算模
我是ruby的新手,正在配置IRB。我喜欢pretty-print(需要'pp'),但总是输入pp来漂亮地打印它似乎很麻烦。我想做的是默认情况下让它漂亮地打印出来,所以如果我有一个var,比如说,'myvar',然后键入myvar,它会自动调用pretty_inspect而不是常规检查。我从哪里开始?理想情况下,我将能够向我的.irbrc文件添加一个自动调用的方法。有什么想法吗?谢谢! 最佳答案 irb中默认pretty-print对象正是hirb被迫去做。Theseposts解释hirb如何将几乎所有内容转换为ascii表。虽