npm-groovy-lint
Advanced tools
Comparing version 8.0.0-beta.5 to 8.0.0
# Changelog | ||
## [8.0.0] Unreleased | ||
## [8.0.0] 2020-11-15 | ||
@@ -8,4 +8,4 @@ - Upgrade to CodeNarc 2.0.0 | ||
- Adapt Indentation rule to new behaviour | ||
- Use codenarc --ruleset arg instead of temp ruleset file | ||
- Replace super-linter by [Mega-Linter](https://github.com/nvuillam/mega-linter#readme) | ||
- Use codenarc --ruleset argument instead of temp ruleset file | ||
- Replace super-linter by [Mega-Linter](https://nvuillam.github.io/mega-linter/) | ||
- Fixes | ||
@@ -18,2 +18,3 @@ - [(#127)](https://github.com/nvuillam/npm-groovy-lint/issues/127) Formatting breaks code, converting `else if` into `elseif` in some cases | ||
- Activate spelling linter of Mega-Linter (+ `.cspell.json` file) | ||
- Add test cases for format and fix using CLI | ||
@@ -20,0 +21,0 @@ ## [7.6.2] 2020-09-09 |
@@ -0,0 +0,0 @@ { |
@@ -105,3 +105,2 @@ // Additional definition for codenarc rules ( get position & available fix) | ||
"ExplicitLinkedListInstantiation", | ||
"InsecureRandom", | ||
"SpaceBeforeOpeningBrace", | ||
@@ -133,2 +132,3 @@ "SpaceAfterOpeningBrace", | ||
"UnusedImport", | ||
"InsecureRandom", | ||
"DuplicateImport", | ||
@@ -135,0 +135,0 @@ "BlankLineBeforePackage", |
@@ -0,0 +0,0 @@ #! /usr/bin/env node |
@@ -12,2 +12,4 @@ #! /usr/bin/env node | ||
const SAMPLE_FILE_SMALL = "SampleFileSmall.groovy"; | ||
const SAMPLE_FILE_SMALL_FORMAT = "SampleFileSmallFormatted.txt"; | ||
const SAMPLE_FILE_SMALL_FIX = "SampleFileSmallFixed.txt"; | ||
const SAMPLE_FILE_SMALL_PATH = startPath + SAMPLE_FILE_SMALL; | ||
@@ -69,2 +71,4 @@ const SAMPLE_FILE_PARSE_ERROR = "WithParseError.groovy"; | ||
SAMPLE_FILE_SMALL, | ||
SAMPLE_FILE_SMALL_FORMAT, | ||
SAMPLE_FILE_SMALL_FIX, | ||
SAMPLE_FILE_BIG_PATH, | ||
@@ -71,0 +75,0 @@ SAMPLE_FILE_SMALL_PATH, |
@@ -7,3 +7,9 @@ #! /usr/bin/env node | ||
const rimraf = require("rimraf"); | ||
const { beforeEachTestCase, copyFilesInTmpDir, checkCodeNarcCallsCounter, SAMPLE_FILE_BIG_PATH } = require("./helpers/common"); | ||
const { | ||
beforeEachTestCase, | ||
copyFilesInTmpDir, | ||
checkCodeNarcCallsCounter, | ||
SAMPLE_FILE_BIG_PATH, | ||
SAMPLE_FILE_SMALL_PATH | ||
} = require("./helpers/common"); | ||
@@ -86,2 +92,27 @@ describe("Lint & fix with API", function() { | ||
it("(API:source) should lint and fix (no lintagainafterfix) 2", async () => { | ||
const sampleFilePath = SAMPLE_FILE_SMALL_PATH; | ||
const expectedFixedErrs = 14; | ||
const prevFileContent = fse.readFileSync(sampleFilePath).toString(); | ||
const npmGroovyLintConfig = { | ||
source: prevFileContent, | ||
sourcefilepath: sampleFilePath, | ||
fix: true, | ||
nolintafter: true, | ||
output: "txt", | ||
insight: false, | ||
verbose: true | ||
}; | ||
const linter = await new NpmGroovyLint(npmGroovyLintConfig, {}).run(); | ||
assert(linter.status === 0, `Linter status is 0 (${linter.status} returned)`); | ||
assert( | ||
linter.lintResult.summary.totalFixedNumber >= expectedFixedErrs, | ||
`${expectedFixedErrs} errors have been fixed (${linter.lintResult.summary.totalFixedNumber} returned)` | ||
); | ||
assert(linter.lintResult.files[0].updatedSource && linter.lintResult.files[0].updatedSource !== prevFileContent, "Source has been updated"); | ||
assert(!linter.outputString.includes("NaN"), "Results does not contain NaN"); | ||
checkCodeNarcCallsCounter(1); | ||
}).timeout(200000); | ||
it("(API:file) should lint and fix a Jenkinsfile in one shot", async function() { | ||
@@ -88,0 +119,0 @@ const tmpDir = await copyFilesInTmpDir(); |
@@ -18,3 +18,3 @@ #! /usr/bin/env node | ||
describe("Format with API", function () { | ||
describe("Format with API", function() { | ||
beforeEach(beforeEachTestCase); | ||
@@ -130,8 +130,7 @@ | ||
); | ||
if (checkType == 'format') { | ||
npmGroovyLintConfig.format = true | ||
if (checkType == "format") { | ||
npmGroovyLintConfig.format = true; | ||
} else if (checkType == "fix") { | ||
npmGroovyLintConfig.fix = true; | ||
} | ||
else if (checkType == "fix") { | ||
npmGroovyLintConfig.fix = true | ||
} | ||
const linter = await new NpmGroovyLint(npmGroovyLintConfig, {}).run(); | ||
@@ -138,0 +137,0 @@ |
@@ -140,4 +140,4 @@ // Shared functions | ||
: varDef.type && varDef.type === "array" | ||
? JSON.parse(value) | ||
: value; | ||
? JSON.parse(value) | ||
: value; | ||
evaluatedVars.push({ | ||
@@ -144,0 +144,0 @@ name: varDef.name, |
{ | ||
"name": "npm-groovy-lint", | ||
"version": "8.0.0-beta.5", | ||
"version": "8.0.0", | ||
"description": "Lint, format and auto-fix your Groovy / Jenkinsfile / Gradle files", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -29,3 +29,3 @@ <!-- markdownlint-disable MD013 MD033 MD034 --> | ||
- [Visual Studio Code Groovy Lint extension](https://marketplace.visualstudio.com/items?itemName=NicolasVuillamy.vscode-groovy-lint) | ||
- [Mega-Linter](https://github.com/nvuillam/mega-linter#readme) (can be used as GitHub Action, and lints all other languages and formats) | ||
- [Mega-Linter](https://nvuillam.github.io/mega-linter/) (can be used as GitHub Action, and lints all other languages and formats) | ||
- [Docker Image](#call-via-docker) | ||
@@ -39,13 +39,5 @@ | ||
## INSTALLATION | ||
## Usage | ||
```shell | ||
npm install -g npm-groovy-lint | ||
``` | ||
Node.js >= 12 is required to run this package. If you can't upgrade, you can use [nvm](https://github.com/nvm-sh/nvm) to have [different node versions on your computer](https://www.sitepoint.com/quick-tip-multiple-versions-node-nvm/) | ||
## USAGE | ||
```shell | ||
npm-groovy-lint OPTIONS | ||
@@ -80,4 +72,12 @@ ``` | ||
## CONFIGURATION | ||
## Installation | ||
```shell | ||
npm install -g npm-groovy-lint | ||
``` | ||
Node.js >= 12 is required to run this package. If you can't upgrade, you can use [nvm](https://github.com/nvm-sh/nvm) to have [different node versions on your computer](https://www.sitepoint.com/quick-tip-multiple-versions-node-nvm/) | ||
## Configuration | ||
Default rules definition ([`recommended`](https://github.com/nvuillam/npm-groovy-lint/blob/master/lib/.groovylintrc-recommended.json), based on [`all`](https://github.com/nvuillam/npm-groovy-lint/blob/master/lib/.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. | ||
@@ -145,3 +145,3 @@ | ||
## EXAMPLE CALLS | ||
## Example calls | ||
@@ -166,3 +166,3 @@ - Lint groovy with JSON output | ||
## DISABLING RULES IN SOURCE | ||
## Disabling rules in source | ||
@@ -249,3 +249,3 @@ You can disable rules directly by adding comment in file, using [eslint style](https://eslint.org/docs/user-guide/configuring#disabling-rules-with-inline-comments) | ||
## AUTO-FIXABLE RULES | ||
## Auto-Fixable rules | ||
@@ -306,22 +306,10 @@ - AssignmentInConditional | ||
## CALL VIA DOCKER | ||
## CD/CI | ||
You can run npm-groovy-lint using its [official docker image](https://hub.docker.com/r/nvuillam/npm-groovy-lint) | ||
### Mega-Linter | ||
### Shell example | ||
Latest npm-groovy-lint version is natively integrated in [**Mega-Linter**](https://nvuillam.github.io/mega-linter/), that you can use as GitHub action or in other CI tools | ||
Run with default settings | ||
### CircleCI | ||
```shell | ||
docker run -u "$(id -u):$(id -g)" -w=/tmp -v "$PWD":/tmp nvuillam/npm-groovy-lint | ||
``` | ||
Run with additional flags by simply appending them at after docker image name: | ||
```shell | ||
docker run -u "$(id -u):$(id -g)" -w=/tmp -v "$PWD":/tmp nvuillam/npm-groovy-lint --failon warning --verbose | ||
``` | ||
### CircleCI example | ||
```yaml | ||
@@ -347,3 +335,3 @@ # .circleci/config.yml | ||
### Jenkinsfile example | ||
### Jenkins | ||
@@ -359,4 +347,22 @@ ```groovy | ||
## CALL VIA JS MODULE | ||
### Shell | ||
Run with default settings | ||
```shell | ||
docker run -u "$(id -u):$(id -g)" -w=/tmp -v "$PWD":/tmp nvuillam/npm-groovy-lint | ||
``` | ||
Run with additional flags by simply appending them at after docker image name: | ||
```shell | ||
docker run -u "$(id -u):$(id -g)" -w=/tmp -v "$PWD":/tmp nvuillam/npm-groovy-lint --failon warning --verbose | ||
``` | ||
### Other | ||
You can run npm-groovy-lint using its [official docker image](https://hub.docker.com/r/nvuillam/npm-groovy-lint) | ||
## Use as module | ||
You can import npm-groovy-lint into your NPM package and call lint & fix via module, using the same options than from npm-groovy-lint command line | ||
@@ -385,8 +391,4 @@ | ||
## TROUBLESHOOTING | ||
## Contribute | ||
- On some environments, it has been observed that installed Groovy version must match Groovy embedded jars delivered with npm-groovy-lint (Groovy 3.0.5) | ||
## CONTRIBUTE | ||
Contributions are very welcome ! | ||
@@ -396,3 +398,3 @@ | ||
## THANKS | ||
## Thanks | ||
@@ -414,3 +416,3 @@ ### Other packages used | ||
## RELEASE NOTES | ||
## Release notes | ||
@@ -423,3 +425,3 @@ ### [8.0.0] Unreleased | ||
- Use codenarc --ruleset arg instead of temp ruleset file | ||
- Replace super-linter by [Mega-Linter](https://github.com/nvuillam/mega-linter#readme) | ||
- Replace super-linter by [Mega-Linter](https://nvuillam.github.io/mega-linter/) | ||
- Fixes | ||
@@ -426,0 +428,0 @@ - [(#127)](https://github.com/nvuillam/npm-groovy-lint/issues/127) Formatting breaks code, converting `else if` into `elseif` in some cases |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
16829788
121
8457
0
479
29
3