xshell 1.0.86 → 1.0.87

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/package.json +7 -3
  2. package/xlint.d.ts +3 -108
  3. package/xlint.js +150 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xshell",
3
- "version": "1.0.86",
3
+ "version": "1.0.87",
4
4
  "type": "module",
5
5
  "main": "./index.js",
6
6
  "bin": {
@@ -58,6 +58,8 @@
58
58
  "@babel/traverse": "^7.24.1",
59
59
  "@koa/cors": "^5.0.0",
60
60
  "@types/ws": "^8.5.10",
61
+ "@typescript-eslint/eslint-plugin": "^7.5.0",
62
+ "@typescript-eslint/parser": "^7.5.0",
61
63
  "@typescript-eslint/utils": "^7.5.0",
62
64
  "ali-oss": "^6.20.0",
63
65
  "archiver": "^7.0.1",
@@ -69,6 +71,9 @@
69
71
  "colors": "^1.4.0",
70
72
  "commander": "^12.0.0",
71
73
  "emoji-regex": "^10.3.0",
74
+ "eslint": "^9.0.0",
75
+ "eslint-plugin-import": "^2.29.1",
76
+ "eslint-plugin-react": "^7.34.1",
72
77
  "gulp-sort": "^2.0.0",
73
78
  "hash-string": "^1.0.0",
74
79
  "i18next": "^23.10.1",
@@ -120,8 +125,7 @@
120
125
  "@types/tough-cookie": "^4.0.5",
121
126
  "@types/ua-parser-js": "^0.7.39",
122
127
  "@types/vinyl-fs": "^3.0.5",
123
- "@types/vscode": "^1.88.0",
124
- "eslint": "^9.0.0"
128
+ "@types/vscode": "^1.88.0"
125
129
  },
126
130
  "pnpm": {
127
131
  "patchedDependencies": {
package/xlint.d.ts CHANGED
@@ -1,108 +1,3 @@
1
- import type ESTree from 'estree';
2
- import type { Rule } from 'eslint';
3
- import { TSESTree, type TSESLint } from '@typescript-eslint/utils';
4
- export declare const xlint_plugin: {
5
- rules: {
6
- 'fold-jsdoc-comments': {
7
- meta: {
8
- readonly fixable: "whitespace";
9
- readonly type: "layout";
10
- };
11
- create: (context: Rule.RuleContext) => {
12
- Program(): void;
13
- };
14
- };
15
- 'nonblock-statement-body-position-with-indentation': {
16
- meta: {
17
- readonly fixable: "whitespace";
18
- readonly type: "layout";
19
- };
20
- create(context: Rule.RuleContext): {
21
- IfStatement(node: ESTree.IfStatement & Rule.NodeParentExtension): void;
22
- WhileStatement: (node: ESTree.WhileStatement & Rule.NodeParentExtension) => void;
23
- DoWhileStatement: (node: ESTree.DoWhileStatement & Rule.NodeParentExtension) => void;
24
- ForStatement: (node: ESTree.ForStatement & Rule.NodeParentExtension) => void;
25
- ForInStatement: (node: ESTree.ForInStatement & Rule.NodeParentExtension) => void;
26
- ForOfStatement: (node: ESTree.ForOfStatement & Rule.NodeParentExtension) => void;
27
- };
28
- };
29
- 'empty-bracket-spacing': {
30
- meta: {
31
- readonly fixable: "whitespace";
32
- readonly type: "layout";
33
- };
34
- create(context: Rule.RuleContext): {
35
- ObjectExpression(node: ESTree.ObjectExpression & Rule.NodeParentExtension): void;
36
- ArrayExpression(node: ESTree.ArrayExpression & Rule.NodeParentExtension): void;
37
- BlockStatement(node: ESTree.BlockStatement & Rule.NodeParentExtension): void;
38
- };
39
- };
40
- 'space-infix-ops-except-exponentiation': {
41
- meta: {
42
- messages: {
43
- missingSpace: string;
44
- redundantSpace: string;
45
- };
46
- fixable: "whitespace";
47
- type: "layout";
48
- };
49
- create(context: TSESLint.RuleContext<'missingSpace' | 'redundantSpace', any[]>): {
50
- AssignmentExpression: (node: any) => void;
51
- AssignmentPattern: (node: any) => void;
52
- BinaryExpression: (node: any) => void;
53
- LogicalExpression: (node: any) => void;
54
- ConditionalExpression: (node: any) => void;
55
- VariableDeclarator: (node: any) => void;
56
- TSEnumMember: (node: TSESTree.TSEnumMember) => void;
57
- PropertyDefinition: (node: TSESTree.PropertyDefinition) => void;
58
- TSTypeAliasDeclaration: (node: TSESTree.TSTypeAliasDeclaration) => void;
59
- TSUnionType: (typeAnnotation: TSESTree.TSIntersectionType | TSESTree.TSUnionType) => void;
60
- TSIntersectionType: (typeAnnotation: TSESTree.TSIntersectionType | TSESTree.TSUnionType) => void;
61
- TSConditionalType: (node: TSESTree.TSConditionalType) => void;
62
- };
63
- };
64
- 'space-in-for-statement': {
65
- meta: {
66
- readonly fixable: "whitespace";
67
- readonly type: "layout";
68
- };
69
- create(context: Rule.RuleContext): {
70
- ForStatement(node: ESTree.ForStatement & Rule.NodeParentExtension): void;
71
- };
72
- };
73
- 'jsx-no-redundant-parenthesis-in-return': {
74
- meta: {
75
- readonly fixable: "whitespace";
76
- readonly type: "layout";
77
- };
78
- create(context: Rule.RuleContext): {
79
- ReturnStatement(node: ESTree.ReturnStatement & Rule.NodeParentExtension): void;
80
- ArrowFunctionExpression(node: ESTree.ArrowFunctionExpression & Rule.NodeParentExtension): void;
81
- };
82
- };
83
- 'keep-indent': {
84
- meta: {
85
- readonly fixable: "whitespace";
86
- readonly type: "layout";
87
- };
88
- create(context: Rule.RuleContext): {
89
- Program(): void;
90
- };
91
- };
92
- 'func-style': {
93
- meta: {
94
- readonly fixable: "whitespace";
95
- readonly type: "layout";
96
- };
97
- create(context: Rule.RuleContext): {
98
- FunctionDeclaration(node: ESTree.FunctionDeclaration & Rule.NodeParentExtension): void;
99
- 'FunctionDeclaration:exit'(): void;
100
- FunctionExpression(node: ESTree.FunctionExpression & Rule.NodeParentExtension): void;
101
- 'FunctionExpression:exit'(): void;
102
- ThisExpression(): void;
103
- ArrowFunctionExpression(): void;
104
- 'ArrowFunctionExpression:exit'(node: ESTree.ArrowFunctionExpression & Rule.NodeParentExtension): void;
105
- };
106
- };
107
- };
108
- };
1
+ import type { ESLint, Linter } from 'eslint';
2
+ export declare const xlint_plugin: ESLint.Plugin;
3
+ export declare const xlint_config: Linter.FlatConfig;
package/xlint.js CHANGED
@@ -1,4 +1,8 @@
1
1
  import { AST_TOKEN_TYPES, ASTUtils, TSESTree } from '@typescript-eslint/utils';
2
+ import TSParser from '@typescript-eslint/parser';
3
+ import ts_plugin from '@typescript-eslint/eslint-plugin';
4
+ import react_plugin from 'eslint-plugin-react';
5
+ import import_plugin from 'eslint-plugin-import';
2
6
  const line_break_pattern = /\r\n|[\r\n\u2028\u2029]/u;
3
7
  const meta = {
4
8
  fixable: 'whitespace',
@@ -724,6 +728,152 @@ export const xlint_plugin = {
724
728
  // }
725
729
  }
726
730
  };
731
+ export const xlint_config = {
732
+ files: ['**/*.{js,mjs,cjs,ts,tsx,mts,cts}'],
733
+ ignores: [
734
+ '*.d.ts',
735
+ 'node_modules/',
736
+ '.git/',
737
+ ],
738
+ languageOptions: {
739
+ ecmaVersion: 'latest',
740
+ parser: TSParser,
741
+ parserOptions: {
742
+ ecmaVersion: 'latest',
743
+ sourceType: 'module',
744
+ project: './tsconfig.json',
745
+ ecmaFeatures: {
746
+ jsx: true
747
+ },
748
+ },
749
+ },
750
+ plugins: {
751
+ '@typescript-eslint': ts_plugin,
752
+ react: react_plugin,
753
+ import: import_plugin,
754
+ xlint: xlint_plugin,
755
+ },
756
+ settings: {
757
+ react: {
758
+ version: 'detect'
759
+ }
760
+ },
761
+ rules: {
762
+ 'xlint/fold-jsdoc-comments': 'error',
763
+ // 取代 nonblock-statement-body-position
764
+ 'xlint/nonblock-statement-body-position-with-indentation': 'error',
765
+ 'xlint/empty-bracket-spacing': 'error',
766
+ // a + b**c
767
+ 'xlint/space-infix-ops-except-exponentiation': 'error',
768
+ 'xlint/space-in-for-statement': 'error',
769
+ 'xlint/jsx-no-redundant-parenthesis-in-return': 'error',
770
+ 'xlint/keep-indent': 'error',
771
+ // 函数使用 function 来声明而不是 const foo = () => { }
772
+ 'xlint/func-style': 'error',
773
+ '@typescript-eslint/semi': ['error', 'never'],
774
+ '@typescript-eslint/no-extra-semi': 'error',
775
+ 'semi-style': ['error', 'first'],
776
+ // 使用 ===
777
+ eqeqeq: 'error',
778
+ // 父类尽量返回 this 类型
779
+ '@typescript-eslint/prefer-return-this-type': 'error',
780
+ // 尽量使用 . 访问属性而不是 []
781
+ '@typescript-eslint/dot-notation': 'error',
782
+ // 必须 throw Error
783
+ '@typescript-eslint/no-throw-literal': 'error',
784
+ // ------------ async
785
+ // 返回 Promise 的函数一定要标记为 async 函数
786
+ '@typescript-eslint/promise-function-async': 'error',
787
+ // 不要 return await promise, 直接 return promise, 除非外面有 try catch
788
+ '@typescript-eslint/return-await': 'error',
789
+ // ------------ 括号
790
+ // a => { } 而不是 (a) => { }
791
+ 'arrow-parens': ['error', 'as-needed', { requireForBlockBody: false }],
792
+ // 不要多余的大括号
793
+ // if (true)
794
+ // console.log()
795
+ curly: ['error', 'multi'],
796
+ // 简单属性不要冗余的大括号 <Component prop='simple-value' />
797
+ 'react/jsx-curly-brace-presence': ['error', 'never'],
798
+ // ------------ 空格
799
+ // { a, b } 这样的对象,大括号里面要有空格
800
+ '@typescript-eslint/object-curly-spacing': ['error', 'always'],
801
+ // [a, b, c]
802
+ '@typescript-eslint/comma-spacing': 'error',
803
+ // foo()
804
+ '@typescript-eslint/func-call-spacing': 'error',
805
+ // a => { } 中箭头左右两边空格
806
+ 'arrow-spacing': ['error'],
807
+ // 注释双斜杠后面要有空格
808
+ 'spaced-comment': ['error', 'always', { markers: ['/'] }],
809
+ // 函数声明中,名称后面要有空格
810
+ '@typescript-eslint/space-before-function-paren': 'error',
811
+ // { return true } 这样的 block 大括号里面要有空格
812
+ 'block-spacing': ['error', 'always'],
813
+ // aaa: 123
814
+ '@typescript-eslint/key-spacing': ['error', { beforeColon: false, afterColon: true, mode: 'minimum' }],
815
+ // aaa: string
816
+ '@typescript-eslint/type-annotation-spacing': 'error',
817
+ // if ()
818
+ '@typescript-eslint/keyword-spacing': ['error', { before: true, after: true }],
819
+ // if (1) { }
820
+ '@typescript-eslint/space-before-blocks': 'error',
821
+ // case 1: ...
822
+ 'switch-colon-spacing': 'error',
823
+ // <Hello name={firstname} />
824
+ 'react/jsx-equals-spacing': ['error', 'never'],
825
+ // 不允许使用 tab
826
+ 'no-tabs': 'error',
827
+ // 使用 \n 换行
828
+ 'linebreak-style': ['error', 'unix'],
829
+ // 文件以 \n 结尾
830
+ 'eol-last': ['error', 'always'],
831
+ // ------------ 引号
832
+ // 用单引号
833
+ 'jsx-quotes': ['error', 'prefer-single'],
834
+ // 用单引号
835
+ quotes: ['error', 'single', { avoidEscape: true, allowTemplateLiterals: false }],
836
+ // 不要冗余的引号包裹属性
837
+ 'quote-props': ['error', 'as-needed', { keywords: false, unnecessary: true }],
838
+ // ------------ 其它
839
+ // boolean 属性不要冗余的 ={true} <Component boolprop />
840
+ 'react/jsx-boolean-value': ['error', 'never'],
841
+ // 没有 children 的 Component 写成闭合标签 <Component />
842
+ 'react/self-closing-comp': 'error',
843
+ // 单行类型声明用 `,` 分割,多行类型声明结尾不要加分号
844
+ '@typescript-eslint/member-delimiter-style': [
845
+ 'error',
846
+ {
847
+ multiline: {
848
+ delimiter: 'none',
849
+ requireLast: false
850
+ },
851
+ singleline: {
852
+ delimiter: 'comma',
853
+ requireLast: false
854
+ }
855
+ }
856
+ ],
857
+ '@typescript-eslint/prefer-includes': 'error',
858
+ '@typescript-eslint/prefer-regexp-exec': 'error',
859
+ // 禁止使用 export default
860
+ 'no-restricted-exports': [
861
+ 'error',
862
+ { restrictDefaultExports: { direct: true, named: true, defaultFrom: true, namedFrom: true, namespaceFrom: true } }
863
+ ],
864
+ '@typescript-eslint/consistent-type-imports': ['error', { fixStyle: 'inline-type-imports', disallowTypeAnnotations: false }],
865
+ // () => { 返回 void 的表达式 }
866
+ '@typescript-eslint/no-confusing-void-expression': 'error',
867
+ // ------------ import
868
+ 'import/no-duplicates': ['error', { 'prefer-inline': true }],
869
+ 'import/order': [
870
+ 'error',
871
+ {
872
+ 'newlines-between': 'always-and-inside-groups'
873
+ }
874
+ ]
875
+ }
876
+ };
727
877
  function split_indent(line) {
728
878
  let i = 0;
729
879
  let indent = 0;