Skip to content

Commit

Permalink
feat: prettier 2.0; update project to use top-level lint and format (#…
Browse files Browse the repository at this point in the history
…312)

- updating the project to use prettier 2.0

BREAKING CHANGE: prettier 2.0 may introduce breaking changes
  • Loading branch information
Paul Marbach committed Apr 28, 2020
1 parent 97bd2d6 commit d07f773
Show file tree
Hide file tree
Showing 16 changed files with 29 additions and 50 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 --stylecheck",
"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
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',
// 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__
2 changes: 1 addition & 1 deletion packages/web-scripts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
12 changes: 2 additions & 10 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 Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit d07f773

Please sign in to comment.