npm-groovy-lint
Advanced tools
Comparing version 7.2.0 to 7.3.0
# Changelog | ||
## [7.3.0] 2020-08-15 | ||
- Allow to link to [CodeNarc RuleSet files](https://codenarc.github.io/CodeNarc/codenarc-creating-ruleset.html) from `.groovylintrc.json`, using property `"codenarcRulesets"`. Warning: doing so means that all other properties of config file will be ignored. | ||
## [7.1.1] 2020-08-11 | ||
@@ -4,0 +8,0 @@ |
@@ -93,3 +93,3 @@ // Call CodeNarc by server or java | ||
(startServerTried === false, | ||
e.code && ["ECONNREFUSED", "ETIMEDOUT"].includes(e.code) && ["unknown", "running"].includes(this.serverStatus)) // running is here in case the Server auto-killed itself at its expiration time | ||
e.code && ["ECONNREFUSED", "ETIMEDOUT"].includes(e.code) && ["unknown", "running"].includes(this.serverStatus)) // running is here in case the Server auto-killed itself at its expiration time | ||
) { | ||
@@ -108,5 +108,5 @@ if ((await this.startCodeNarcServer()) && this.serverStatus === "running") { | ||
"CodeNarcServer unexpected error:\n" + | ||
JSON.stringify(e, null, 2) + | ||
"\n" + | ||
(e.response && e.response.data && e.response.data.errorDtl ? JSON.stringify(e.response.data.errorDtl, null, 2) : undefined) | ||
JSON.stringify(e, null, 2) + | ||
"\n" + | ||
(e.response && e.response.data && e.response.data.errorDtl ? JSON.stringify(e.response.data.errorDtl, null, 2) : undefined) | ||
); | ||
@@ -113,0 +113,0 @@ } |
@@ -41,4 +41,6 @@ // Configuration file management | ||
let configUser = {}; | ||
let configFilePath; | ||
if (configExtensions.includes(startPathOrFile.split(".").pop()) && mode !== "format") { | ||
// Sent file name | ||
configFilePath = startPathOrFile; | ||
configUser = await loadConfigFromFile(startPathOrFile); | ||
@@ -48,3 +50,3 @@ } else if (startPathOrFile.match(/^[a-zA-Z\d-_]+$/) && mode !== "format") { | ||
fileNames = configExtensions.map(ext => `.groovylintrc-${startPathOrFile}.${ext}`); | ||
const configFilePath = await getConfigFileName(sourcefilepath || process.cwd(), sourcefilepath, fileNames, ""); | ||
configFilePath = await getConfigFileName(sourcefilepath || process.cwd(), sourcefilepath, fileNames, ""); | ||
configUser = await loadConfigFromFile(configFilePath); | ||
@@ -60,6 +62,15 @@ } else { | ||
} | ||
const configFilePath = await getConfigFileName(startPathOrFile, sourcefilepath, fileNames, defaultConfig); | ||
configFilePath = await getConfigFileName(startPathOrFile, sourcefilepath, fileNames, defaultConfig); | ||
// Load user configuration from file | ||
configUser = await loadConfigFromFile(configFilePath); | ||
} | ||
// Complete PATH to codeNarc rulesets if defined in .groovylintrc | ||
if (configFilePath && configUser.codenarcRulesets) { | ||
// Set ruleSet file if found from config file | ||
configUser.rulesets = configUser.codenarcRulesets | ||
.split(",") | ||
.map(rulesetFile => path.resolve(path.dirname(configFilePath) + "/" + rulesetFile)) | ||
.join(","); | ||
} | ||
// Shorten rule names if long rule names Cat.Rule replaced by Ru | ||
@@ -66,0 +77,0 @@ configUser.rules = await shortenRuleNames(configUser.rules || {}); |
@@ -11,3 +11,3 @@ #! /usr/bin/env node | ||
describe("Miscellaneous", function () { | ||
describe("Miscellaneous", function() { | ||
beforeEach(beforeEachTestCase); | ||
@@ -162,2 +162,13 @@ | ||
it("(API:source) should use a CodeNarc ruleset defined in groovylintrc.json", async () => { | ||
const npmGroovyLintConfig = { | ||
config: "./lib/example/.groovylintrc-codenarc-rulesets.json", | ||
path: "./lib/example/", | ||
files: "**/" + SAMPLE_FILE_SMALL, | ||
output: "txt" | ||
}; | ||
const linter = await new NpmGroovyLint(npmGroovyLintConfig, {}).run(); | ||
assert(linter.status === 0, `Linter status is 0 (${linter.status} returned)`); | ||
}); | ||
it("(API:source) should cancel current request", async () => { | ||
@@ -298,3 +309,2 @@ const requestKey = "requestKeyCalculatedByExternal" + Math.random(); | ||
it("(API:Server) should kill java override running server", async () => { | ||
let javaPath; | ||
@@ -301,0 +311,0 @@ try { |
{ | ||
"name": "npm-groovy-lint", | ||
"version": "7.2.0", | ||
"version": "7.3.0", | ||
"description": "Lint, format and auto-fix your Groovy / Jenkinsfile / Gradle files", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -98,2 +98,6 @@ <!-- markdownlint-disable MD033 --> | ||
OR | ||
- **codenarcRulesets**: Comma-separated string containing the list of `.xml` or `.groovy` CodeNarc RuleSet files (in case you already are a CodeNarc user and do not wish to switch to npm-groovy-lint config format) | ||
### Examples | ||
@@ -128,4 +132,10 @@ | ||
## EXAMPLES | ||
```json | ||
{ | ||
"codenarcRulesets": "RuleSet-1.groovy,RuleSet-2.groovy" | ||
} | ||
``` | ||
## EXAMPLE CALLS | ||
- Lint groovy with JSON output | ||
@@ -384,2 +394,6 @@ | ||
### [7.3.0] 2020-08-15 | ||
- Allow to link to [CodeNarc RuleSet files](https://codenarc.github.io/CodeNarc/codenarc-creating-ruleset.html) from `.groovylintrc.json`, using property `"codeNarcRulesets"`. Warning: doing so means that all other properties of config file will be ignored. | ||
### [7.1.1] 2020-08-11 | ||
@@ -386,0 +400,0 @@ |
16570627
116
8000
426