diff --git a/.eslintignore b/.eslintignore new file mode 120000 index 00000000..3e4e48b0 --- /dev/null +++ b/.eslintignore @@ -0,0 +1 @@ +.gitignore \ No newline at end of file diff --git a/.eslintrc.json b/.eslintrc.json index 66fdf6f0..ef1a9910 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,3 +1,7 @@ { - "extends": ["@spotify", "@spotify/eslint-config-oss"] + "extends": ["@spotify", "@spotify/eslint-config-oss"], + "ignorePatterns": [ + "__fixtures__", + "packages/create-web-scripts-library/template" + ] } diff --git a/package.json b/package.json index bb622ece..92c3193b 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,8 @@ "postinstall": "./postinstall.sh", "test": "lerna run test --stream", "build": "lerna run build --stream", - "lint": "lerna run lint --stream", + "lint": "web-scripts lint --no-typecheck", + "format": "web-scripts format", "commit": "web-scripts commit", "bootstrap": "lerna bootstrap --use-workspaces", "release": "./release.sh" @@ -22,7 +23,6 @@ "@spotify/eslint-config-oss": "^1.0.0", "husky": "^4.0.0", "lerna": "^3.20.2", - "prettier": "^1.18.2", "typescript": "^3.7.4" }, "husky": { diff --git a/packages/create-web-scripts-library/package.json b/packages/create-web-scripts-library/package.json index 0c4ba1f6..89ee8c2f 100644 --- a/packages/create-web-scripts-library/package.json +++ b/packages/create-web-scripts-library/package.json @@ -35,7 +35,7 @@ }, "dependencies": { "chalk": "^4.0.0", - "commander": "^4.0.1", + "commander": "^5.1.0", "execa": "^4.0.0", "fs-extra": "^9.0.0", "read-pkg-up": "^7.0.1" diff --git a/packages/eslint-config-base/package.json b/packages/eslint-config-base/package.json index ce1c3728..76a308eb 100644 --- a/packages/eslint-config-base/package.json +++ b/packages/eslint-config-base/package.json @@ -8,12 +8,8 @@ "type": "git", "url": "git+https://github.com/spotify/web-scripts.git" }, - "scripts": { - "lint": "web-scripts lint" - }, - "devDependencies": { - "@spotify/web-scripts": "^6.2.0" - }, + "scripts": {}, + "devDependencies": {}, "peerDependencies": { "eslint": ">=5.x" }, diff --git a/packages/eslint-config-react/package.json b/packages/eslint-config-react/package.json index 02ba3f1f..f1022b27 100644 --- a/packages/eslint-config-react/package.json +++ b/packages/eslint-config-react/package.json @@ -8,11 +8,8 @@ "url": "git+https://github.com/spotify/web-scripts.git" }, "main": "index.js", - "scripts": { - "lint": "web-scripts lint" - }, + "scripts": {}, "devDependencies": { - "@spotify/web-scripts": "^6.2.0", "eslint": "^6.8.0", "eslint-plugin-jsx-a11y": "^6.2.1", "eslint-plugin-react": "^7.16.0", diff --git a/packages/eslint-config-typescript/package.json b/packages/eslint-config-typescript/package.json index 4666dbdb..80b2cf25 100644 --- a/packages/eslint-config-typescript/package.json +++ b/packages/eslint-config-typescript/package.json @@ -8,11 +8,8 @@ "url": "git+https://github.com/spotify/web-scripts.git" }, "main": "index.js", - "scripts": { - "lint": "web-scripts lint" - }, + "scripts": {}, "devDependencies": { - "@spotify/web-scripts": "^6.2.0", "@typescript-eslint/eslint-plugin": "^2.14.0", "@typescript-eslint/parser": "^2.14.0", "eslint": "^6.8.0" diff --git a/packages/eslint-config/package.json b/packages/eslint-config/package.json index 3c4f89ae..2de36f0f 100644 --- a/packages/eslint-config/package.json +++ b/packages/eslint-config/package.json @@ -16,9 +16,7 @@ "bugs": { "url": "https://github.com/spotify/web-scripts/issues" }, - "scripts": { - "lint": "web-scripts lint" - }, + "scripts": {}, "dependencies": { "@spotify/eslint-config-base": "^6.2.0", "@spotify/eslint-config-react": "^6.2.0", @@ -33,7 +31,6 @@ "eslint-plugin-react-hooks": "^3.0.0" }, "devDependencies": { - "@spotify/web-scripts": "^6.2.0", "eslint": "^6.8.0" }, "peerDependencies": { diff --git a/packages/prettier-config/index.js b/packages/prettier-config/index.js index 17212206..ee195ab2 100644 --- a/packages/prettier-config/index.js +++ b/packages/prettier-config/index.js @@ -26,7 +26,7 @@ module.exports = { trailingComma: 'all', // bracketSpacing: true, // jsxBracketSameLine: false, - // arrowParens: 'avoid', + arrowParens: 'avoid', // rangeStart: 0, // rangeEnd: Infinity, // requirePragma: false, diff --git a/packages/prettier-config/package.json b/packages/prettier-config/package.json index 1a478a01..298ea606 100644 --- a/packages/prettier-config/package.json +++ b/packages/prettier-config/package.json @@ -8,15 +8,12 @@ "url": "git+https://github.com/spotify/web-scripts.git" }, "main": "index.js", - "scripts": { - "lint": "web-scripts lint" - }, + "scripts": {}, "devDependencies": { - "@spotify/web-scripts": "^6.2.0", - "prettier": "^1.18.2" + "prettier": "^2.0.5" }, "peerDependencies": { - "prettier": "1.x" + "prettier": "2.x" }, "publishConfig": { "access": "public" diff --git a/packages/tsconfig/package.json b/packages/tsconfig/package.json index 4ceea2e2..af87c737 100644 --- a/packages/tsconfig/package.json +++ b/packages/tsconfig/package.json @@ -12,11 +12,9 @@ "tsconfig.json" ], "scripts": { - "test": "./run-tests.sh", - "lint": "web-scripts lint" + "test": "./run-tests.sh" }, "devDependencies": { - "@spotify/web-scripts": "^6.2.0", "typescript": "^3.7.4" }, "peerDependencies": { diff --git a/packages/web-scripts/.eslintignore b/packages/web-scripts/.eslintignore index cba51b32..c3ddca59 100644 --- a/packages/web-scripts/.eslintignore +++ b/packages/web-scripts/.eslintignore @@ -1 +1 @@ -__fixtures__ \ No newline at end of file +__fixtures__ diff --git a/packages/web-scripts/package.json b/packages/web-scripts/package.json index 6d8c9a19..8b6c675b 100644 --- a/packages/web-scripts/package.json +++ b/packages/web-scripts/package.json @@ -24,7 +24,7 @@ "clean": "rm -rf cjs esm types", "build": "node ./bin/web-scripts build", "test": "node ./bin/web-scripts test", - "lint": "node ./bin/web-scripts lint --stylecheck", + "lint": "node ./bin/web-scripts lint", "format": "node ./bin/web-scripts format", "bootstrap": "yarn run clean && tsc --allowJs --outDir cjs --noEmit false --module CommonJS", "prepublishOnly": "yarn run bootstrap && yarn run build" @@ -41,7 +41,7 @@ "@types/jest": "^25.1.0", "@types/react": "^16.8.19", "@types/react-dom": "^16.8.4", - "commander": "^4.0.1", + "commander": "^5.1.0", "commitizen": "^4.0.3", "cross-spawn-promise": "^0.10.1", "cz-conventional-changelog": "^3.0.2", @@ -50,7 +50,7 @@ "jest": "^25.1.0", "jest-junit": "^10.0.0", "lint-staged": "^10.0.4", - "prettier": "^1.18.2", + "prettier": "^2.0.5", "semantic-release": "^17.0.1", "ts-jest": "^25.4.0", "typescript": "^3.7.4" diff --git a/packages/web-scripts/src/Tasks/FormatTask/index.ts b/packages/web-scripts/src/Tasks/FormatTask/index.ts index 4beeec67..b2d39de9 100644 --- a/packages/web-scripts/src/Tasks/FormatTask/index.ts +++ b/packages/web-scripts/src/Tasks/FormatTask/index.ts @@ -40,14 +40,14 @@ export function getPrettierConfig(): string | null { export function formatTask(task: FormatTaskDesc): SpawnSyncReturns { const cmd = 'npx'; const config = task.config || getPrettierConfig(); - const path = task.path || `${CONSUMING_ROOT}/src`; + const path = task.path || `${CONSUMING_ROOT}/**/src`; const args = [ '--no-install', 'prettier', ...(config ? ['--config', config] : []), '--write', - `${path}/**/*.[jt]s?(x)`, + `${path}/**/*.{ts,tsx,js,jsx}`, ]; dbg('npx args %o', args); return spawn.sync(cmd, args, { stdio: 'inherit' }); diff --git a/packages/web-scripts/src/Tasks/LintTask.ts b/packages/web-scripts/src/Tasks/LintTask.ts index 68bc7ef4..0833a78c 100644 --- a/packages/web-scripts/src/Tasks/LintTask.ts +++ b/packages/web-scripts/src/Tasks/LintTask.ts @@ -92,7 +92,7 @@ export async function styleCheck(): Promise { args.push('--config', config); } - args.push('--check', `${CONSUMING_ROOT}/src/**/*.[jt]s?(x)`); + args.push('--check', `${CONSUMING_ROOT}/**/src/**/*.{ts,tsx,js,jsx}`); const stdout = await spawn(cmd, args, { stdio: 'inherit' }); return (stdout || '').toString(); } diff --git a/packages/web-scripts/src/index.ts b/packages/web-scripts/src/index.ts index 93c49f80..9d97d87d 100644 --- a/packages/web-scripts/src/index.ts +++ b/packages/web-scripts/src/index.ts @@ -93,8 +93,10 @@ program .allowUnknownOption() .description('Run ESLint and TypeScript to statically analyze your code') .option('--config [path]', 'path to ESLint config') - .option('--typecheck', 'run a TypeScript type check') - .option('--stylecheck', "run Prettier's style check") + .option('--typecheck', 'run a TypeScript type check', true) + .option('--no-typecheck', 'do not run a TypeScript type check') + .option('--stylecheck', "run Prettier's style check", true) + .option('--no-stylecheck', "do not run Prettier's style check") .action((...args) => { const cmd = getCommand(args); const rest = getPositionalArgs(args); diff --git a/packages/web-scripts/src/integration.test.ts b/packages/web-scripts/src/integration.test.ts index 83004a85..ce11d396 100644 --- a/packages/web-scripts/src/integration.test.ts +++ b/packages/web-scripts/src/integration.test.ts @@ -43,16 +43,8 @@ const copyFile = promisify(copyFileFS); // log output after the command finishes const exec = async (cmd: string, options?: object) => { function _log(resp: { stdout?: string | Buffer; stderr?: string | Buffer }) { - if (resp.stdout) - resp.stdout - .toString() - .split('\n') - .forEach(dbg); - if (resp.stderr) - resp.stderr - .toString() - .split('\n') - .forEach(dbg); + if (resp.stdout) resp.stdout.toString().split('\n').forEach(dbg); + if (resp.stderr) resp.stderr.toString().split('\n').forEach(dbg); } try { const resp = await execPromise(cmd, options); @@ -76,14 +68,17 @@ describe('integration tests', () => { }); describe('help', () => { - test('The CLI offers help when invoked with no arguments', async () => { - const result = await exec(`${CLI}`); - expect(result.stdout).toMatch('Usage: web-scripts [options] [command]'); + const USAGE_MATCH = 'Usage: web-scripts [options] [command]'; + + test('The CLI fails and offers help when invoked with no arguments', async () => { + await expect(exec(`${CLI}`)).rejects.toMatchObject({ + stdout: expect.stringContaining(USAGE_MATCH), + }); }); test('The CLI offers help when invoked with --help flag', async () => { const result = await exec(`${CLI} --help`); - expect(result.stdout).toMatch('Usage: web-scripts [options] [command]'); + expect(result.stdout).toMatch(USAGE_MATCH); }); }); @@ -99,7 +94,7 @@ describe('integration tests', () => { test( 'Full integration test', - async () => await testScripts([], ['--typecheck', '--stylecheck']), + async () => await testScripts(), TEST_SCRIPTS_TIMEOUT, ); }); @@ -116,7 +111,7 @@ describe('integration tests', () => { test( 'Full integration test', - async () => await testScripts(['--no-types']), + async () => await testScripts(['--no-types'], ['--no-typecheck']), TEST_SCRIPTS_TIMEOUT, ); }); diff --git a/yarn.lock b/yarn.lock index aa360f55..172d6204 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1869,7 +1869,7 @@ regexpp "^3.0.0" tsutils "^3.17.1" -"@typescript-eslint/experimental-utils@2.30.0", "@typescript-eslint/experimental-utils@^2.5.0": +"@typescript-eslint/experimental-utils@2.30.0": version "2.30.0" resolved "https://registry.yarnpkg.com/@typescript-eslint/experimental-utils/-/experimental-utils-2.30.0.tgz#9845e868c01f3aed66472c561d4b6bac44809dd0" integrity sha512-L3/tS9t+hAHksy8xuorhOzhdefN0ERPDWmR9CclsIGOUqGKy6tqc/P+SoXeJRye5gazkuPO0cK9MQRnolykzkA== @@ -1879,6 +1879,16 @@ eslint-scope "^5.0.0" eslint-utils "^2.0.0" +"@typescript-eslint/experimental-utils@^2.5.0": + version "2.29.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/experimental-utils/-/experimental-utils-2.29.0.tgz#3cb8060de9265ba131625a96bbfec31ba6d4a0fe" + integrity sha512-H/6VJr6eWYstyqjWXBP2Nn1hQJyvJoFdDtsHxGiD+lEP7piGnGpb/ZQd+z1ZSB1F7dN+WsxUDh8+S4LwI+f3jw== + dependencies: + "@types/json-schema" "^7.0.3" + "@typescript-eslint/typescript-estree" "2.29.0" + eslint-scope "^5.0.0" + eslint-utils "^2.0.0" + "@typescript-eslint/parser@^2.14.0": version "2.30.0" resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-2.30.0.tgz#7681c305a6f4341ae2579f5e3a75846c29eee9ce" @@ -1889,6 +1899,19 @@ "@typescript-eslint/typescript-estree" "2.30.0" eslint-visitor-keys "^1.1.0" +"@typescript-eslint/typescript-estree@2.29.0": + version "2.29.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-2.29.0.tgz#1be6612bb02fc37ac9f466521c1459a4744e8d3a" + integrity sha512-3YGbtnWy4az16Egy5Fj5CckkVlpIh0MADtAQza+jiMADRSKkjdpzZp/5WuvwK/Qib3Z0HtzrDFeWanS99dNhnA== + dependencies: + debug "^4.1.1" + eslint-visitor-keys "^1.1.0" + glob "^7.1.6" + is-glob "^4.0.1" + lodash "^4.17.15" + semver "^6.3.0" + tsutils "^3.17.1" + "@typescript-eslint/typescript-estree@2.30.0": version "2.30.0" resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-2.30.0.tgz#1b8e848b55144270255ffbfe4c63291f8f766615" @@ -2900,16 +2923,16 @@ commander@^2.11.0, commander@~2.20.3: resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.3.tgz#fd485e84c03eb4881c20722ba48035e8531aeb33" integrity sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ== -commander@^4.0.1: - version "4.1.1" - resolved "https://registry.yarnpkg.com/commander/-/commander-4.1.1.tgz#9fd602bd936294e9e9ef46a3f4d6964044b18068" - integrity sha512-NOKm8xhkzAjzFx8B2v5OAHT+u5pRQc2UCa2Vq9jYL/31o2wi9mxBA7LIFs3sV5VSC49z6pEhfbMULvShKj26WA== - commander@^5.0.0: version "5.0.0" resolved "https://registry.yarnpkg.com/commander/-/commander-5.0.0.tgz#dbf1909b49e5044f8fdaf0adc809f0c0722bdfd0" integrity sha512-JrDGPAKjMGSP1G0DUoaceEJ3DZgAfr/q6X7FVk4+U5KxUSKviYGM2k6zWkfyyBHy5rAtzgYJFa1ro2O9PtoxwQ== +commander@^5.1.0: + version "5.1.0" + resolved "https://registry.yarnpkg.com/commander/-/commander-5.1.0.tgz#46abbd1652f8e059bddaef99bbdcb2ad9cf179ae" + integrity sha512-P0CysNDQ7rtVw4QIQtm+MRxV66vKFSvlsQvGYXZWR3qFU0jlMKHZZZgw8e+8DSah4UDKMqnknRDQz+xuQXQ/Zg== + commitizen@^4.0.3: version "4.0.4" resolved "https://registry.yarnpkg.com/commitizen/-/commitizen-4.0.4.tgz#60e9666e293269f459f1038ca452b39acecb8999" @@ -7955,10 +7978,10 @@ prepend-http@^1.0.1: resolved "https://registry.yarnpkg.com/prepend-http/-/prepend-http-1.0.4.tgz#d4f4562b0ce3696e41ac52d0e002e57a635dc6dc" integrity sha1-1PRWKwzjaW5BrFLQ4ALlemNdxtw= -prettier@^1.18.2: - version "1.19.1" - resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.19.1.tgz#f7d7f5ff8a9cd872a7be4ca142095956a60797cb" - integrity sha512-s7PoyDv/II1ObgQunCbB9PdLmUcBZcnWOcxDh7O0N/UwDEsHyqkW+Qh28jW+mVuCdx7gLB0BotYI1Y6uI9iyew== +prettier@^2.0.5: + version "2.0.5" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.0.5.tgz#d6d56282455243f2f92cc1716692c08aa31522d4" + integrity sha512-7PtVymN48hGcO4fGjybyBSIWDsLU4H4XlvOHfq91pz9kkGlonzwTfYkaIEwiRg/dAJF9YlbsduBAgtYLi+8cFg== pretty-format@^24.9.0: version "24.9.0"