diff --git a/.eslintignore b/.eslintignore new file mode 120000 index 000000000..3e4e48b0b --- /dev/null +++ b/.eslintignore @@ -0,0 +1 @@ +.gitignore \ No newline at end of file diff --git a/.eslintrc.json b/.eslintrc.json index 66fdf6f05..ef1a9910c 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 bb622eceb..d0b0b6d47 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 --stylecheck", + "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/eslint-config-base/package.json b/packages/eslint-config-base/package.json index ce1c3728f..76a308eb8 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 02ba3f1f4..f1022b273 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 4666dbdb9..80b2cf250 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 3c4f89aee..2de36f0f4 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/package.json b/packages/prettier-config/package.json index 1a478a01e..298ea6063 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 4ceea2e2b..af87c737b 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-utils/src/has-config.ts b/packages/web-scripts-utils/src/has-config.ts index c786bcb5e..4ef97e33a 100644 --- a/packages/web-scripts-utils/src/has-config.ts +++ b/packages/web-scripts-utils/src/has-config.ts @@ -50,7 +50,7 @@ export const hasConfig = ( cwd: getConsumingRoot(), }) || { packageJson: {}, path: getConsumingRoot() }; const root = pkgPath.slice(0, pkgPath.length - '/package.json'.length); - return sources.some(source => { + return sources.some((source) => { switch (source.type) { case 'file': return !!glob.sync(source.pattern, { cwd: root }).length; diff --git a/packages/web-scripts-utils/src/has-key-in-obj.ts b/packages/web-scripts-utils/src/has-key-in-obj.ts index e78cea58f..9c7aaae11 100644 --- a/packages/web-scripts-utils/src/has-key-in-obj.ts +++ b/packages/web-scripts-utils/src/has-key-in-obj.ts @@ -19,7 +19,7 @@ export const hasKeyInObj = ( ): boolean => { const [k, ...restOfK] = key.split('.'); if (restOfK.length === 0) { - return Object.keys(obj).some(ok => ok === k); + return Object.keys(obj).some((ok) => ok === k); } const nextObj = obj[k]; if (!(nextObj instanceof Object)) { diff --git a/packages/web-scripts/.eslintignore b/packages/web-scripts/.eslintignore index cba51b32f..c3ddca59a 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 9ce588ed1..6abb9e13b 100644 --- a/packages/web-scripts/package.json +++ b/packages/web-scripts/package.json @@ -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/AuditTasks/index.test.ts b/packages/web-scripts/src/Tasks/AuditTasks/index.test.ts index 35f333a93..b5ca10181 100644 --- a/packages/web-scripts/src/Tasks/AuditTasks/index.test.ts +++ b/packages/web-scripts/src/Tasks/AuditTasks/index.test.ts @@ -18,7 +18,7 @@ import { join } from 'path'; import { auditTask } from '.'; // @ts-ignore -jest.spyOn(process, 'exit').mockImplementation(c => c); +jest.spyOn(process, 'exit').mockImplementation((c) => c); jest.mock('cross-spawn-promise', () => jest.fn()); diff --git a/packages/web-scripts/src/Tasks/AuditTasks/index.ts b/packages/web-scripts/src/Tasks/AuditTasks/index.ts index ef872a2af..5077aa377 100644 --- a/packages/web-scripts/src/Tasks/AuditTasks/index.ts +++ b/packages/web-scripts/src/Tasks/AuditTasks/index.ts @@ -34,7 +34,7 @@ export async function auditTask(task: AuditTaskDesc): Promise { const fns = [yarnRun]; return await Promise.all( - fns.map(async fn => { + fns.map(async (fn) => { dbg('Beginning %s task', fn.name); const stdout = await fn(task); dbg('Finished %s task', fn.name); diff --git a/packages/web-scripts/src/Tasks/BuildTask.ts b/packages/web-scripts/src/Tasks/BuildTask.ts index 6f0092ee0..fca7be155 100644 --- a/packages/web-scripts/src/Tasks/BuildTask.ts +++ b/packages/web-scripts/src/Tasks/BuildTask.ts @@ -37,7 +37,7 @@ export async function buildTask(task: BuildTaskDesc): Promise { } return Promise.all( - fns.map(async fn => { + fns.map(async (fn) => { dbg('Beginning %s task', fn.name); const result = await fn(task); dbg('Finished %s task', fn.name); diff --git a/packages/web-scripts/src/Tasks/CommitTasks.ts b/packages/web-scripts/src/Tasks/CommitTasks.ts index 938189de3..01619d509 100644 --- a/packages/web-scripts/src/Tasks/CommitTasks.ts +++ b/packages/web-scripts/src/Tasks/CommitTasks.ts @@ -55,7 +55,7 @@ export async function precommitTask( } const results = await Promise.all( - fns.map(async fn => { + fns.map(async (fn) => { dbg('Beginning %s task', fn.name); const stdout = await fn(task); dbg('Finished %s task', fn.name); diff --git a/packages/web-scripts/src/Tasks/FormatTask/index.test.ts b/packages/web-scripts/src/Tasks/FormatTask/index.test.ts index 95a7fa06c..6a9ef2da1 100644 --- a/packages/web-scripts/src/Tasks/FormatTask/index.test.ts +++ b/packages/web-scripts/src/Tasks/FormatTask/index.test.ts @@ -30,7 +30,7 @@ const readFile = promisify(readFileFS); const mkdir = promisify(mkdirFS); // @ts-ignore -jest.spyOn(process, 'exit').mockImplementation(c => c); +jest.spyOn(process, 'exit').mockImplementation((c) => c); describe('web-scripts format', () => { let pkgRoot: string; diff --git a/packages/web-scripts/src/Tasks/FormatTask/index.ts b/packages/web-scripts/src/Tasks/FormatTask/index.ts index 4beeec672..b2d39de9c 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 68bc7ef4a..84e566dde 100644 --- a/packages/web-scripts/src/Tasks/LintTask.ts +++ b/packages/web-scripts/src/Tasks/LintTask.ts @@ -42,7 +42,7 @@ export async function lintTask(task: LintTaskDesc): Promise { if (task.stylecheck) fns.push(styleCheck); return await Promise.all( - fns.map(async fn => { + fns.map(async (fn) => { dbg('Beginning %s task', fn.name); const stdout = await fn(task); dbg('Finished %s task', fn.name); @@ -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/integration.test.ts b/packages/web-scripts/src/integration.test.ts index 79686c01a..28946a7c0 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); @@ -187,7 +179,7 @@ describe('integration tests', () => { ); await mkdir(join(PKG_ROOT, 'src')); - await fileNames.map(fileName => + await fileNames.map((fileName) => copyFile( join(THIS_ROOT, '__fixtures__', fileName), join(PKG_ROOT, 'src', fileName), diff --git a/yarn.lock b/yarn.lock index d1c1aca90..09b8ce1b2 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7965,10 +7965,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"