From 9a285107ef044ecc3d1fad68a036d3701adc549b Mon Sep 17 00:00:00 2001 From: Louis Bompart Date: Fri, 11 Mar 2022 01:01:43 -0500 Subject: [PATCH] feat(eslint): support glob for windows (#79) Currently, the `lint` script will fail on Windows because single quotes are being used to wrap the glob. This can be easily fixed by using double quotes. Source: https://eslint.org/docs/user-guide/command-line-interface#:~:text=If%20you%20want%20to%20use%20node%20glob%20syntax%2C%20you%20have%20to%20quote%20your%20parameter%20(using%20double%20quotes%20if%20you%20need%20it%20to%20run%20in%20Windows) --- README.md | 2 +- lib/postinstall/update-package.js | 2 +- package.json | 2 +- tap-snapshots/test/postlint/check-package.js.test.cjs | 8 ++++---- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 4ab53d5a..06a244e9 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ These fields will be set in the project's `package.json`: license: 'ISC', templateVersion: $TEMPLATE_VERSION, scripts: { - lint: `eslint '**/*.js'`, + lint: 'eslint "**/*.js"', postlint: 'npm-template-check', lintfix: 'npm run lint -- --fix', 'template-copy': 'npm-template-copy --force', diff --git a/lib/postinstall/update-package.js b/lib/postinstall/update-package.js index e7b89ac9..d03efeea 100644 --- a/lib/postinstall/update-package.js +++ b/lib/postinstall/update-package.js @@ -9,7 +9,7 @@ const changes = { author: 'GitHub Inc.', files: ['bin', 'lib'], scripts: { - lint: `eslint '**/*.js'`, + lint: 'eslint "**/*.js"', postlint: 'npm-template-check', 'template-copy': 'npm-template-copy --force', lintfix: 'npm run lint -- --fix', diff --git a/package.json b/package.json index ba507709..a8075b2a 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "npm-template-copy": "bin/postinstall.js" }, "scripts": { - "lint": "eslint '**/*.js'", + "lint": "eslint \"**/*.js\"", "lintfix": "npm run lint -- --fix", "postinstall": "node bin/postinstall.js", "postlint": "npm-template-check", diff --git a/tap-snapshots/test/postlint/check-package.js.test.cjs b/tap-snapshots/test/postlint/check-package.js.test.cjs index f305198c..1fab8d8e 100644 --- a/tap-snapshots/test/postlint/check-package.js.test.cjs +++ b/tap-snapshots/test/postlint/check-package.js.test.cjs @@ -12,7 +12,7 @@ Array [ The following package.json fields are incorrect: Field: "author" Expected: "GitHub Inc." Found: "Bob" Field: "files" Expected: ["bin","lib"] Found: undefined - Field: "scripts" Expected: {"lint":"eslint '**/*.js'","postlint":"npm-template-check","template-copy":"npm-template-copy --force","lintfix":"npm run lint -- --fix","preversion":"npm test","postversion":"npm publish","prepublishOnly":"git push origin --follow-tags","snap":"tap","test":"tap","posttest":"npm run lint"} Found: undefined + Field: "scripts" Expected: {"lint":"eslint \\\\"**/*.js\\\\"","postlint":"npm-template-check","template-copy":"npm-template-copy --force","lintfix":"npm run lint -- --fix","preversion":"npm test","postversion":"npm publish","prepublishOnly":"git push origin --follow-tags","snap":"tap","test":"tap","posttest":"npm run lint"} Found: undefined Field: "engines" Expected: {"node":"^12.13.0 || ^14.15.0 || >=16"} Found: undefined ), "solution": "npm rm @npmcli/template-oss && npm i -D @npmcli/template-oss", @@ -27,7 +27,7 @@ Array [ The following package.json fields are incorrect: Field: "author" Expected: "GitHub Inc." Found: undefined Field: "files" Expected: ["bin","lib"] Found: undefined - Field: "scripts.lint" Expected: "eslint '**/*.js'" Found: undefined + Field: "scripts.lint" Expected: "eslint \\\\"**/*.js\\\\"" Found: undefined Field: "scripts.postlint" Expected: "npm-template-check" Found: undefined Field: "scripts.template-copy" Expected: "npm-template-copy --force" Found: undefined Field: "scripts.lintfix" Expected: "npm run lint -- --fix" Found: undefined @@ -51,7 +51,7 @@ Array [ The following package.json fields are incorrect: Field: "author" Expected: "GitHub Inc." Found: undefined Field: "files" Expected: ["bin","lib"] Found: undefined - Field: "scripts" Expected: {"lint":"eslint '**/*.js'","postlint":"npm-template-check","template-copy":"npm-template-copy --force","lintfix":"npm run lint -- --fix","preversion":"npm test","postversion":"npm publish","prepublishOnly":"git push origin --follow-tags","snap":"tap","test":"tap","posttest":"npm run lint"} Found: undefined + Field: "scripts" Expected: {"lint":"eslint \\\\"**/*.js\\\\"","postlint":"npm-template-check","template-copy":"npm-template-copy --force","lintfix":"npm run lint -- --fix","preversion":"npm test","postversion":"npm publish","prepublishOnly":"git push origin --follow-tags","snap":"tap","test":"tap","posttest":"npm run lint"} Found: undefined Field: "engines" Expected: {"node":"^12.13.0 || ^14.15.0 || >=16"} Found: undefined ), "solution": "npm rm @npmcli/template-oss && npm i -D @npmcli/template-oss", @@ -66,7 +66,7 @@ Array [ The following package.json fields are incorrect: Field: "author" Expected: "GitHub Inc." Found: undefined Field: "files" Expected: ["bin","lib"] Found: undefined - Field: "scripts" Expected: {"lint":"eslint '**/*.js'","postlint":"npm-template-check","template-copy":"npm-template-copy --force","lintfix":"npm run lint -- --fix","preversion":"npm test","postversion":"npm publish","prepublishOnly":"git push origin --follow-tags","snap":"tap","test":"tap","posttest":"npm run lint"} Found: undefined + Field: "scripts" Expected: {"lint":"eslint \\\\"**/*.js\\\\"","postlint":"npm-template-check","template-copy":"npm-template-copy --force","lintfix":"npm run lint -- --fix","preversion":"npm test","postversion":"npm publish","prepublishOnly":"git push origin --follow-tags","snap":"tap","test":"tap","posttest":"npm run lint"} Found: undefined Field: "engines" Expected: {"node":"^12.13.0 || ^14.15.0 || >=16"} Found: undefined ), "solution": "npm rm @npmcli/template-oss && npm i -D @npmcli/template-oss",