Skip to content

Commit 1607368

Browse files
committedFeb 18, 2022
updated eslint to 8+
1 parent e8de0d1 commit 1607368

14 files changed

+546
-1038
lines changed
 

‎.eslintrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
"guard-for-in": 0,
3535
"consistent-return": 0,
3636
"array-callback-return": 0,
37-
"prefer-destructuring": 0,
37+
"prefer-destructuring": 1,
3838
"class-methods-use-this": 0,
3939
"object-curly-newline": ["error", {
4040
"ObjectPattern": { "multiline": true },

‎package-lock.json

+524-995
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,9 @@
5858
"clean-webpack-plugin": "^4.0.0",
5959
"compression-webpack-plugin": "^9.2.0",
6060
"css-loader": "^6.6.0",
61-
"eslint": "^7.32.0",
61+
"eslint": "^8.9.0",
6262
"eslint-config-airbnb": "^19.0.4",
6363
"eslint-import-resolver-webpack": "^0.13.2",
64-
"eslint-loader": "^4.0.2",
6564
"eslint-plugin-import": "^2.25.4",
6665
"eslint-webpack-plugin": "3.1.1",
6766
"file-loader": "^6.2.0",

‎src/components/api-request.js

+7-9
Original file line numberDiff line numberDiff line change
@@ -274,11 +274,11 @@ export default class ApiRequest extends LitElement {
274274
for (const param of filteredParams) {
275275
const [declaredParamSchema, serializeStyle, mimeTypeElem] = getSchemaFromParam(param);
276276
if (!declaredParamSchema) {
277-
continue;
277+
continue; // eslint-disable-line no-continue
278278
}
279279
const paramSchema = getTypeInfo(declaredParamSchema);
280280
if (!paramSchema) {
281-
continue;
281+
continue; // eslint-disable-line no-continue
282282
}
283283
const schemaAsObj = schemaInObjectNotation(declaredParamSchema, {});
284284
// let exampleVal = '';
@@ -509,7 +509,7 @@ export default class ApiRequest extends LitElement {
509509
let reqBodyExampleHtml = '';
510510

511511
const requestBodyTypes = [];
512-
const content = this.request_body.content;
512+
const { content } = this.request_body;
513513
for (const mimeType in content) {
514514
requestBodyTypes.push({
515515
mimeType,
@@ -709,7 +709,7 @@ export default class ApiRequest extends LitElement {
709709
<div style="width:24px; background-color:var(--light-border-color)">
710710
<div class="row" style="flex-direction:row-reverse; width:160px; height:24px; transform:rotate(270deg) translateX(-160px); transform-origin:top left; display:block;" @click="${(e) => {
711711
if (e.target.classList.contains('v-tab-btn')) {
712-
const tab = e.target.dataset.tab;
712+
const { tab } = e.target.dataset;
713713
if (tab) {
714714
const tabPanelEl = e.target.closest('.tab-panel');
715715
const selectedTabBtnEl = tabPanelEl.querySelector(`.v-tab-btn[data-tab="${tab}"]`);
@@ -1082,8 +1082,7 @@ export default class ApiRequest extends LitElement {
10821082
queryParam.append(el.dataset.pname, el.value);
10831083
}
10841084
} else {
1085-
const paramSerializeStyle = el.dataset.paramSerializeStyle;
1086-
const paramSerializeExplode = el.dataset.paramSerializeExplode;
1085+
const { paramSerializeStyle, paramSerializeExplode } = el.dataset;
10871086
let vals = ((el.value && Array.isArray(el.value)) ? el.value : []);
10881087
vals = Array.isArray(vals) ? vals.filter((v) => v !== '') : [];
10891088
if (vals.length > 0) {
@@ -1112,8 +1111,7 @@ export default class ApiRequest extends LitElement {
11121111
const queryParam = new URLSearchParams();
11131112
try {
11141113
let queryParamObj = {};
1115-
const paramSerializeStyle = el.dataset.paramSerializeStyle;
1116-
const paramSerializeExplode = el.dataset.paramSerializeExplode;
1114+
const { paramSerializeStyle, paramSerializeExplode } = el.dataset.paramSerializeStyle;
11171115
queryParamObj = Object.assign(queryParamObj, JSON.parse(el.value.replace(/\s+/g, ' ')));
11181116
if (el.dataset.paramAllowReserved === 'true') {
11191117
queryParamsWithReservedCharsAllowed.push(el.dataset.pname);
@@ -1283,7 +1281,7 @@ export default class ApiRequest extends LitElement {
12831281
} else if (/^audio\/|^image\/|^video\/|^font\/|tar$|zip$|7z$|rtf$|msword$|excel$|\/pdf$|\/octet-stream$/.test(requestBodyType)) {
12841282
const bodyParamFileEl = requestPanelEl.querySelector('.request-body-param-file');
12851283
if (bodyParamFileEl?.files[0]) {
1286-
fetchOptions.body = bodyParamFileEl.files[0];
1284+
fetchOptions.body = bodyParamFileEl.files[0]; // eslint-disable-line prefer-destructuring
12871285
curlData = ` --data-binary @${bodyParamFileEl.files[0].name} \\\n`;
12881286
}
12891287
} else if (requestBodyType.includes('json') || requestBodyType.includes('xml') || requestBodyType.includes('text')) {

‎src/components/api-response.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ export default class ApiResponse extends LitElement {
148148
@click="${() => {
149149
this.selectedStatus = respStatus;
150150
if (this.responses[respStatus].content && Object.keys(this.responses[respStatus].content)[0]) {
151-
this.selectedMimeType = Object.keys(this.responses[respStatus].content)[0];
151+
this.selectedMimeType = Object.keys(this.responses[respStatus].content)[0]; // eslint-disable-line prefer-destructuring
152152
} else {
153153
this.selectedMimeType = undefined;
154154
}

‎src/components/schema-table.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,8 @@ export default class SchemaTable extends LitElement {
162162
isOneOfLabel = true;
163163
} else if (key.startsWith('::OPTION')) {
164164
const parts = key.split('~');
165-
keyLabel = parts[1];
166-
keyDescr = parts[2];
165+
keyLabel = parts[1]; // eslint-disable-line prefer-destructuring
166+
keyDescr = parts[2]; // eslint-disable-line prefer-destructuring
167167
} else {
168168
keyLabel = key;
169169
}

‎src/components/schema-tree.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,8 @@ export default class SchemaTree extends LitElement {
156156
keyLabel = key.replace('::', '').replace('~', ' ');
157157
} else if (key.startsWith('::OPTION')) {
158158
const parts = key.split('~');
159-
keyLabel = parts[1];
160-
keyDescr = parts[2];
159+
keyLabel = parts[1]; // eslint-disable-line prefer-destructuring
160+
keyDescr = parts[2]; // eslint-disable-line prefer-destructuring
161161
} else {
162162
keyLabel = key;
163163
}

‎src/oauth-receiver.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export default class OauthReceiver extends HTMLElement {
2424
} else if (window.location.hash) { // Applies to Implicit flow
2525
const token_type = this.parseQueryString(window.location.hash.substring(1), 'token_type'); // eslint-disable-line camelcase
2626
const access_token = this.parseQueryString(window.location.hash.substring(1), 'access_token'); // eslint-disable-line camelcase
27-
authData = { token_type, access_token, responseType: 'token' };
27+
authData = { token_type, access_token, responseType: 'token' }; // eslint-disable-line camelcase
2828
}
2929

3030
if (window.opener) {

‎src/rapidoc-mini.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ export default class RapiDocMini extends LitElement {
316316
}
317317
if (!this.selectedServer) {
318318
if (this.resolvedSpec.servers) {
319-
this.selectedServer = this.resolvedSpec.servers[0];
319+
this.selectedServer = this.resolvedSpec.servers[0]; // eslint-disable-line prefer-destructuring
320320
}
321321
}
322322
this.requestUpdate();

‎src/rapidoc.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -709,7 +709,7 @@ export default class RapiDoc extends LitElement {
709709
}
710710
if (!this.selectedServer) {
711711
if (this.resolvedSpec.servers) {
712-
this.selectedServer = this.resolvedSpec.servers[0];
712+
this.selectedServer = this.resolvedSpec.servers[0]; // eslint-disable-line prefer-destructuring
713713
}
714714
}
715715
this.requestUpdate();

‎src/templates/security-scheme-template.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -253,9 +253,7 @@ async function onInvokeOAuthFlow(securitySchemeId, flowType, authUrl, tokenUrl,
253253
/* eslint-disable indent */
254254

255255
function oAuthFlowTemplate(flowName, clientId, clientSecret, securitySchemeId, authFlow) {
256-
let authorizationUrl = authFlow.authorizationUrl;
257-
let tokenUrl = authFlow.tokenUrl;
258-
let refreshUrl = authFlow.refreshUrl;
256+
let { authorizationUrl, tokenUrl, refreshUrl } = authFlow.authorizationUrl;
259257
const isUrlAbsolute = (url) => (url.indexOf('://') > 0 || url.indexOf('//') === 0);
260258
if (refreshUrl && !isUrlAbsolute(refreshUrl)) {
261259
refreshUrl = `${this.selectedServer.computedUrl}/${refreshUrl.replace(/^\//, '')}`;

‎src/utils/schema-utils.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ export function normalizeExamples(examples, dataType = 'string') {
105105
}
106106
if (examples.length > 0) {
107107
if (dataType === 'array') {
108-
exampleVal = examples[0];
108+
[exampleVal] = examples;
109109
exampleList = examples.map((v) => ({ value: v, description: Array.isArray(v) ? v.join(' , ') : v }));
110110
} else {
111111
exampleVal = examples[0].toString();

‎src/utils/spec-parser.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ function groupByTags(openApiSpec, sortEndpointsBy, generateMissingTags = false,
313313
// Generate a short summary which is broken
314314
let shortSummary = (pathOrHookObj.summary || pathOrHookObj.description || `${methodName.toUpperCase()} ${pathOrHookName}`).trim();
315315
if (shortSummary.length > 100) {
316-
shortSummary = shortSummary.split(/[.|!|?]\s|[\r?\n]/)[0]; // take the first line (period or carriage return)
316+
[shortSummary] = shortSummary.split(/[.|!|?]\s|[\r?\n]/); // take the first line (period or carriage return)
317317
}
318318
// Merge Common Parameters with This methods parameters
319319
let finalParameters = [];

‎webpack.config.js

+2-18
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const HtmlWebpackPlugin = require('html-webpack-plugin');
2020
const TerserPlugin = require('terser-webpack-plugin');
2121
const UnminifiedWebpackPlugin = require('unminified-webpack-plugin');
2222
const path = require('path');
23-
// const ESLintPlugin = require('eslint-webpack-plugin');
23+
const ESLintPlugin = require('eslint-webpack-plugin');
2424

2525
const rapidocVersion = JSON.stringify(require('./package.json').version).replace(/"/g, '');
2626

@@ -36,6 +36,7 @@ const rapidocBanner = `
3636
const commonPlugins = [
3737
new webpack.ProvidePlugin({ Buffer: ['buffer', 'Buffer'] }),
3838
new webpack.HotModuleReplacementPlugin(),
39+
new ESLintPlugin({ extensions: ['js'] }),
3940
new CleanWebpackPlugin(),
4041
new webpack.optimize.LimitChunkCountPlugin({ maxChunks: 1 }),
4142
new HtmlWebpackPlugin({ template: 'index.html' }),
@@ -101,23 +102,6 @@ module.exports = {
101102
},
102103
module: {
103104
rules: [
104-
{
105-
enforce: 'pre',
106-
test: /\.js$/,
107-
exclude: /node_modules/,
108-
loader: 'eslint-loader',
109-
options: {
110-
emitWarning: true,
111-
// failOnWarning: true,
112-
// failOnError: true,
113-
fix: false,
114-
configFile: './.eslintrc',
115-
outputReport: {
116-
filePath: './eslint_report.html',
117-
formatter: 'html',
118-
},
119-
},
120-
},
121105
{
122106
test: /\.js$/,
123107
exclude: /node_modules/,

0 commit comments

Comments
 (0)
Please sign in to comment.