Skip to content

Commit 4f1d65c

Browse files
committed
Add lint and fix test
1 parent c9bdb7a commit 4f1d65c

File tree

11 files changed

+2002
-97
lines changed

11 files changed

+2002
-97
lines changed

.github/workflows/test.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ jobs:
4646
mamba-version: "*"
4747
channels: conda-forge
4848
python-version: "3.7"
49+
4950
- name: Install dependencies
5051
run: |
5152
mamba install python=${{ matrix.python-version }} pip nodejs=16 yarn
@@ -58,6 +59,11 @@ jobs:
5859
yarn build
5960
cd ../tests; npm install
6061
62+
- name: Linter check
63+
working-directory: javascript
64+
run: |
65+
yarn lint:check
66+
6167
- name: Run Python tests
6268
run: |
6369
pytest -v

javascript/.eslintcache

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[{"/home/fcollonval/projects/jupyter_ydoc/javascript/lib/api.d.ts":"1","/home/fcollonval/projects/jupyter_ydoc/javascript/lib/api.js":"2","/home/fcollonval/projects/jupyter_ydoc/javascript/lib/index.d.ts":"3","/home/fcollonval/projects/jupyter_ydoc/javascript/lib/index.js":"4","/home/fcollonval/projects/jupyter_ydoc/javascript/lib/utils.d.ts":"5","/home/fcollonval/projects/jupyter_ydoc/javascript/lib/utils.js":"6","/home/fcollonval/projects/jupyter_ydoc/javascript/lib/ymodels.d.ts":"7","/home/fcollonval/projects/jupyter_ydoc/javascript/lib/ymodels.js":"8","/home/fcollonval/projects/jupyter_ydoc/javascript/src/api.ts":"9","/home/fcollonval/projects/jupyter_ydoc/javascript/src/index.ts":"10","/home/fcollonval/projects/jupyter_ydoc/javascript/src/utils.ts":"11","/home/fcollonval/projects/jupyter_ydoc/javascript/src/ymodels.ts":"12","/home/fcollonval/projects/jupyter_ydoc/javascript/test/ymodels.spec.ts":"13"},{"size":14660,"mtime":1667573006775,"results":"14","hashOfConfig":"15"},{"size":305,"mtime":1667573006791,"results":"16","hashOfConfig":"15"},{"size":133,"mtime":1667570816542,"results":"17","hashOfConfig":"15"},{"size":429,"mtime":1667573006807,"results":"18","hashOfConfig":"15"},{"size":517,"mtime":1667573006815,"results":"19","hashOfConfig":"15"},{"size":1065,"mtime":1667573006823,"results":"20","hashOfConfig":"15"},{"size":17964,"mtime":1667573006935,"results":"21","hashOfConfig":"15"},{"size":39275,"mtime":1667573007083},{"size":14903,"mtime":1667570712700,"results":"22","hashOfConfig":"15"},{"size":396,"mtime":1667570712700,"results":"23","hashOfConfig":"15"},{"size":1180,"mtime":1667570712700,"results":"24","hashOfConfig":"15"},{"size":42408,"mtime":1667570712700,"results":"25","hashOfConfig":"15"},{"size":14256,"mtime":1667573007467,"results":"26","hashOfConfig":"15"},{"filePath":"27","messages":"28","suppressedMessages":"29","errorCount":1,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},"1u2rmju",{"filePath":"30","messages":"31","suppressedMessages":"32","errorCount":1,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"33","messages":"34","suppressedMessages":"35","errorCount":1,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"36","messages":"37","suppressedMessages":"38","errorCount":1,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"39","messages":"40","suppressedMessages":"41","errorCount":1,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"42","messages":"43","suppressedMessages":"44","errorCount":1,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"45","messages":"46","suppressedMessages":"47","errorCount":9,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"48","messages":"49","suppressedMessages":"50","errorCount":1,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"51","messages":"52","suppressedMessages":"53","errorCount":1,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"54","messages":"55","suppressedMessages":"56","errorCount":1,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"57","messages":"58","suppressedMessages":"59","errorCount":18,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"60","messages":"61","suppressedMessages":"62","errorCount":31,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},"/home/fcollonval/projects/jupyter_ydoc/javascript/lib/api.d.ts",["63"],[],"/home/fcollonval/projects/jupyter_ydoc/javascript/lib/api.js",["64"],[],"/home/fcollonval/projects/jupyter_ydoc/javascript/lib/index.d.ts",["65"],[],"/home/fcollonval/projects/jupyter_ydoc/javascript/lib/index.js",["66"],[],"/home/fcollonval/projects/jupyter_ydoc/javascript/lib/utils.d.ts",["67"],[],"/home/fcollonval/projects/jupyter_ydoc/javascript/lib/utils.js",["68"],[],"/home/fcollonval/projects/jupyter_ydoc/javascript/lib/ymodels.d.ts",["69","70","71","72","73","74","75","76","77"],[],"/home/fcollonval/projects/jupyter_ydoc/javascript/src/api.ts",["78"],[],"/home/fcollonval/projects/jupyter_ydoc/javascript/src/index.ts",["79"],[],"/home/fcollonval/projects/jupyter_ydoc/javascript/src/utils.ts",["80"],[],"/home/fcollonval/projects/jupyter_ydoc/javascript/src/ymodels.ts",["81","82","83","84","85","86","87","88","89","90","91","92","93","94","95","96","97","98"],[],"/home/fcollonval/projects/jupyter_ydoc/javascript/test/ymodels.spec.ts",["99","100","101","102","103","104","105","106","107","108","109","110","111","112","113","114","115","116","117","118","119","120","121","122","123","124","125","126","127","128","129"],[],{"ruleId":"130","message":"131","line":1,"column":1,"endLine":1,"endColumn":2,"severity":2,"nodeType":null},{"ruleId":"130","message":"131","line":1,"column":1,"endLine":1,"endColumn":2,"severity":2,"nodeType":null},{"ruleId":"130","message":"131","line":1,"column":1,"endLine":1,"endColumn":2,"severity":2,"nodeType":null},{"ruleId":"130","message":"131","line":1,"column":1,"endLine":1,"endColumn":2,"severity":2,"nodeType":null},{"ruleId":"130","message":"131","line":1,"column":1,"endLine":1,"endColumn":2,"severity":2,"nodeType":null},{"ruleId":"130","message":"131","line":1,"column":1,"endLine":1,"endColumn":2,"severity":2,"nodeType":null},{"ruleId":"130","message":"131","line":1,"column":1,"endLine":1,"endColumn":2,"severity":2,"nodeType":null},{"ruleId":"132","severity":2,"message":"133","line":219,"column":7,"nodeType":"134","messageId":"135","endLine":219,"endColumn":16},{"ruleId":"132","severity":2,"message":"133","line":422,"column":7,"nodeType":"134","messageId":"135","endLine":422,"endColumn":16},{"ruleId":"132","severity":2,"message":"136","line":426,"column":7,"nodeType":"134","messageId":"135","endLine":426,"endColumn":22},{"ruleId":"132","severity":2,"message":"136","line":427,"column":7,"nodeType":"134","messageId":"135","endLine":427,"endColumn":22},{"ruleId":"132","severity":2,"message":"133","line":517,"column":7,"nodeType":"134","messageId":"135","endLine":517,"endColumn":16},{"ruleId":"132","severity":2,"message":"133","line":539,"column":7,"nodeType":"134","messageId":"135","endLine":539,"endColumn":16},{"ruleId":"132","severity":2,"message":"137","line":604,"column":7,"nodeType":"134","messageId":"135","endLine":604,"endColumn":21},{"ruleId":"132","severity":2,"message":"137","line":605,"column":7,"nodeType":"134","messageId":"135","endLine":605,"endColumn":21},{"ruleId":"130","message":"131","line":1,"column":1,"endLine":1,"endColumn":2,"severity":2,"nodeType":null},{"ruleId":"130","message":"131","line":1,"column":1,"endLine":1,"endColumn":2,"severity":2,"nodeType":null},{"ruleId":"130","message":"131","line":1,"column":1,"endLine":1,"endColumn":2,"severity":2,"nodeType":null},{"ruleId":"130","message":"131","line":1,"column":1,"endLine":1,"endColumn":2,"severity":2,"nodeType":null},{"ruleId":"132","severity":2,"message":"136","line":365,"column":13,"nodeType":"134","messageId":"135","endLine":365,"endColumn":28},{"ruleId":"132","severity":2,"message":"133","line":409,"column":29,"nodeType":"134","messageId":"135","endLine":409,"endColumn":38},{"ruleId":"132","severity":2,"message":"133","line":465,"column":7,"nodeType":"134","messageId":"135","endLine":465,"endColumn":16},{"ruleId":"132","severity":2,"message":"138","line":763,"column":11,"nodeType":"134","messageId":"135","endLine":763,"endColumn":25},{"ruleId":"132","severity":2,"message":"138","line":781,"column":32,"nodeType":"134","messageId":"135","endLine":781,"endColumn":46},{"ruleId":"132","severity":2,"message":"133","line":799,"column":7,"nodeType":"134","messageId":"135","endLine":799,"endColumn":16},{"ruleId":"132","severity":2,"message":"133","line":952,"column":7,"nodeType":"134","messageId":"135","endLine":952,"endColumn":16},{"ruleId":"132","severity":2,"message":"136","line":959,"column":7,"nodeType":"134","messageId":"135","endLine":959,"endColumn":22},{"ruleId":"132","severity":2,"message":"136","line":962,"column":7,"nodeType":"134","messageId":"135","endLine":962,"endColumn":22},{"ruleId":"132","severity":2,"message":"136","line":1030,"column":7,"nodeType":"134","messageId":"135","endLine":1030,"endColumn":22},{"ruleId":"132","severity":2,"message":"133","line":1151,"column":7,"nodeType":"134","messageId":"135","endLine":1151,"endColumn":16},{"ruleId":"132","severity":2,"message":"133","line":1161,"column":7,"nodeType":"134","messageId":"135","endLine":1161,"endColumn":16},{"ruleId":"132","severity":2,"message":"133","line":1188,"column":7,"nodeType":"134","messageId":"135","endLine":1188,"endColumn":16},{"ruleId":"132","severity":2,"message":"133","line":1198,"column":7,"nodeType":"134","messageId":"135","endLine":1198,"endColumn":16},{"ruleId":"132","severity":2,"message":"137","line":1303,"column":7,"nodeType":"134","messageId":"135","endLine":1303,"endColumn":21},{"ruleId":"132","severity":2,"message":"137","line":1306,"column":7,"nodeType":"134","messageId":"135","endLine":1306,"endColumn":21},{"ruleId":"132","severity":2,"message":"137","line":1536,"column":7,"nodeType":"134","messageId":"135","endLine":1536,"endColumn":21},{"ruleId":"130","message":"131","line":1,"column":1,"endLine":1,"endColumn":2,"severity":2,"nodeType":null},{"ruleId":"132","severity":2,"message":"139","line":19,"column":11,"nodeType":"134","messageId":"135","endLine":19,"endColumn":24},{"ruleId":"132","severity":2,"message":"140","line":21,"column":13,"nodeType":"134","messageId":"135","endLine":21,"endColumn":25},{"ruleId":"132","severity":2,"message":"139","line":34,"column":11,"nodeType":"134","messageId":"135","endLine":34,"endColumn":24},{"ruleId":"132","severity":2,"message":"140","line":36,"column":13,"nodeType":"134","messageId":"135","endLine":36,"endColumn":25},{"ruleId":"132","severity":2,"message":"139","line":49,"column":11,"nodeType":"134","messageId":"135","endLine":49,"endColumn":24},{"ruleId":"132","severity":2,"message":"140","line":51,"column":13,"nodeType":"134","messageId":"135","endLine":51,"endColumn":25},{"ruleId":"132","severity":2,"message":"139","line":64,"column":11,"nodeType":"134","messageId":"135","endLine":64,"endColumn":24},{"ruleId":"132","severity":2,"message":"140","line":66,"column":13,"nodeType":"134","messageId":"135","endLine":66,"endColumn":25},{"ruleId":"132","severity":2,"message":"139","line":82,"column":13,"nodeType":"134","messageId":"135","endLine":82,"endColumn":26},{"ruleId":"132","severity":2,"message":"140","line":84,"column":15,"nodeType":"134","messageId":"135","endLine":84,"endColumn":27},{"ruleId":"132","severity":2,"message":"139","line":100,"column":18,"nodeType":"134","messageId":"135","endLine":100,"endColumn":31},{"ruleId":"132","severity":2,"message":"140","line":102,"column":11,"nodeType":"134","messageId":"135","endLine":102,"endColumn":23},{"ruleId":"132","severity":2,"message":"139","line":112,"column":11,"nodeType":"134","messageId":"135","endLine":112,"endColumn":24},{"ruleId":"132","severity":2,"message":"139","line":124,"column":11,"nodeType":"134","messageId":"135","endLine":124,"endColumn":24},{"ruleId":"132","severity":2,"message":"140","line":126,"column":13,"nodeType":"134","messageId":"135","endLine":126,"endColumn":25},{"ruleId":"132","severity":2,"message":"139","line":159,"column":11,"nodeType":"134","messageId":"135","endLine":159,"endColumn":24},{"ruleId":"132","severity":2,"message":"140","line":161,"column":13,"nodeType":"134","messageId":"135","endLine":161,"endColumn":25},{"ruleId":"132","severity":2,"message":"139","line":184,"column":11,"nodeType":"134","messageId":"135","endLine":184,"endColumn":24},{"ruleId":"132","severity":2,"message":"140","line":186,"column":13,"nodeType":"134","messageId":"135","endLine":186,"endColumn":25},{"ruleId":"132","severity":2,"message":"139","line":216,"column":11,"nodeType":"134","messageId":"135","endLine":216,"endColumn":24},{"ruleId":"132","severity":2,"message":"140","line":218,"column":13,"nodeType":"134","messageId":"135","endLine":218,"endColumn":25},{"ruleId":"132","severity":2,"message":"133","line":249,"column":34,"nodeType":"134","messageId":"135","endLine":249,"endColumn":43},{"ruleId":"132","severity":2,"message":"133","line":254,"column":51,"nodeType":"134","messageId":"135","endLine":254,"endColumn":60},{"ruleId":"132","severity":2,"message":"133","line":260,"column":51,"nodeType":"134","messageId":"135","endLine":260,"endColumn":60},{"ruleId":"132","severity":2,"message":"133","line":272,"column":51,"nodeType":"134","messageId":"135","endLine":272,"endColumn":60},{"ruleId":"132","severity":2,"message":"133","line":287,"column":51,"nodeType":"134","messageId":"135","endLine":287,"endColumn":60},{"ruleId":"132","severity":2,"message":"133","line":304,"column":45,"nodeType":"134","messageId":"135","endLine":304,"endColumn":54},{"ruleId":"132","severity":2,"message":"133","line":305,"column":28,"nodeType":"134","messageId":"135","endLine":305,"endColumn":37},{"ruleId":"132","severity":2,"message":"138","line":352,"column":20,"nodeType":"134","messageId":"135","endLine":352,"endColumn":34},{"ruleId":"132","severity":2,"message":"138","line":359,"column":20,"nodeType":"134","messageId":"135","endLine":359,"endColumn":34},"react/prop-types","Definition for rule 'react/prop-types' was not found.","camelcase","Identifier 'cell_type' is not in camel case.","Identifier","notCamelCase","Identifier 'execution_count' is not in camel case.","Identifier 'nbformat_minor' is not in camel case.","Identifier 'outputs_hidden' is not in camel case.","Identifier 'orig_nbformat' is not in camel case.","Identifier 'display_name' is not in camel case."]

javascript/.eslintrc.cjs

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
module.exports = {
2+
env: {
3+
browser: true,
4+
es6: true,
5+
commonjs: true,
6+
node: true,
7+
'jest/globals': true
8+
},
9+
globals: {
10+
BigInt: 'readonly',
11+
HTMLCollectionOf: 'readonly',
12+
NodeJS: 'readonly',
13+
RequestInit: 'readonly',
14+
RequestInfo: 'readonly',
15+
ScrollLogicalPosition: 'readonly'
16+
},
17+
root: true,
18+
extends: [
19+
'eslint:recommended',
20+
'plugin:@typescript-eslint/eslint-recommended',
21+
'plugin:@typescript-eslint/recommended',
22+
'prettier'
23+
],
24+
parser: '@typescript-eslint/parser',
25+
plugins: ['@typescript-eslint'],
26+
overrides: [
27+
{
28+
files: ['test/**/*.spec.ts'],
29+
plugins: ['jest'],
30+
extends: ['plugin:jest/recommended'],
31+
rules: {
32+
'jest/no-conditional-expect': 'warn',
33+
'jest/valid-title': 'warn',
34+
'jest/no-standalone-expect': [
35+
'error',
36+
{
37+
additionalTestBlockFunctions: ['it']
38+
}
39+
]
40+
}
41+
}
42+
],
43+
rules: {
44+
'@typescript-eslint/naming-convention': [
45+
'error',
46+
{
47+
selector: 'interface',
48+
format: ['PascalCase'],
49+
custom: {
50+
regex: '^I[A-Z]',
51+
match: true
52+
}
53+
}
54+
],
55+
'@typescript-eslint/no-unused-vars': ['warn', { args: 'none' }],
56+
'@typescript-eslint/no-use-before-define': 'off',
57+
'@typescript-eslint/no-explicit-any': 'off',
58+
'@typescript-eslint/no-non-null-assertion': 'off',
59+
'@typescript-eslint/no-namespace': 'off',
60+
'@typescript-eslint/interface-name-prefix': 'off',
61+
'@typescript-eslint/explicit-function-return-type': 'off',
62+
'@typescript-eslint/ban-ts-comment': ['warn', { 'ts-ignore': true }],
63+
'@typescript-eslint/ban-types': 'warn',
64+
'@typescript-eslint/no-non-null-asserted-optional-chain': 'warn',
65+
'@typescript-eslint/no-var-requires': 'off',
66+
'@typescript-eslint/no-empty-interface': 'off',
67+
'@typescript-eslint/triple-slash-reference': 'warn',
68+
'@typescript-eslint/no-inferrable-types': 'off',
69+
camelcase: [
70+
'error',
71+
{
72+
allow: [
73+
'cell_type',
74+
'display_name',
75+
'orig_nbformat',
76+
'outputs_hidden'
77+
]
78+
}
79+
],
80+
'id-match': ['error', '^[a-zA-Z_]+[a-zA-Z0-9_]*$'], // https://certitude.consulting/blog/en/invisible-backdoor/
81+
'no-inner-declarations': 'off',
82+
'no-prototype-builtins': 'off',
83+
'no-control-regex': 'warn',
84+
'no-undef': 'warn',
85+
'no-case-declarations': 'warn',
86+
'no-useless-escape': 'off',
87+
'prefer-const': 'off',
88+
'sort-imports': [
89+
'error',
90+
{
91+
ignoreCase: true,
92+
ignoreDeclarationSort: true,
93+
ignoreMemberSort: false,
94+
memberSyntaxSortOrder: ['none', 'all', 'multiple', 'single'],
95+
allowSeparatedGroups: false
96+
}
97+
]
98+
}
99+
};

javascript/.prettierrc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"singleQuote": true,
3+
"trailingComma": "none",
4+
"arrowParens": "avoid"
5+
}

javascript/.vscode/launch.json

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
{
2-
"version": "0.2.0",
3-
"configurations": [
4-
{
5-
"type": "node",
6-
"request": "attach",
7-
"name": "Attach to jest",
8-
// Usage:
9-
// Open the parent directory in VSCode
10-
// Run `jlpm test:debug:watch` in a terminal
11-
// Run this debugging task
12-
"port": 9229
13-
}
14-
]
2+
"version": "0.2.0",
3+
"configurations": [
4+
{
5+
"type": "node",
6+
"request": "attach",
7+
"name": "Attach to jest",
8+
// Usage:
9+
// Open the parent directory in VSCode
10+
// Run `jlpm test:debug:watch` in a terminal
11+
// Run this debugging task
12+
"port": 9229
13+
}
14+
]
1515
}

javascript/babel.config.js renamed to javascript/babel.config.cjs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
module.exports = {
77
presets: [
88
[
9-
"@babel/preset-env",
9+
'@babel/preset-env',
1010
{
1111
targets: {
12-
node: "current",
13-
},
14-
},
15-
],
16-
],
12+
node: 'current'
13+
}
14+
}
15+
]
16+
]
1717
};

javascript/jest.config.cjs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* Copyright (c) Jupyter Development Team.
3+
* Distributed under the terms of the Modified BSD License.
4+
*/
5+
6+
const path = require('path');
7+
const esModules = ['lib0', 'y-protocols', 'y-websocket', 'yjs'].join('|');
8+
9+
module.exports = {
10+
preset: 'ts-jest/presets/js-with-babel',
11+
testTimeout: 10000,
12+
testPathIgnorePatterns: ['/lib/', '/node_modules/'],
13+
moduleFileExtensions: [
14+
'ts',
15+
'tsx',
16+
'js',
17+
'jsx',
18+
'json',
19+
'node',
20+
'mjs',
21+
'cjs'
22+
],
23+
transformIgnorePatterns: [`/node_modules/(?!${esModules}).+`],
24+
reporters: ['default'],
25+
coverageReporters: ['json', 'lcov', 'text', 'html'],
26+
coverageDirectory: path.join(__dirname, 'coverage'),
27+
testRegex: '/test/.*.spec.ts[x]?$',
28+
globals: {
29+
'ts-jest': {
30+
tsconfig: `./tsconfig.test.json`
31+
}
32+
}
33+
};

javascript/jest.config.js

Lines changed: 0 additions & 39 deletions
This file was deleted.

0 commit comments

Comments
 (0)