Skip to content

Commit

Permalink
chore: update deps (#112)
Browse files Browse the repository at this point in the history
  • Loading branch information
P0lip authored Aug 2, 2022
1 parent 7f169fc commit acca1b7
Show file tree
Hide file tree
Showing 24 changed files with 2,580 additions and 1,597 deletions.
6 changes: 6 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
extends: ['@stoplight'],
rules: {
'no-param-reassign': 'warn',
},
};
3 changes: 3 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
...require('@stoplight/eslint-config/prettier.config'),
};
2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = {
preset: '@stoplight/scripts',
testEnvironment: 'node'
testEnvironment: 'node',
};
23 changes: 16 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"scripts": {
"build": "sl-scripts build",
"commit": "git-cz",
"lint": "tslint -c tslint.json 'src/**/*.ts'",
"lint": "eslint --ext .js,.jsx,.ts,.tsx .",
"lint.fix": "yarn lint --fix",
"release": "sl-scripts release",
"release.dryRun": "sl-scripts release --dry-run --debug",
Expand All @@ -45,16 +45,25 @@
"safe-stable-stringify": "^1.1"
},
"devDependencies": {
"@stoplight/eslint-config": "^3.0.0",
"@stoplight/scripts": "^7.0.4",
"@types/jest": "^24.0.21",
"@types/jest": "^28.1.6",
"@types/lodash": "^4.14.144",
"@types/node": "^12.12.5",
"@typescript-eslint/eslint-plugin": "^5.32.0",
"@typescript-eslint/parser": "^5.32.0",
"benchmark": "^2.1.4",
"jest": "^24.9.0",
"ts-jest": "^24.1.0",
"tslint": "^5.20.0",
"tslint-config-stoplight": "~1.3.0",
"typescript": "3.6.4"
"eslint": "^8.21.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-jest": "^26.7.0",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-react": "^7.30.1",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-simple-import-sort": "^7.0.0",
"jest": "^28.1.3",
"prettier": "^2.3.1",
"ts-jest": "^28.0.7",
"typescript": "^4.7.4"
},
"lint-staged": {
"*.{ts,tsx}$": [
Expand Down
9 changes: 5 additions & 4 deletions src/__tests__/getJsonPathForPosition.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as fs from 'fs';
import { join } from 'path';

import { getJsonPathForPosition } from '../getJsonPathForPosition';
import { parseWithPointers } from '../parseWithPointers';

Expand All @@ -11,7 +12,7 @@ describe('getJsonPathForPosition', () => {
describe('simple fixture', () => {
const result = parseWithPointers(simple);

test.each`
it.each`
line | character | path
${0} | ${0} | ${void 0}
${1} | ${4} | ${['hello']}
Expand All @@ -26,7 +27,7 @@ describe('getJsonPathForPosition', () => {
describe('users fixture', () => {
const result = parseWithPointers(users);

test.each`
it.each`
line | character | path
${0} | ${0} | ${void 0}
${0} | ${231} | ${void 0}
Expand All @@ -44,7 +45,7 @@ describe('getJsonPathForPosition', () => {
describe('one-liner', () => {
const result = parseWithPointers(`{ "foo": true, "bar": false }`);

test.each`
it.each`
line | character | path
${0} | ${3} | ${['foo']}
${0} | ${12} | ${['foo']}
Expand All @@ -57,7 +58,7 @@ describe('getJsonPathForPosition', () => {
describe('multiline comments', () => {
const result = parseWithPointers(multilineComments);

test.each`
it.each`
line | character | path
${1} | ${4} | ${['hello']}
${7} | ${5} | ${['address', 'street']}
Expand Down
15 changes: 8 additions & 7 deletions src/__tests__/getLocationForJsonPath.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as fs from 'fs';
import { join } from 'path';

import { getLocationForJsonPath } from '../getLocationForJsonPath';
import { parseWithPointers } from '../parseWithPointers';

Expand All @@ -13,7 +14,7 @@ describe('getLocationForJsonPath', () => {
describe('pet store fixture', () => {
const result = parseWithPointers(petStore);

test.each`
it.each`
start | end | path | closest
${[8, 21]} | ${[8, 41]} | ${['info', 'contact', 'email']} | ${false}
${[8, 21]} | ${[8, 41]} | ${['info', 'contact', 'email']} | ${true}
Expand Down Expand Up @@ -53,7 +54,7 @@ describe('getLocationForJsonPath', () => {
describe('simple fixture', () => {
const result = parseWithPointers(simple);

test.each`
it.each`
start | end | path
${[2, 13]} | ${[4, 3]} | ${['address']}
${[3, 14]} | ${[3, 17]} | ${['address', 'street']}
Expand All @@ -78,7 +79,7 @@ describe('getLocationForJsonPath', () => {
describe('users fixture', () => {
const result = parseWithPointers(users);

test.each`
it.each`
start | end | path
${[3, 14]} | ${[3, 19]} | ${['users', 0, 'name']}
${[3, 14]} | ${[3, 19]} | ${['users', '0', 'name']}
Expand All @@ -103,7 +104,7 @@ describe('getLocationForJsonPath', () => {
describe('one-liner', () => {
const result = parseWithPointers(`{ "foo": true, "bar": false }`);

test.each`
it.each`
start | end | path
${[0, 9]} | ${[0, 13]} | ${['foo']}
${[0, 22]} | ${[0, 27]} | ${['bar']}
Expand All @@ -126,7 +127,7 @@ describe('getLocationForJsonPath', () => {
describe('multiline comments', () => {
const result = parseWithPointers(multilineComments);

test.each`
it.each`
start | end | path
${[1, 11]} | ${[1, 18]} | ${['hello']}
${[7, 14]} | ${[7, 17]} | ${['address', 'street']}
Expand All @@ -151,7 +152,7 @@ describe('getLocationForJsonPath', () => {
describe('todos', () => {
const result = parseWithPointers(todos);

test.each`
it.each`
start | end | path | closest
${[42, 13]} | ${[73, 7]} | ${['paths', '/todos/{todoId}', 'get']} | ${false}
${[42, 13]} | ${[73, 7]} | ${['paths', '/todos/{todoId}', 'get', 'description']} | ${true}
Expand Down Expand Up @@ -189,7 +190,7 @@ describe('getLocationForJsonPath', () => {
}
}`);

test.each`
it.each`
start | end | path | closest
${[2, 10]} | ${[4, 4]} | ${['foo', 'bar', 'baz', 'baz-inga']} | ${true}
${[]} | ${[]} | ${['foo', 'bar', 'baz', 'baz-inga']} | ${false}
Expand Down
4 changes: 2 additions & 2 deletions src/__tests__/hasRef.spec.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { hasRef } from '../hasRef';

describe('hasRef', () => {
test('should return true for object containing property with $ref key and string value', () => {
it('should return true for object containing property with $ref key and string value', () => {
expect(hasRef({ $ref: '' })).toBe(true);
});

test('should return false for object not containing property with $ref key and string value', () => {
it('should return false for object not containing property with $ref key and string value', () => {
expect(hasRef({ $ref: null })).toBe(false);
expect(hasRef({})).toBe(false);
expect(hasRef({ x: true })).toBe(false);
Expand Down
6 changes: 3 additions & 3 deletions src/__tests__/isPlainObject.spec.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { isPlainObject } from '../isPlainObject';

it('isPlainObject', () => {
expect(isPlainObject(new class Foo {}())).toBe(false);
test('isPlainObject', () => {
expect(isPlainObject(new (class Foo {})())).toBe(false);
expect(isPlainObject([1, 2, 3])).toBe(false);

expect(isPlainObject({ x: 0, y: 0 })).toBe(true);
expect(isPlainObject(Object.create(null))).toBe(true);

const a = new class {}();
const a = new (class {})();
a.constructor = Object;
expect(isPlainObject(a)).toBe(true);
});
32 changes: 17 additions & 15 deletions src/__tests__/parseWithPointers.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
import { DiagnosticSeverity } from '@stoplight/types';
import * as fs from 'fs';
import { join } from 'path';

import { parseWithPointers } from '../parseWithPointers';

const simple = fs.readFileSync(join(__dirname, './fixtures/simple.json'), 'utf-8');

describe('json parser', () => {
test('parse simple', () => {
it('parse simple', () => {
expect(parseWithPointers(simple)).toMatchSnapshot({
ast: expect.any(Object),
lineMap: expect.any(Array),
});
});

test('parse complex', () => {
it('parse complex', () => {
expect(
parseWithPointers(`{
"users": [
Expand All @@ -40,7 +41,7 @@ describe('json parser', () => {
});
});

test('does not allow comments by default', () => {
it('does not allow comments by default', () => {
expect(
parseWithPointers(`{
// a comment
Expand Down Expand Up @@ -72,7 +73,7 @@ describe('json parser', () => {
]);
});

test('does not allow trailing commas by default', () => {
it('does not allow trailing commas by default', () => {
expect(
parseWithPointers(`{
"name": "Antti",
Expand Down Expand Up @@ -105,7 +106,7 @@ describe('json parser', () => {
});

describe('fixtures', () => {
test.each(['petstore.oas2.json', 'user.jschema.json'])('parses %s', async filename => {
it.each(['petstore.oas2.json', 'user.jschema.json'])('parses %s', async filename => {
expect(
parseWithPointers((await fs.promises.readFile(join(__dirname, 'fixtures', filename), 'utf-8')) as string),
).toMatchSnapshot({
Expand All @@ -116,12 +117,11 @@ describe('json parser', () => {
});

describe('invalid fixtures', () => {
test.each(['schema.json', 'characters.json'])('parses %s', async filename => {
it.each(['schema.json', 'characters.json'])('parses %s', async filename => {
expect(
parseWithPointers((await fs.promises.readFile(
join(__dirname, 'fixtures/invalid', filename),
'utf-8',
)) as string),
parseWithPointers(
(await fs.promises.readFile(join(__dirname, 'fixtures/invalid', filename), 'utf-8')) as string,
),
).toMatchSnapshot({
ast: expect.any(Object),
lineMap: expect.any(Array),
Expand All @@ -130,7 +130,7 @@ describe('json parser', () => {
});

describe('duplicate keys', () => {
test('given object with no duplicate keys, does not report any errors', () => {
it('given object with no duplicate keys, does not report any errors', () => {
expect(
parseWithPointers(
`{
Expand Down Expand Up @@ -181,7 +181,7 @@ describe('json parser', () => {
).toEqual([]);
});

test('given object containing with duplicate keys, reports them', () => {
it('given object containing with duplicate keys, reports them', () => {
expect(
parseWithPointers(
`{
Expand Down Expand Up @@ -278,7 +278,7 @@ describe('json parser', () => {
]);
});

test('generates correct paths for dupes in arrays', () => {
it('generates correct paths for dupes in arrays', () => {
expect(
parseWithPointers('{ "A": [{}, { "foo": true, "foo": false,\n "foo": 2 }] }', { ignoreDuplicateKeys: false }),
).toHaveProperty('diagnostics', [
Expand Down Expand Up @@ -313,7 +313,7 @@ describe('json parser', () => {
});
});

test('includes properties with empty string as keys', () => {
it('includes properties with empty string as keys', () => {
expect(parseWithPointers('{ "": [{ "foo": true, "": false }] }')).toHaveProperty('data', {
'': [{ '': false, foo: true }],
});
Expand Down Expand Up @@ -372,7 +372,9 @@ describe('json parser', () => {
});

it('does not touch arrays', () => {
const { data } = parseWithPointers(`[0, 1, 2]`, { preserveKeyOrder: true });
const { data } = parseWithPointers(`[0, 1, 2]`, {
preserveKeyOrder: true,
});

expect(Object.keys(data)).toEqual(['0', '1', '2']);
expect(Object.getOwnPropertySymbols(data)).toEqual([]);
Expand Down
13 changes: 7 additions & 6 deletions src/__tests__/reparentBundleTarget.spec.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { reparentBundleTarget } from '../reparentBundleTarget';

describe('reparentBundleTarget', () => {
it.each<[string, string]>([['#', '#/components'], ['#/components', '#'], ['#/components/schemas', '#/components']])(
'given %p paths, should throw',
(from, to) => {
expect(reparentBundleTarget.bind(null, {}, from, to)).toThrow();
},
);
it.each<[string, string]>([
['#', '#/components'],
['#/components', '#'],
['#/components/schemas', '#/components'],
])('given %p paths, should throw', (from, to) => {
expect(reparentBundleTarget.bind(null, {}, from, to)).toThrow();
});

it('should reparent refs', () => {
const document = {
Expand Down
Loading

0 comments on commit acca1b7

Please sign in to comment.