Skip to content

Commit

Permalink
update prettier and format SCSS files
Browse files Browse the repository at this point in the history
Co-Authored-By: Jed Fox <[email protected]>
  • Loading branch information
shiftkey and j-f1 committed Feb 1, 2018
1 parent cd52356 commit da2b417
Show file tree
Hide file tree
Showing 7 changed files with 76 additions and 16 deletions.
5 changes: 1 addition & 4 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,7 @@ rules:
###########
prettier/prettier:
- error
- singleQuote: true
trailingComma: es5
semi: false
parser: typescript
- parser: typescript
no-restricted-syntax:
- error
# no-default-export
Expand Down
14 changes: 14 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,16 @@
out/
dist/
node_modules/
npm-debug.log
yarn-error.log
app/node_modules/
.DS_Store
.awcache
.idea/
.eslintcache

app/static/common
app/test/fixtures
gemoji
*.json
*.md
4 changes: 4 additions & 0 deletions .prettierrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
singleQuote: true
trailingComma: es5
semi: false
proseWrap: always
5 changes: 1 addition & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,7 @@ install:
- yarn install --force

script:
- yarn lint
- yarn build:prod
- yarn test:setup
- yarn test
- yarn lint && yarn build:prod && yarn test:setup && yarn test

after_failure:
- yarn test:review
11 changes: 6 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,13 @@
"clean:tslint": "rimraf tslint-rules/*.js",
"compile:tslint": "tsc -p tslint-rules",
"compile:script": "tsc -p script",
"lint": "yarn compile:tslint && yarn compile:script && yarn tslint && yarn eslint-check && yarn eslint",
"lint:fix": "yarn compile:tslint && yarn tslint:fix && yarn eslint:fix",
"lint": "yarn lint:src && yarn lint:prettier",
"lint:fix": "yarn lint:src:fix && yarn lint:prettier --fix",
"lint:prettier": "ts-node script/prettier.ts",
"lint:src": "yarn tslint && yarn eslint-check && yarn eslint",
"lint:src:fix": "yarn tslint --fix && yarn eslint --fix",
"tslint": "tslint ./{script,tslint-rules}/*.ts ./app/{src,typings,test}/**/*.{ts,tsx}",
"tslint:fix": "yarn tslint --fix",
"eslint": "ts-node script/eslint.ts",
"eslint:fix": "yarn eslint --fix",
"eslint-check": "eslint --print-config .eslintrc.* | eslint-config-prettier-check",
"publish": "node script/publish",
"clean-slate": "rimraf out node_modules app/node_modules && yarn",
Expand Down Expand Up @@ -78,7 +79,7 @@
"node-sass": "^4.7.2",
"octicons": "^7.0.1",
"parallel-webpack": "^2.1.0",
"prettier": "1.10.0",
"prettier": "1.10.2",
"request": "^2.72.0",
"rimraf": "^2.5.2",
"sass-loader": "^6.0.6",
Expand Down
47 changes: 47 additions & 0 deletions script/prettier.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/usr/bin/env ts-node

import * as Path from 'path'
import chalk from 'chalk'
import { spawnSync } from 'child_process'

const shouldFix = process.argv.indexOf('--fix') > -1

const root = Path.dirname(__dirname)

const prettier = process.platform === 'win32' ? 'prettier.cmd' : 'prettier'
const prettierPath = Path.join(root, 'node_modules', '.bin', prettier)

const args = ['**/*.scss', '--list-different']

if (shouldFix) {
args.push('--write')
}

const result = spawnSync(prettierPath, args, {
cwd: root,
})

if (!shouldFix && result.status > 0) {
process.exitCode = result.status

const fileList = result.stdout.toString().trim()

if (fileList.length > 0) {
console.log('These files are not formatted correctly:\n')

console.log(result.stdout.toString())

console.error(
chalk`{bold.green → To fix these errors, run {underline yarn lint:prettier --fix}}`
)
} else {
console.log('Something went wrong with invoking prettier:')
console.log(result.stderr.toString())
}
} else if (result.status < 0) {
process.exitCode = result.status

console.log('prettier returned an unexpected exit code')
console.log(`stdout: '${result.stdout.toString()}'`)
console.log(`stderr: '${result.stderr.toString()}'`)
}
6 changes: 3 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5310,9 +5310,9 @@ preserve@^0.2.0:
version "0.2.0"
resolved "https://registry.yarnpkg.com/preserve/-/preserve-0.2.0.tgz#815ed1f6ebc65926f865b310c0713bcb3315ce4b"

[email protected].0:
version "1.10.0"
resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.10.0.tgz#0b89c9b0d55d0862d9c977e4b459696bdea564fb"
[email protected].2:
version "1.10.2"
resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.10.2.tgz#1af8356d1842276a99a5b5529c82dd9e9ad3cc93"

pretty-bytes@^1.0.2:
version "1.0.4"
Expand Down

0 comments on commit da2b417

Please sign in to comment.