Skip to content

Commit 170b977

Browse files
committed
chore(cleanup): code cleanup and eslint ignore
1 parent 0d21ad2 commit 170b977

File tree

5 files changed

+71
-74
lines changed

5 files changed

+71
-74
lines changed

eslint.config.mjs

Lines changed: 57 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import prettierExtends from "eslint-config-prettier";
55
import { fixupPluginRules } from "@eslint/compat";
66
import globals from "globals";
77
import tseslint from "typescript-eslint";
8+
import promisePlugin from "eslint-plugin-promise";
89

910
const globalToUse = {
1011
...globals.browser,
@@ -14,64 +15,64 @@ const globalToUse = {
1415
...globals.node,
1516
};
1617

17-
export default tseslint.config({
18-
extends: [
19-
{
20-
ignores: [
21-
"client/cypress/plugins/index.js",
22-
".lintstagedrc.js",
23-
".next/**/*",
24-
"public/js/*",
25-
".yarn/js/*",
26-
"ui/out/**/*",
27-
"apps/expo/ios/**/*",
28-
"apps/expo/android/**/*",
29-
"electron/build/**/*",
30-
"public/*.js",
31-
"public/*.map",
18+
const ignores = [
19+
".lintstagedrc.js",
20+
"**/.yarn/**/*",
21+
"**/dist/**/*",
22+
"public/js/*",
23+
".yarn/js/*",
24+
"dist/**/*",
25+
"coverage/**/*",
26+
];
27+
/** @type {import('@typescript-eslint/utils').FlatConfig.ConfigArray} */
28+
const configs = tseslint.config(
29+
{
30+
ignores,
31+
32+
extends: [
33+
eslint.configs.recommended,
34+
...tseslint.configs.recommended,
35+
promisePlugin.configs["flat/recommended"],
36+
prettierExtends,
37+
],
38+
plugins: {
39+
promise: promisePlugin,
40+
prettierPlugin,
41+
"unused-imports": fixupPluginRules(unusedImportsPlugin),
42+
},
43+
rules: {
44+
"prefer-rest-params": "off",
45+
"prefer-const": "error",
46+
"prefer-spread": "off",
47+
"no-case-declarations": "off",
48+
curly: ["error", "all"],
49+
"@typescript-eslint/no-non-null-assertion": "off",
50+
"@typescript-eslint/consistent-type-definitions": ["error", "interface"],
51+
"@typescript-eslint/consistent-type-imports": [
52+
"error",
53+
{
54+
prefer: "type-imports",
55+
},
3256
],
57+
"@typescript-eslint/ban-ts-comment": "off",
58+
"@typescript-eslint/no-explicit-any": "off",
59+
"@typescript-eslint/no-use-before-define": ["off"],
60+
"object-shorthand": "error",
61+
"@typescript-eslint/no-unused-vars": [
62+
"warn",
63+
{ varsIgnorePattern: "^_", argsIgnorePattern: "^_", ignoreRestSiblings: true },
64+
],
65+
"unused-imports/no-unused-imports": "error",
3366
},
34-
prettierExtends,
35-
eslint.configs.recommended,
36-
...tseslint.configs.recommended,
37-
],
38-
settings: {
39-
react: { version: "detect" },
40-
},
41-
plugins: {
42-
prettierPlugin,
43-
"unused-imports": fixupPluginRules(unusedImportsPlugin),
44-
},
45-
rules: {
46-
"prefer-rest-params": "off",
47-
"prefer-const": "error",
48-
"prefer-spread": "off",
49-
"no-case-declarations": "off",
50-
curly: ["error", "all"],
51-
"@typescript-eslint/no-non-null-assertion": "off",
52-
"@typescript-eslint/consistent-type-definitions": ["error", "interface"],
53-
"@typescript-eslint/consistent-type-imports": [
54-
"error",
55-
{
56-
prefer: "type-imports",
57-
},
58-
],
59-
"@typescript-eslint/ban-ts-comment": "off",
60-
"@typescript-eslint/no-explicit-any": "off",
61-
"@typescript-eslint/no-use-before-define": ["off"],
62-
"object-shorthand": "error",
63-
"@typescript-eslint/no-unused-vars": [
64-
"warn",
65-
{ varsIgnorePattern: "^_", argsIgnorePattern: "^_", ignoreRestSiblings: true },
66-
],
67-
"unused-imports/no-unused-imports": "error",
68-
},
69-
languageOptions: {
70-
globals: globalToUse,
71-
parserOptions: {
72-
ecmaFeatures: {
73-
jsx: true,
67+
languageOptions: {
68+
globals: globalToUse,
69+
parserOptions: {
70+
ecmaFeatures: {
71+
jsx: true,
72+
},
7473
},
7574
},
7675
},
77-
});
76+
{ ignores },
77+
);
78+
export default configs;

lib/pointer.ts

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ class Pointer<S extends object = JSONSchema, O extends ParserOptions<S> = Parser
104104
}
105105

106106
const token = tokens[i];
107-
107+
108108
if (this.value[token] === undefined || (this.value[token] === null && i === tokens.length - 1)) {
109109
// one final case is if the entry itself includes slashes, and was parsed out as a token - we can join the remaining tokens and try again
110110
let didFindSubstringSlashMatch = false;
@@ -123,22 +123,18 @@ class Pointer<S extends object = JSONSchema, O extends ParserOptions<S> = Parser
123123

124124
this.value = null;
125125

126-
let path: any = '';
126+
const path = this.$ref.path || "";
127127

128-
if (path !== undefined) {
129-
path = this.$ref.path;
130-
}
128+
const targetRef = this.path.replace(path, "");
129+
const targetFound = Pointer.join("", found);
130+
const parentPath = pathFromRoot?.replace(path, "");
131131

132-
const targetRef = this.path.replace(path, '');
133-
const targetFound = Pointer.join('', found);
134-
const parentPath = pathFromRoot?.replace(path, '');
135-
136132
throw new MissingPointerError(token, decodeURI(this.originalPath), targetRef, targetFound, parentPath);
137133
} else {
138134
this.value = this.value[token];
139135
}
140136

141-
found.push(token)
137+
found.push(token);
142138
}
143139

144140
// Resolve the final value

test/specs/empty/empty.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ describe("Empty schema", () => {
1010
const parser = new $RefParser();
1111
const schema = await parser.parse(path.rel("test/specs/empty/empty.json"));
1212
expect(schema).to.be.an("object");
13-
expect(schema).to.be.empty; // eslint-disable-line no-unused-expressions
13+
expect(schema).to.be.empty;
1414
expect(parser.schema).to.equal(schema);
1515
expect(parser.$refs.paths()).to.deep.equal([path.abs("test/specs/empty/empty.json")]);
1616
});
@@ -24,7 +24,7 @@ describe("Empty schema", () => {
2424
const parser = new $RefParser();
2525
const schema = await parser.dereference(path.rel("test/specs/empty/empty.json"));
2626
expect(schema).to.be.an("object");
27-
expect(schema).to.be.empty; // eslint-disable-line no-unused-expressions
27+
expect(schema).to.be.empty;
2828
expect(parser.schema).to.equal(schema);
2929
expect(parser.$refs.paths()).to.deep.equal([path.abs("test/specs/empty/empty.json")]);
3030
// The "circular" flag should NOT be set
@@ -35,7 +35,7 @@ describe("Empty schema", () => {
3535
const parser = new $RefParser();
3636
const schema = await parser.bundle(path.rel("test/specs/empty/empty.json"));
3737
expect(schema).to.be.an("object");
38-
expect(schema).to.be.empty; // eslint-disable-line no-unused-expressions
38+
expect(schema).to.be.empty;
3939
expect(parser.schema).to.equal(schema);
4040
expect(parser.$refs.paths()).to.deep.equal([path.abs("test/specs/empty/empty.json")]);
4141
});

test/specs/http.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ describe("HTTP options", () => {
155155
const schema = await parser.parse("https://petstore.swagger.io/v2/swagger.json");
156156

157157
expect(schema).to.be.an("object");
158-
expect(schema).not.to.be.empty; // eslint-disable-line no-unused-expressions
158+
expect(schema).not.to.be.empty;
159159
expect(parser.schema).to.equal(schema);
160160
});
161161

@@ -170,7 +170,7 @@ describe("HTTP options", () => {
170170
});
171171

172172
expect(schema).to.be.an("object");
173-
expect(schema).not.to.be.empty; // eslint-disable-line no-unused-expressions
173+
expect(schema).not.to.be.empty;
174174
expect(parser.schema).to.equal(schema);
175175
});
176176

@@ -188,7 +188,7 @@ describe("HTTP options", () => {
188188

189189
// The request succeeded, which means this browser doesn't support CORS.
190190
expect(schema).to.be.an("object");
191-
expect(schema).not.to.be.empty; // eslint-disable-line no-unused-expressions
191+
expect(schema).not.to.be.empty;
192192
expect(parser.schema).to.equal(schema);
193193
} catch (err) {
194194
// The request failed, which is expected

test/specs/refs.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ describe("$Refs object", () => {
134134
values = $refs.values();
135135
expect(values).to.deep.equal(expected);
136136
} else {
137-
expect(values).to.be.an("object").and.empty; // eslint-disable-line no-unused-expressions
137+
expect(values).to.be.an("object").and.empty;
138138
}
139139
});
140140

@@ -154,7 +154,7 @@ describe("$Refs object", () => {
154154
values = $refs.values();
155155
expect(values).to.deep.equal(expected);
156156
} else {
157-
expect(values).to.be.an("object").and.empty; // eslint-disable-line no-unused-expressions
157+
expect(values).to.be.an("object").and.empty;
158158
}
159159
});
160160
});

0 commit comments

Comments
 (0)