npm-groovy-lint
Advanced tools
Comparing version 3.2.1 to 3.2.2
# Changelog | ||
## [3.2.2] 2020-03-31 | ||
- New option **returnrules** if you want to return rules descriptions and documentation url in results | ||
- Use npm ci instead of npm install in CircleCI build | ||
## [3.2.1] 2020-03-29 | ||
- Return rules descriptions in results | ||
- New option nolintafter: do not lint again a format or a fix, as the client prefers to request it | ||
- New option **nolintafter**: do not lint again a format or a fix, as the client prefers to request it | ||
- Fixes | ||
@@ -8,0 +13,0 @@ - [Issue #13](https://github.com/nvuillam/npm-groovy-lint/issues/13): False positive error ClassNameSameAsFileName |
@@ -9,2 +9,3 @@ // Shared functions | ||
const xml2js = require("xml2js"); | ||
const { getConfigFileName } = require("./config.js"); | ||
const { getNpmGroovyLintRules } = require("./groovy-lint-rules.js"); | ||
@@ -19,2 +20,3 @@ const { evaluateRange, evaluateVariables, getSourceLines } = require("./utils.js"); | ||
const CODENARC_TMP_FILENAME_BASE = "codeNarcTmpFile_"; | ||
const CODENARC_WWW_BASE = "https://codenarc.github.io/CodeNarc"; | ||
@@ -197,7 +199,18 @@ // Convert NPM-groovy-lint into codeNarc arguments | ||
// Parse error definitions if not already done | ||
if (result.rules == null) { | ||
// Parse error definitions & build url if not already done and not noreturnrules option | ||
if (result.rules == null && options.returnrules === true) { | ||
const configAllFileName = await getConfigFileName(__dirname, null, [".groovylintrc-all.json"]); | ||
const grooylintrcAllRules = Object.keys(JSON.parse(fse.readFileSync(configAllFileName, "utf8").toString()).rules); | ||
const rules = {}; | ||
for (const ruleDef of tempXmlFileContent.CodeNarc.Rules[0].Rule) { | ||
rules[ruleDef["$"].name] = { description: ruleDef.Description[0] }; | ||
const ruleName = ruleDef["$"].name; | ||
// Add description from CodeNarc | ||
rules[ruleName] = { description: ruleDef.Description[0] }; | ||
// Try to build codenarc url (ex: https://codenarc.github.io/CodeNarc/codenarc-rules-basic.html#bitwiseoperatorinconditional-rule ) | ||
const matchRules = grooylintrcAllRules.filter(ruleNameX => ruleNameX.split(".")[1] === ruleName); | ||
if (matchRules && matchRules[0]) { | ||
const ruleCategory = matchRules[0].split(".")[0]; | ||
const ruleDocUrl = `${CODENARC_WWW_BASE}/codenarc-rules-${ruleCategory}.html#${ruleName.toLowerCase()}-rule`; | ||
rules[ruleName].docUrl = ruleDocUrl; | ||
} | ||
} | ||
@@ -204,0 +217,0 @@ result.rules = rules; |
@@ -174,2 +174,7 @@ /** | ||
{ | ||
option: "returnrules", | ||
type: "Boolean", | ||
description: "Return rule descriptions and url if this argument is set" | ||
}, | ||
{ | ||
option: "help", | ||
@@ -176,0 +181,0 @@ alias: "h", |
{ | ||
"name": "npm-groovy-lint", | ||
"version": "3.2.1", | ||
"version": "3.2.2", | ||
"description": "NPM CodeNarc wrapper to easily lint Groovy files", | ||
@@ -19,4 +19,4 @@ "main": "index.js", | ||
"publish:beta": "npm run build && npm publish --tag beta", | ||
"dev:lint-build-all": "npm run lint:fix && npm run build", | ||
"dev:test-in-vscode-groovy-lint": "npm run dev:lint-build-all && node script-deploy-in-vscode.js" | ||
"dev:lint-build": "npm run lint:fix && npm run build", | ||
"dev:lint-build-copy-vscode": "npm run dev:lint-build && node script-deploy-in-vscode.js" | ||
}, | ||
@@ -23,0 +23,0 @@ "repository": { |
@@ -59,3 +59,4 @@ # NPM GROOVY LINT (and FIX !) | ||
| --failoninfo | Boolean | Fails if at least one error is found | | ||
| --codenarcargs | Boolean | Use core CodeNarc arguments (all npm-groovy-lint arguments will be ignored)<br/> Doc: http://codenarc.github.io/CodeNarc/codenarc-command-line.html<br/> Example: `npm-groovy-lint --codenarcargs -basedir="jdeploy-bundle/lib/example" -rulesetfiles="file:jdeploy-bundle/lib/example/RuleSet-Groovy.groovy" -maxPriority1Violations=0 -report="xml:ReportTestCodenarc.xml` | | ||
| --returnrules | Boolean | Return rules descriptions and URL if set | | ||
| --codenarcargs | String | Use core CodeNarc arguments (all npm-groovy-lint arguments will be ignored)<br/> Doc: http://codenarc.github.io/CodeNarc/codenarc-command-line.html<br/> Example: `npm-groovy-lint --codenarcargs -basedir="jdeploy-bundle/lib/example" -rulesetfiles="file:jdeploy-bundle/lib/example/RuleSet-Groovy.groovy" -maxPriority1Violations=0 -report="xml:ReportTestCodenarc.xml` | | ||
| -h<br/> --help | Boolean | Show help (npm-groovy-lint -h OPTIONNAME to see option detail with examples) | ||
@@ -65,4 +66,8 @@ | ||
Default rules definition ([`recommended`](https://github.com/nvuillam/npm-groovy-lint/blob/master/.groovylintrc-recommended.json), based on [`all`](https://github.com/nvuillam/npm-groovy-lint/blob/master/.groovylintrc-all.json) tracks a lot of errors, do not hesitate to ignore some of them (like NoDef ou RequiredVariableType) if they are too mean for your project. | ||
Define a file named **.groovylintrc.json** (or .js or .YAML, or include in a property groovyLintConfig in package.json) | ||
*If you are using [VsCode Groovy Lint extension](https://marketplace.visualstudio.com/items?itemName=NicolasVuillamy.vscode-groovy-lint), just use QuickFix* ***Ignore in all files*** *and it will generate groovylintrc.json file* | ||
Format : | ||
@@ -69,0 +74,0 @@ |
16372892
4191
190