add spellchecker

This commit is contained in:
vbasiuk
2024-09-09 22:43:59 +03:00
parent 3c97184fce
commit e4fd7990b0
7 changed files with 1465 additions and 1288 deletions

View File

@@ -1,3 +0,0 @@
{
"extends": ["@iden3/eslint-config"]
}

31
.eslintrc.js Normal file
View File

@@ -0,0 +1,31 @@
const iden3Config = require('@iden3/eslint-config');
const { spellcheckerRule, cspellConfig } = require('@iden3/eslint-config/cspell');
module.exports = {
...iden3Config,
rules: {
'@cspell/spellchecker': [
1,
{
...spellcheckerRule,
cspell: {
...cspellConfig,
ignoreWords: [
'idid',
'subdelim',
'genesistest',
'dupl',
'supa',
'Unmarshal',
'genesistes',
'changedgenesis',
'serv',
'pchar',
'idstring',
'idchar'
]
}
}
]
}
};

2687
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -30,7 +30,7 @@
"deps:check": "madge --warning --circular --extensions ts ./",
"test": "jest",
"test:watch": "jest --watch",
"lint": "eslint --fix --ext .ts src/** tests/**",
"lint": "eslint --fix --fix --ext .ts src/** tests/**",
"lint:check": "eslint --ext .ts src/** tests/**",
"format": "prettier --config .prettierrc './**/*.ts' --write",
"format:check": "prettier --config .prettierrc './**/*.ts' --check"
@@ -63,7 +63,9 @@
"@rollup/plugin-terser": "^0.4.3",
"@rollup/plugin-typescript": "^11.1.4",
"@types/jest": "^29.2.0",
"@typescript-eslint/eslint-plugin": "^5.41.0",
"@typescript-eslint/eslint-plugin": "^5.0.0",
"eslint-plugin-prettier": "^4.2.1",
"@cspell/eslint-plugin": "^8.14.2",
"jest": "^29.2.2",
"madge": "^6.1.0",
"prettier": "^2.7.1",

View File

@@ -135,7 +135,7 @@ export class Parser {
// from the grammar:
// idstring = 1*idchar
// return error because idstring is empty, ex- did:a::123:456
throw new Error(`idstring must be atleast one char long, ${currentIndex}`);
throw new Error(`idstring must be at least one char long, ${currentIndex}`);
}
// set parser state
@@ -298,7 +298,7 @@ export class Parser {
percentEncoded = true;
indexIncrement = 3;
} else {
// not pecent encoded
// not percent encoded
percentEncoded = false;
indexIncrement = 1;
}
@@ -313,7 +313,7 @@ export class Parser {
}
if (currentIndex == startIndex && this.out.pathSegments.length === 0) {
throw new Error(`first path segment must have atleast one character, ${currentIndex}`);
throw new Error(`first path segment must have at least one character, ${currentIndex}`);
}
// update parser state
@@ -359,7 +359,7 @@ export class Parser {
percentEncoded = true;
indexIncrement = 3;
} else {
// not pecent encoded
// not percent encoded
percentEncoded = false;
indexIncrement = 1;
}
@@ -407,7 +407,7 @@ export class Parser {
percentEncoded = true;
indexIncrement = 3;
} else {
// not pecent encoded
// not percent encoded
percentEncoded = false;
indexIncrement = 1;
}

View File

@@ -412,7 +412,7 @@ describe('claim test', () => {
describe('merklization', () => {
const tests = [
{
name: 'not merklizedd',
name: 'not merklized',
claim: () => Claim.newClaim(new SchemaHash()),
expectedPosition: MerklizedRootPosition.None
},

View File

@@ -22,7 +22,7 @@ describe('DID parser', () => {
expect(true).toBe(d.isUrl());
});
it('returns true if PathSegements', () => {
it('returns true if PathSegments', () => {
const d = new DID({ method: 'example', id: '123', pathSegments: ['a', 'b'] });
expect(true).toBe(d.isUrl());
});
@@ -123,7 +123,7 @@ describe('DID parser', () => {
expect('did:example:123/a/b').toBe(d.string());
});
it('includes Path assembled from PathSegements', () => {
it('includes Path assembled from PathSegments', () => {
const d = new DID({ method: 'example', id: '123', pathSegments: ['a', 'b'] });
expect('did:example:123/a/b').toBe(d.string());
});
@@ -201,7 +201,7 @@ describe('DID parser', () => {
expect(() => DID.parse('did:a:')).toThrow();
});
it('returns error if input does not have a seconconst d to mark end of method', () => {
it('returns error if input does not have a second const d to mark end of method', () => {
expect(() => DID.parse('did:aaaaaaaaaaa')).toThrow();
});
@@ -209,7 +209,7 @@ describe('DID parser', () => {
expect(() => DID.parse('did::aaaaaaaaaaa')).toThrow();
});
it('returns error if idstring is empty', () => {
it('returns error if id string is empty', () => {
const dids = [
'did:a::123:456',
'did:a:123::456',
@@ -416,7 +416,7 @@ describe('DID parser', () => {
expect('someService').toBe(d.path);
});
it('succeeds to extract path segements', () => {
it('succeeds to extract path segments', () => {
const d = DID.parse('did:a:123:456/a/b');
const segments = d.pathSegments;
@@ -459,11 +459,11 @@ describe('DID parser', () => {
expect(() => DID.parse('did:a:123:456/ssss^sss')).toThrow();
});
it('does not fail if path has atleast one segment and a trailing slash', () => {
it('does not fail if path has at least one segment and a trailing slash', () => {
expect(() => DID.parse('did:a:123:456/a/b/')).not.toThrow();
});
it('succeeds to extract query after idstring', () => {
it('succeeds to extract query after id string', () => {
const d = DID.parse('did:a:123?abc');
expect('a').toBe(d.method);
expect('123').toBe(d.id);