chore: replace all cn comments of fe to en version by volc api (#320)
This commit is contained in:
@@ -48,7 +48,7 @@ export const flowPreset = {
|
||||
'@coze-arch/tsx-no-leaked-render': 'warn',
|
||||
'@coze-arch/no-pkg-dir-import': 'error',
|
||||
'@coze-arch/no-duplicated-deps': 'error',
|
||||
// 不允许超过 4 层的相对应用
|
||||
// Relative applications with more than 4 layers are not allowed
|
||||
'@coze-arch/no-deep-relative-import': [
|
||||
'error',
|
||||
{
|
||||
@@ -56,7 +56,7 @@ export const flowPreset = {
|
||||
},
|
||||
],
|
||||
'@coze-arch/package-require-author': 'error',
|
||||
// 函数代码行不要超过 150
|
||||
// Function code lines should not exceed 150.
|
||||
'@coze-arch/max-line-per-function': [
|
||||
'error',
|
||||
{
|
||||
@@ -73,11 +73,11 @@ export const flowPreset = {
|
||||
files: ['package.json'],
|
||||
processor: '@coze-arch/json-processor',
|
||||
rules: {
|
||||
// TODO: 需要重构为直接解析json,否则全局规则都会对processor处理后的文件`package.js`生效.
|
||||
// TODO: It needs to be refactored to parse json directly, otherwise the global rules will take effect on the file'package.js' processed by the processor.
|
||||
//https://github.com/eslint/json
|
||||
'@coze-arch/package-require-author': 'error',
|
||||
'@coze-arch/package-disallow-deps': 'error',
|
||||
// 关闭prettier规则,因为该规则lint package.js存在bug
|
||||
// Close the prettier rule because there is a bug in the rule lint package.js
|
||||
'prettier/prettier': 'off',
|
||||
},
|
||||
},
|
||||
|
||||
@@ -36,7 +36,7 @@ const getStaticStringValue = node => {
|
||||
*
|
||||
* @param node
|
||||
* @returns
|
||||
* 为什么需要这个判断,对于下面这种函数
|
||||
* Why is this judgment necessary for a function such as
|
||||
* ```
|
||||
* var obj1 = {
|
||||
* set
|
||||
@@ -46,9 +46,9 @@ const getStaticStringValue = node => {
|
||||
* }
|
||||
* }
|
||||
*```
|
||||
* 如果不采用下面这个判断,函数判断将得到3,实际应该为5. 类似的还有
|
||||
* If you don't use the following judgment, the function judgment will get 3, which should actually be 5. Similarly, there are
|
||||
* ```
|
||||
* //如果不采用下面这个判断,函数判断将得到3,实际应该为8
|
||||
* //If the following judgment is not used, the function judgment will get 3, which should actually be 8ing judgment, the function judgment will get 3, which should actually be 8.
|
||||
* class A {
|
||||
static
|
||||
[
|
||||
@@ -85,14 +85,14 @@ const isEmbedded = node => {
|
||||
*
|
||||
* @param node
|
||||
* @returns function name
|
||||
* Q:为什么不直接用 node.id.value获取函数名称 ?
|
||||
* A:这种方式对于 传统的函数写法没问题,但是对于
|
||||
* Q: Why not get the function name directly with node.id?
|
||||
* A: This method is fine for traditional function writing, but for
|
||||
* const tips = {
|
||||
* fun: () => {}
|
||||
* };
|
||||
* 或者
|
||||
* or
|
||||
* const fun2 = () => {}
|
||||
* 方式书写函数得到的名称为null,所以采取下面这种方式获取,
|
||||
* The name of the function written in the following way is null, so it is obtained in the following way.
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -192,7 +192,7 @@ const getStaticPropertyName = node => {
|
||||
case 'VariableDeclarator':
|
||||
prop = node.id;
|
||||
break;
|
||||
//TODO: CallExpression 场景较为复杂,目前应该没有完全覆盖
|
||||
//TODO: The CallExpression scenario is more complex and should not be fully covered at present
|
||||
case 'CallExpression':
|
||||
prop = node.callee;
|
||||
break;
|
||||
@@ -240,7 +240,7 @@ export const maxLinePerFunctionRule: Rule.RuleModule = {
|
||||
function checkFunctionLength(funcNode) {
|
||||
const node = isEmbedded(funcNode) ? funcNode.parent : funcNode;
|
||||
|
||||
// 针对函数声明,函数表达式,箭头函数,函数定义四种类型
|
||||
// Four types of function declarations, function expressions, arrow functions, and function definitions
|
||||
if (
|
||||
node.type === 'FunctionDeclaration' ||
|
||||
node.type === 'FunctionExpression' ||
|
||||
|
||||
@@ -40,7 +40,7 @@ export const noDuplicatedDepsRule: Rule.RuleModule = {
|
||||
if (!properties) {
|
||||
return;
|
||||
}
|
||||
// 对比 dependencies 与 devDependencies 之间是否存在重复依赖
|
||||
// Compare dependencies with devDependencies for duplicate dependencies
|
||||
const dependencies = properties.find(
|
||||
p => p.key.value === 'dependencies',
|
||||
);
|
||||
|
||||
@@ -40,7 +40,7 @@ export const noPkgDirImport: Rule.RuleModule = {
|
||||
const modulePath = resolve(importPath, context);
|
||||
|
||||
if (!modulePath) {
|
||||
// 解析不到的情况,暂不处理
|
||||
// If it cannot be resolved, it will not be dealt with for the time being.
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -56,15 +56,15 @@ export const noPkgDirImport: Rule.RuleModule = {
|
||||
return;
|
||||
}
|
||||
|
||||
// 本地link会解析到node_modules目录,需要拿到pkg name再次解析。
|
||||
// The local link will resolve to the node_modules directory, and you need to get the pkg name to resolve it again.
|
||||
const moduleRealPath = resolve(pkg.name, context);
|
||||
|
||||
if (
|
||||
// 包名称就是引用路径
|
||||
// The package name is the reference path
|
||||
pkg.name === importPath ||
|
||||
// 解析到其他包,如@type
|
||||
// Parse to other packages, such as @type
|
||||
!importPath.startsWith(pkg.name) ||
|
||||
// 解析到自己包的文件
|
||||
// Parse to the file of your own package
|
||||
currentPkgPath === importPkgPath ||
|
||||
!moduleRealPath ||
|
||||
moduleRealPath.includes('node_modules')
|
||||
|
||||
@@ -32,7 +32,7 @@ vi.mock('eslint-module-utils/readPkgUp', () => ({
|
||||
const validCases = [
|
||||
{
|
||||
code: 'import "xxx"',
|
||||
modulePath: undefined, // modulePath 为 空
|
||||
modulePath: undefined, // modulePath is empty
|
||||
moduleRealPath: undefined,
|
||||
importPkgPath: 'path/to/import/pkg',
|
||||
currentPkgPath: 'path/to/current/pkg',
|
||||
@@ -48,7 +48,7 @@ const validCases = [
|
||||
importPkgPath: 'path/to/import/pkg',
|
||||
currentPkgPath: 'path/to/current/pkg',
|
||||
pkg: {
|
||||
name: 'some/pkg', // 包名称与引用路径相同
|
||||
name: 'some/pkg', // The package name is the same as the reference path
|
||||
exports: {},
|
||||
},
|
||||
},
|
||||
@@ -59,7 +59,7 @@ const validCases = [
|
||||
importPkgPath: 'path/to/import/pkg',
|
||||
currentPkgPath: 'path/to/current/pkg',
|
||||
pkg: {
|
||||
name: undefined, // 解析到不规范配置的package.json
|
||||
name: undefined, // Parse to the non-canonical package.json
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -69,7 +69,7 @@ const validCases = [
|
||||
importPkgPath: 'path/to/import/pkg',
|
||||
currentPkgPath: 'path/to/current/pkg',
|
||||
pkg: {
|
||||
name: '@types/pkg', // 解析到类型包
|
||||
name: '@types/pkg', // Parse to type package
|
||||
exports: {},
|
||||
},
|
||||
},
|
||||
@@ -77,7 +77,7 @@ const validCases = [
|
||||
code: "import pkg from 'pkg';",
|
||||
modulePath: 'path/to/module',
|
||||
moduleRealPath: 'path/to/module',
|
||||
importPkgPath: 'path/to/same/pkg', // 相同路径
|
||||
importPkgPath: 'path/to/same/pkg', // same path
|
||||
currentPkgPath: 'path/to/same/pkg',
|
||||
pkg: {
|
||||
name: '@types/pkg',
|
||||
@@ -98,7 +98,7 @@ const validCases = [
|
||||
{
|
||||
code: "import pkg from 'pkg';",
|
||||
modulePath: 'path/to/module',
|
||||
moduleRealPath: 'path/to/node_modules/pkg', // 解析到node_modules
|
||||
moduleRealPath: 'path/to/node_modules/pkg', // Parse to node_modules
|
||||
importPkgPath: 'path/to/import/pkg',
|
||||
currentPkgPath: 'path/to/current/pkg',
|
||||
pkg: {
|
||||
@@ -134,7 +134,7 @@ const validCases = [
|
||||
if (!c.modulePath) {
|
||||
return {
|
||||
code: c.code,
|
||||
// TODO: 避免eslint duplication检测。可能需要改为其他方式
|
||||
// TODO: Avoid eslint duplication. It may need to be changed to another way
|
||||
settings: c,
|
||||
};
|
||||
}
|
||||
@@ -167,7 +167,7 @@ const invalidCases = [
|
||||
currentPkgPath: 'path/to/current/pkg',
|
||||
pkg: {
|
||||
name: 'pkg',
|
||||
exports: undefined, // 为空
|
||||
exports: undefined, // empty
|
||||
},
|
||||
messageId: 'noExportsCfg',
|
||||
},
|
||||
|
||||
@@ -56,7 +56,7 @@ export const disallowDepRule: Rule.RuleModule = {
|
||||
return;
|
||||
}
|
||||
const [, blockVersion, tips] = definition;
|
||||
// 没有提供 version 参数,判定为不允许所有版本号
|
||||
// No version parameter is provided, and it is determined that all version numbers are not allowed
|
||||
if (typeof blockVersion !== 'string' || blockVersion.length <= 0) {
|
||||
context.report({
|
||||
node,
|
||||
|
||||
@@ -20,12 +20,12 @@ import reactPlugin from 'eslint-plugin-react';
|
||||
|
||||
const originRule = reactPlugin.rules['jsx-no-leaked-render'];
|
||||
|
||||
// 扩展react/jsx-no-leaked-render。增加判断 「&&」 表达式左边为 boolean 、 null 、 undefined TS类型,则不报错。
|
||||
// Expand the react/jsx-no-leaked-render. If the left side of the "& &" expression is boolean, null, undefined TS type, no error will be reported.
|
||||
export const tsxNoLeakedRender = ruleComposer.filterReports(
|
||||
originRule,
|
||||
problem => {
|
||||
const { parent } = problem.node;
|
||||
// 如果表达式是用于jsx属性,则不需要修复。 如 <Comp prop={ { foo: 1 } && obj } />
|
||||
// If the expression is used for jsx properties, it does not need to be fixed. Such as < Comp prop = {{foo: 1} & & obj}/>
|
||||
if (
|
||||
parent?.type === AST_NODE_TYPES.JSXExpressionContainer &&
|
||||
parent?.parent?.type === AST_NODE_TYPES.JSXAttribute
|
||||
|
||||
@@ -25,7 +25,7 @@ ruleTester.run('prefer-shallow', preferShallow, {
|
||||
'new Foo()',
|
||||
'useShallowedFooStore()',
|
||||
'useFooStore((s) => s.value)',
|
||||
'useFooStore(selector)', // 暂时豁免
|
||||
'useFooStore(selector)', // Temporary exemption
|
||||
'useShallowFooStore(() => ({}))',
|
||||
'useFooStore(useShallow(() => ({})))',
|
||||
'useFooStore(useShallow(() => ([])))',
|
||||
|
||||
Reference in New Issue
Block a user