diff --git a/.eslintrc.json b/.eslintrc.json index 767391c1..fe37f35a 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -9,10 +9,6 @@ "ecmaVersion": "latest" }, "rules": { - "arrow-parens": ["error", "always"], - "comma-dangle": "off", - "handle-callback-err": "off", - "consistent-return": "off", - "new-cap": "off" + "consistent-return": "off" } } diff --git a/.prettierrc b/.prettierrc index 74d3eb4a..32f77d65 100644 --- a/.prettierrc +++ b/.prettierrc @@ -1,6 +1,6 @@ { "singleQuote": true, - "trailingComma": "es5", + "trailingComma": "all", "overrides": [ { "files": ".prettierrc", diff --git a/lib/types.js b/lib/types.js index fe518b39..27d2584b 100644 --- a/lib/types.js +++ b/lib/types.js @@ -55,13 +55,13 @@ const updateTypeMetadata = (Type, metadata = {}) => { const checkCustomType = (proto) => { if (!proto) { throw new Error( - 'Custom type must be an object with methods "construct" and "checkType"' + 'Custom type must be an object with methods "construct" and "checkType"', ); } const { checkType, construct } = proto; if (!checkType || !construct) { throw new Error( - 'Custom type must contain "construct" and "checkType" methods' + 'Custom type must contain "construct" and "checkType" methods', ); } if (typeof checkType !== 'function' || typeof construct !== 'function') { diff --git a/metaschema.d.ts b/metaschema.d.ts index 002041d7..f1c79cc7 100644 --- a/metaschema.d.ts +++ b/metaschema.d.ts @@ -77,7 +77,7 @@ export function loadSchema(fileName: string): Promise; export function readDirectory(dirPath: string): Promise>; export function loadModel( modelPath: string, - systemTypes: object + systemTypes: object, ): Promise; export function saveTypes(outputFile: string, model: Model): Promise; diff --git a/test/collections.js b/test/collections.js index 39b82b82..44f2980b 100644 --- a/test/collections.js +++ b/test/collections.js @@ -343,11 +343,11 @@ metatests.test('Collections: nested object', (test) => { test.strictSame(sch2.check({}).valid, false); test.strictSame( sch3.check({ key: [{ key: { key: { name: 'Georg' } } }] }).valid, - true + true, ); test.strictSame( sch3.check({ key: [{ key: { name: 'Georg' } }] }).valid, - false + false, ); test.strictSame(sch4.check({}).valid, true); test.strictSame(sch4.fields.required, false); diff --git a/test/model.js b/test/model.js index 441da63c..c437ecca 100644 --- a/test/model.js +++ b/test/model.js @@ -64,7 +64,7 @@ metatests.test('Model: from struct', (test) => { const warn = model.warnings[0]; test.strictEqual( warn, - 'Warning: "Address" referenced by "Company" is not found' + 'Warning: "Address" referenced by "Company" is not found', ); test.end(); @@ -118,7 +118,7 @@ metatests.test( const identifier = model.entities.get('Identifier'); test.strictEqual( identifier.check({ creation: Date.now().toLocaleString() }).valid, - true + true, ); const tester = model.entities.get('Tester'); test.strictEqual( @@ -132,7 +132,7 @@ metatests.test( ], }, }).valid, - true + true, ); test.strictEqual( tester.check({ @@ -141,8 +141,8 @@ metatests.test( count: 2, }, }).valid, - false + false, ); test.end(); - } + }, ); diff --git a/test/schema.js b/test/schema.js index 87aa9a37..78eff638 100644 --- a/test/schema.js +++ b/test/schema.js @@ -127,21 +127,21 @@ metatests.test('Schema: validation function', (test) => { schema.check({ field: 'abc', }).valid, - true + true, ); test.strictSame( schema.check({ field2: 'abc', }).errors, - ['Field "" .field is required', 'Field "field2" is not expected'] + ['Field "" .field is required', 'Field "field2" is not expected'], ); test.strictSame( schema.check({ throw: '42', }).errors, - ['Field "" validation failed Error: 42', 'Field "throw" is not expected'] + ['Field "" validation failed Error: 42', 'Field "throw" is not expected'], ); test.end(); @@ -183,14 +183,14 @@ metatests.test('Schema: nested validation function', (test) => { schema.check({ field: 'abc', }).valid, - true + true, ); test.strictSame( schema.check({ field2: 'abc', }).errors, - ['Field "field" is required', 'Field "field2" is not expected'] + ['Field "field" is required', 'Field "field2" is not expected'], ); test.strictSame( @@ -200,7 +200,7 @@ metatests.test('Schema: nested validation function', (test) => { field: 'abc', }, }).valid, - true + true, ); test.strictSame( @@ -213,7 +213,7 @@ metatests.test('Schema: nested validation function', (test) => { [ 'Field "field2" is not expected', 'Field "nested" nested.field is required', - ] + ], ); test.strictSame( @@ -226,7 +226,7 @@ metatests.test('Schema: nested validation function', (test) => { [ 'Field "throw" is not expected', 'Field "nested" validation failed Error: 42', - ] + ], ); test.end(); }); @@ -278,16 +278,16 @@ metatests.test( type: 'myType', note: 'this is not vorbidden anymore', }).valid, - true + true, ); test.strictSame( schema.check({ note: 'this is not vorbidden anymore', }).valid, - false + false, ); test.end(); - } + }, ); metatests.test('Schema: custom validate on field', (test) => { @@ -317,7 +317,7 @@ metatests.test('Schema: custom validate on field', (test) => { test.strictEqual(schema1.check({ email: 'asd@asd.com' }).valid, true); test.strictEqual( schema1.check({ email: 'asdasdasdasdasdasd@asd.com' }).errors, - ['Field "email" exceeds the maximum length'] + ['Field "email" exceeds the maximum length'], ); const defs2 = { type: 'number', diff --git a/test/structs.js b/test/structs.js index d9263c57..6d3692e4 100644 --- a/test/structs.js +++ b/test/structs.js @@ -145,7 +145,7 @@ metatests.test('Structs: multiple optional nested struct', (test) => { nfield1: { text: 'abc' }, }, }).valid, - true + true, ); test.strictSame( @@ -156,7 +156,7 @@ metatests.test('Structs: multiple optional nested struct', (test) => { nfield2: { text: 'aaa' }, }, }).valid, - true + true, ); test.strictSame( @@ -167,7 +167,7 @@ metatests.test('Structs: multiple optional nested struct', (test) => { nfield2: { text: 'aaa', caption: 'caption' }, }, }).valid, - true + true, ); test.strictSame( @@ -181,7 +181,7 @@ metatests.test('Structs: multiple optional nested struct', (test) => { [ `Field "data.nfield1.text" is required`, `Field "data.nfield2.caption" not of expected type: string`, - ] + ], ); test.end(); }); diff --git a/test/tuple.js b/test/tuple.js index bb51fc82..49339d34 100644 --- a/test/tuple.js +++ b/test/tuple.js @@ -31,7 +31,7 @@ metatests.test('Tuple: basic implementation', (test) => { ]); test.strictEqual( schema2.check([BigInt(9007199254740991), false, 123]).errors, - ['Field "" value length is more then expected in tuple'] + ['Field "" value length is more then expected in tuple'], ); const long = { type: 'tuple', value: ['string'] }; @@ -75,7 +75,7 @@ metatests.test('Tuple: usage with schema', (test) => { test.strictEqual(schema.check({ field: [true, 123] }).valid, true); test.strictEqual( schema.check({ field: [false, { some: 'wrong data' }] }).errors, - ['Field "field(count1)" not of expected type: number'] + ['Field "field(count1)" not of expected type: number'], ); test.end(); });