Skip to content

Commit

Permalink
chore(lint): tidy up linting code and remove unused stuff
Browse files Browse the repository at this point in the history
We moved linting to the backend!
  • Loading branch information
domharrington committed Sep 13, 2023
1 parent 7208a56 commit 2985658
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 40 deletions.
3 changes: 3 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,8 @@
"warnOnUnassignedImports": true
}
]
},
"parserOptions": {
"ecmaVersion": 2020
}
}
5 changes: 0 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
#!/usr/bin/env node
/* eslint-disable no-console */

/* We'll make this better eventually, but for now we'll make it quickly! */

const fs = require('fs');
const path = require('path');

Expand Down Expand Up @@ -100,7 +96,6 @@ async function main(opts) {
})
.then(response => {
const body = response.data;
console.log('body', body);
if (body.lint?.length) {
body.lint.forEach(l => {
console.log(`Linting issues in ${l.fileName}:`);
Expand Down
35 changes: 0 additions & 35 deletions utils.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
const fs = require('fs');
const path = require('path');

const spectralCore = require('@stoplight/spectral-core');
const { bundleAndLoadRuleset } = require('@stoplight/spectral-ruleset-bundler/with-loader');
const { Spectral, Document } = spectralCore;
const { truthy } = require('@stoplight/spectral-functions'); // this has to be installed as well
const Parsers = require('@stoplight/spectral-parsers'); // make sure to install the package if you intend to use default parsers!

const glob = require('glob');
const ignore = require('ignore');

Expand Down Expand Up @@ -58,35 +52,6 @@ module.exports = {

return glob.sync(globs).filter(ig.createFilter()).filter(filterOas);
},

async lint(spec) {
return new Promise((resolve, reject) => {
// this will be our API specification document
const loadRules = {
// It's crazy we have to mock `fs` for spectral, but
// alas, i guess that's what makes micro valuable?
promises: {
readFile() {
return `extends: spectral:oas
rules:
openapi-tags: off
operation-tags: off`;
},
},
};

bundleAndLoadRuleset(`/.we-need-some-thing-here.yaml`, { fs: loadRules, fetch: false }).then(ruleSet => {
const myDocument = new Document(spec.oas, Parsers.Json, 'oas');
const spectral = new Spectral();
spectral.setRuleset(ruleSet);

// we lint our document using the ruleset we passed to the Spectral object
spectral.run(myDocument).then(results => {
resolve({ success: !results.length, output: results });
});
});
});
},
};

module.exports.isOpenApiJson = isOpenApiJson;
Expand Down

0 comments on commit 2985658

Please sign in to comment.