-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(responsibilities): add class descriptions
- Loading branch information
1 parent
e81e212
commit 4f14011
Showing
18 changed files
with
716 additions
and
47 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
#!/usr/bin/env node | ||
|
||
"use strict"; | ||
|
||
const fs = require("fs"); | ||
const meow = require("meow"); | ||
const path = require("path"); | ||
// eslint-disable-next-line node/no-unsupported-features | ||
const { CLIEngine } = require("eslint"); | ||
|
||
const msg = { | ||
error: "❌ There was a problem generating your CRC Model report.\n ", | ||
|
||
success: "✅ CRC Model report generated at ", | ||
|
||
usage: ` | ||
Usage | ||
$ eslint-plugin-crc input [options] [info] | ||
Input | ||
The path (or glob) of the JavaScript resources you want | ||
analyzed. [Default: '.'] | ||
Options | ||
--output, -o The "CRC Models report" destination directory. | ||
[Default: './reports'] | ||
Info | ||
--help Show this dialog. | ||
--version Display the installed semantic version. | ||
Examples | ||
$ eslint-plugin-crc | ||
✅ Generated a CRC Model report to | ||
/Users/you/work/repo/reports/crc-model-report.md. | ||
$ eslint-plugin-crc 'lib/**/*.js' -o='./tests/analysis' | ||
✅ Generated a CRC Model report to | ||
/Users/you/work/repo/tests/analysis/crc-model-report.md. | ||
$ eslint-plugin-crc -o='😱 ' | ||
❌ There was a problem generating your CRC Model report. | ||
Error: ENOENT: no such file or directory, open '😱 ' | ||
`, | ||
|
||
toString: function (message = "", type = msg.success) { | ||
return type + message; | ||
} | ||
}; | ||
|
||
const options = { | ||
flags: { | ||
output: { | ||
alias: "o", | ||
default: path.resolve(__dirname, "../reports/crc-model-report.md"), | ||
type: "string" | ||
} | ||
} | ||
}; | ||
|
||
function writeReportFile (out, report) { | ||
// eslint-disable-next-line security/detect-non-literal-fs-filename | ||
fs.writeFile(out, report, {flag: "w"}, (err) => { | ||
if (err) { | ||
console.error(msg.toString(err, msg.error)); | ||
} | ||
console.log(msg.toString(out)); | ||
}); | ||
} | ||
|
||
function generateReport () { | ||
const eslintCli = new CLIEngine("./lib/.eslintrc.yml"); | ||
const cli = meow(msg.usage, options); | ||
const files = eslintCli.resolveFileGlobPatterns(cli.input); | ||
const report = eslintCli.executeOnFiles(files); | ||
const formatter = eslintCli.getFormatter("./lib/formatters/crc/index.js"); | ||
const crcModelReport = formatter(report.results); | ||
const out = cli.flags.output || options.flags.output.default; | ||
writeReportFile(out, crcModelReport); | ||
} | ||
|
||
function main () { | ||
generateReport(); | ||
} | ||
|
||
main(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// const astConfig = require("./ast-config"); | ||
const escomplex = require("escomplex"); | ||
// const espree = require("espree"); | ||
|
||
class Complexity { | ||
static analyze (context) { | ||
return escomplex.analyse(context); | ||
} | ||
} | ||
|
||
module.exports = Complexity; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/** | ||
* A collection of "classes"--i.e., prototypable JS objects--in a single CrcReport. | ||
*/ | ||
// class CrcReport { | ||
// constructor () { | ||
// this.meta = { | ||
// date: new Date(), | ||
// description: null, | ||
// title: null | ||
// }; | ||
// this.classes = []; | ||
// } | ||
// } | ||
|
||
// module.exports = CrcReport; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// const { CLIEngine } = require("eslint"); | ||
// | ||
// const cli = new CLIEngine({ | ||
// configFile: '../.eslintrc.yml' | ||
// }); | ||
// | ||
// module.exports = cli.getFormatter('.'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
lib/formatters/crc/crc-page-template.md → lib/formatters/crc/crc-page-template.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,9 @@ | ||
# CRC Model results | ||
|
||
> <%= reportSummary %>. Generated on <%= date.toISOString() %>. | ||
|
||
<%= results %> | ||
|
||
--- | ||
|
||
[classes-mdn-url]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes |
Oops, something went wrong.