Skip to content

Commit

Permalink
major release- 7.0.0 (#318)
Browse files Browse the repository at this point in the history
* build(web-scripts): use commander 5 (#314)

BREAKING CHANGE: running web-scripts without arguments exits code 1 now instead of exiting 0

* feat: prettier 2.0; update project to use top-level lint and format (#312)

- updating the project to use prettier 2.0

BREAKING CHANGE: prettier 2.0 may introduce breaking changes

* improvement(web-scripts): make stylecheck and typecheck default for lint (#310)

* feat: prettier 2.0; update project to use top-level lint and format

- updating the project to use prettier 2.0

BREAKING CHANGE: prettier 2.0 may introduce breaking changes

* improvement(web-scripts): make stylecheck and typecheck default for lint

the lint script will now default typechecking and stylechecking to true by default. You may shut
these off with `--no-typecheck` and `--no-stylecheck`.

BREAKING CHANGE: Users who have projects incompatible with TypeScript checks or with projects that
do not user prettier will now fail yarn lint.
  • Loading branch information
Paul Marbach committed Apr 28, 2020
1 parent 47640ce commit 29509b4
Show file tree
Hide file tree
Showing 18 changed files with 74 additions and 67 deletions.
1 change: 1 addition & 0 deletions .eslintignore
6 changes: 5 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
{
"extends": ["@spotify", "@spotify/eslint-config-oss"]
"extends": ["@spotify", "@spotify/eslint-config-oss"],
"ignorePatterns": [
"__fixtures__",
"packages/create-web-scripts-library/template"
]
}
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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": {
Expand Down
2 changes: 1 addition & 1 deletion packages/create-web-scripts-library/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
8 changes: 2 additions & 6 deletions packages/eslint-config-base/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
5 changes: 1 addition & 4 deletions packages/eslint-config-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
5 changes: 1 addition & 4 deletions packages/eslint-config-typescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
5 changes: 1 addition & 4 deletions packages/eslint-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -33,7 +31,6 @@
"eslint-plugin-react-hooks": "^3.0.0"
},
"devDependencies": {
"@spotify/web-scripts": "^6.2.0",
"eslint": "^6.8.0"
},
"peerDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/prettier-config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ module.exports = {
trailingComma: 'all',
// bracketSpacing: true,
// jsxBracketSameLine: false,
// arrowParens: 'avoid',
arrowParens: 'avoid',

This comment has been minimized.

Copy link
@keikraft

keikraft May 13, 2020

Hey there! We use @spotify/prettier-config as our prettier base config in our project, we recently upgraded it to 7.0.0 and got lot of lint errors because of the arrow parenthesis. We were wondering on our team what was the motivation of overriding prettier default. We think they had a good point on making arrowParens: 'always' the default, but would like to know your opinion :)

// rangeStart: 0,
// rangeEnd: Infinity,
// requirePragma: false,
Expand Down
9 changes: 3 additions & 6 deletions packages/prettier-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 1 addition & 3 deletions packages/tsconfig/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
2 changes: 1 addition & 1 deletion packages/web-scripts/.eslintignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__fixtures__
__fixtures__
6 changes: 3 additions & 3 deletions packages/web-scripts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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",
Expand All @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions packages/web-scripts/src/Tasks/FormatTask/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ export function getPrettierConfig(): string | null {
export function formatTask(task: FormatTaskDesc): SpawnSyncReturns<Buffer> {
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' });
Expand Down
2 changes: 1 addition & 1 deletion packages/web-scripts/src/Tasks/LintTask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export async function styleCheck(): Promise<string> {
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();
}
6 changes: 4 additions & 2 deletions packages/web-scripts/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
27 changes: 11 additions & 16 deletions packages/web-scripts/src/integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
});
});

Expand All @@ -99,7 +94,7 @@ describe('integration tests', () => {

test(
'Full integration test',
async () => await testScripts([], ['--typecheck', '--stylecheck']),
async () => await testScripts(),
TEST_SCRIPTS_TIMEOUT,
);
});
Expand All @@ -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,
);
});
Expand Down
43 changes: 33 additions & 10 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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==
Expand All @@ -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"
Expand All @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit 29509b4

Please sign in to comment.