Run with npx https://gist.github.com/seriema/b1c00036175cbfc374548b499bafcb27
.
Last active
May 2, 2019 11:03
-
-
Save seriema/b1c00036175cbfc374548b499bafcb27 to your computer and use it in GitHub Desktop.
lint-episerver-cms-api
This file contains hidden or 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
#!/usr/bin/env node | |
const EslintEngine = require("eslint").CLIEngine; | |
const args = require('arg')({ | |
'--xproduct': Boolean, | |
'-x': '--xproduct' | |
}); | |
const fs = require('fs'); | |
const config = require("./npx-eslintrc.js"); | |
const configXProduct = require("./npx-eslintrc-xproduct.js"); | |
const eslint = new EslintEngine({ | |
// Only use the included config files. | |
baseConfig: args["--xproduct"] ? configXProduct : config, | |
useEslintrc: false | |
}); | |
// Run on all files in the current directory. | |
const report = eslint.executeOnFiles( | |
eslint.resolveFileGlobPatterns(["."]) | |
); | |
// The default formatter "telemetry" is a JSON file we would like to have as feedback on our API's. | |
const telemetryFormatter = eslint.getFormatter("@episerver/cms"); | |
fs.writeFile('episerver-cms-api-usage.json', telemetryFormatter(report.results), 'utf8', (err) => { | |
if(err) { | |
throw err | |
} | |
}); | |
// Output a nice summary table. | |
const summaryFormatter = eslint.getFormatter("@episerver/cms/lib/summary"); | |
console.log(summaryFormatter(report.results)); |
This file contains hidden or 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
const config = require("./npx-eslintrc.js"); | |
module.exports = Object.assign({}, config, | |
{ | |
"rules": { | |
"@episerver/cms/no-internal-episerver-apis": ["error", "xproduct"] | |
} | |
} | |
); |
This file contains hidden or 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
module.exports = { | |
"plugins": ["@episerver/cms"], | |
"extends": "plugin:@episerver/cms/recommended" | |
}; |
This file contains hidden or 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
{ | |
"name": "@episerver/create-cms-api-report", | |
"version": "0.0.0", | |
"bin": "index.js", | |
"dependencies": { | |
"@episerver/eslint-formatter-cms": "^1.0.0", | |
"@episerver/eslint-plugin-cms": "^2.1.0", | |
"arg": "^4.1.0", | |
"eslint": "^4.19.1" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment