Skip to content

Commit

Permalink
Add pre-commit hook for linting and code autoformatting. (rjsf-team#510)
Browse files Browse the repository at this point in the history
Also updated prettier options to use es5 trailing commas.
  • Loading branch information
n1k0 authored Mar 12, 2017
1 parent 3eb6dd8 commit 7206a2a
Show file tree
Hide file tree
Showing 65 changed files with 1,452 additions and 1,438 deletions.
15 changes: 13 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,25 @@
"build:lib": "rimraf lib && cross-env NODE_ENV=production babel -d lib/ src/",
"build:dist": "rimraf dist && cross-env NODE_ENV=production webpack --config webpack.config.dist.js --optimize-minimize",
"build:playground": "rimraf build && cross-env NODE_ENV=production webpack --config webpack.config.prod.js --optimize-minimize && cp playground/index.prod.html build/index.html",
"cs-check": "prettier-check --jsx-bracket-same-line '{playground,src,test}/**/*.js'",
"cs-format": "prettier --jsx-bracket-same-line '{playground,src,test}/**/*.js' --write",
"cs-check": "prettier-check $npm_package_prettierOptions '{playground,src,test}/**/*.js'",
"cs-format": "prettier $npm_package_prettierOptions '{playground,src,test}/**/*.js' --write",
"dist": "npm run build:lib && npm run build:dist",
"lint": "eslint src test playground",
"precommit": "lint-staged",
"publish-to-gh-pages": "npm run build:playground && gh-pages --dist build/",
"publish-to-npm": "npm run build:readme && npm run dist && npm publish",
"start": "node devServer.js",
"tdd": "cross-env NODE_ENV=test mocha --compilers js:babel-register --watch --require ./test/setup-jsdom.js test/**/*_test.js",
"test": " cross-env NODE_ENV=test mocha --compilers js:babel-register --require ./test/setup-jsdom.js test/**/*_test.js"
},
"prettierOptions": "--jsx-bracket-same-line --trailing-comma es5",
"lint-staged": {
"{playground,src,test}/**/*.js": [
"npm run lint",
"npm run cs-format",
"git add"
]
},
"main": "lib/index.js",
"files": [
"dist",
Expand Down Expand Up @@ -59,7 +68,9 @@
"extract-text-webpack-plugin": "^1.0.1",
"gh-pages": "^0.11.0",
"html": "0.0.10",
"husky": "^0.13.2",
"jsdom": "^8.3.0",
"lint-staged": "^3.3.1",
"mocha": "^2.5.3",
"prettier": "^0.22.0",
"prettier-check": "^1.0.0",
Expand Down
50 changes: 25 additions & 25 deletions playground/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,81 +48,81 @@ const cmOptions = {
mode: {
name: "javascript",
json: true,
statementIndent: 2
statementIndent: 2,
},
lineNumbers: true,
lineWrapping: true,
indentWithTabs: false,
tabSize: 2
tabSize: 2,
};
const themes = {
default: {
stylesheet: "//maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css"
stylesheet: "//maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css",
},
cerulean: {
stylesheet: "//cdnjs.cloudflare.com/ajax/libs/bootswatch/3.3.6/cerulean/bootstrap.min.css"
stylesheet: "//cdnjs.cloudflare.com/ajax/libs/bootswatch/3.3.6/cerulean/bootstrap.min.css",
},
cosmo: {
stylesheet: "//cdnjs.cloudflare.com/ajax/libs/bootswatch/3.3.6/cosmo/bootstrap.min.css"
stylesheet: "//cdnjs.cloudflare.com/ajax/libs/bootswatch/3.3.6/cosmo/bootstrap.min.css",
},
cyborg: {
stylesheet: "//cdnjs.cloudflare.com/ajax/libs/bootswatch/3.3.6/cyborg/bootstrap.min.css",
editor: "blackboard"
editor: "blackboard",
},
darkly: {
stylesheet: "//cdnjs.cloudflare.com/ajax/libs/bootswatch/3.3.6/darkly/bootstrap.min.css",
editor: "mbo"
editor: "mbo",
},
flatly: {
stylesheet: "//cdnjs.cloudflare.com/ajax/libs/bootswatch/3.3.6/flatly/bootstrap.min.css",
editor: "ttcn"
editor: "ttcn",
},
journal: {
stylesheet: "//cdnjs.cloudflare.com/ajax/libs/bootswatch/3.3.6/journal/bootstrap.min.css"
stylesheet: "//cdnjs.cloudflare.com/ajax/libs/bootswatch/3.3.6/journal/bootstrap.min.css",
},
lumen: {
stylesheet: "//cdnjs.cloudflare.com/ajax/libs/bootswatch/3.3.6/lumen/bootstrap.min.css"
stylesheet: "//cdnjs.cloudflare.com/ajax/libs/bootswatch/3.3.6/lumen/bootstrap.min.css",
},
paper: {
stylesheet: "//cdnjs.cloudflare.com/ajax/libs/bootswatch/3.3.6/paper/bootstrap.min.css"
stylesheet: "//cdnjs.cloudflare.com/ajax/libs/bootswatch/3.3.6/paper/bootstrap.min.css",
},
readable: {
stylesheet: "//cdnjs.cloudflare.com/ajax/libs/bootswatch/3.3.6/readable/bootstrap.min.css"
stylesheet: "//cdnjs.cloudflare.com/ajax/libs/bootswatch/3.3.6/readable/bootstrap.min.css",
},
sandstone: {
stylesheet: "//cdnjs.cloudflare.com/ajax/libs/bootswatch/3.3.6/sandstone/bootstrap.min.css",
editor: "solarized"
editor: "solarized",
},
simplex: {
stylesheet: "//cdnjs.cloudflare.com/ajax/libs/bootswatch/3.3.6/simplex/bootstrap.min.css",
editor: "ttcn"
editor: "ttcn",
},
slate: {
stylesheet: "//cdnjs.cloudflare.com/ajax/libs/bootswatch/3.3.6/slate/bootstrap.min.css",
editor: "monokai"
editor: "monokai",
},
spacelab: {
stylesheet: "//cdnjs.cloudflare.com/ajax/libs/bootswatch/3.3.6/spacelab/bootstrap.min.css"
stylesheet: "//cdnjs.cloudflare.com/ajax/libs/bootswatch/3.3.6/spacelab/bootstrap.min.css",
},
"solarized-dark": {
stylesheet: "//cdn.rawgit.com/aalpern/bootstrap-solarized/master/bootstrap-solarized-dark.css",
editor: "dracula"
editor: "dracula",
},
"solarized-light": {
stylesheet: "//cdn.rawgit.com/aalpern/bootstrap-solarized/master/bootstrap-solarized-light.css",
editor: "solarized"
editor: "solarized",
},
superhero: {
stylesheet: "//cdnjs.cloudflare.com/ajax/libs/bootswatch/3.3.6/superhero/bootstrap.min.css",
editor: "dracula"
editor: "dracula",
},
united: {
stylesheet: "//cdnjs.cloudflare.com/ajax/libs/bootswatch/3.3.6/united/bootstrap.min.css"
stylesheet: "//cdnjs.cloudflare.com/ajax/libs/bootswatch/3.3.6/united/bootstrap.min.css",
},
yeti: {
stylesheet: "//cdnjs.cloudflare.com/ajax/libs/bootswatch/3.3.6/yeti/bootstrap.min.css",
editor: "eclipse"
}
editor: "eclipse",
},
};

class GeoPosition extends Component {
Expand Down Expand Up @@ -262,7 +262,7 @@ class Selector extends Component {
function ThemeSelector({ theme, select }) {
const themeSchema = {
type: "string",
enum: Object.keys(themes)
enum: Object.keys(themes),
};
return (
<Form
Expand All @@ -287,7 +287,7 @@ class App extends Component {
validate,
editor: "default",
theme: "default",
liveValidate: true
liveValidate: true,
};
}

Expand Down Expand Up @@ -335,7 +335,7 @@ class App extends Component {
theme,
editor,
ArrayFieldTemplate,
transformErrors
transformErrors,
} = this.state;

return (
Expand Down
90 changes: 45 additions & 45 deletions playground/samples/arrays.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ module.exports = {
properties: {
name: {
type: "string",
default: "Default name"
}
}
}
default: "Default name",
},
},
},
},
type: "object",
properties: {
Expand All @@ -18,17 +18,17 @@ module.exports = {
title: "A list of strings",
items: {
type: "string",
default: "bazinga"
}
default: "bazinga",
},
},
multipleChoicesList: {
type: "array",
title: "A multiple choices list",
items: {
type: "string",
enum: ["foo", "bar", "fuzz", "qux"]
enum: ["foo", "bar", "fuzz", "qux"],
},
uniqueItems: true
uniqueItems: true,
},
fixedItemsList: {
type: "array",
Expand All @@ -37,25 +37,25 @@ module.exports = {
{
title: "A string value",
type: "string",
default: "lorem ipsum"
default: "lorem ipsum",
},
{
title: "a boolean value",
type: "boolean"
}
type: "boolean",
},
],
additionalItems: {
title: "Additional item",
type: "number"
}
type: "number",
},
},
minItemsList: {
type: "array",
title: "A list with a minimal number of items",
minItems: 3,
items: {
$ref: "#/definitions/Thing"
}
$ref: "#/definitions/Thing",
},
},
nestedList: {
type: "array",
Expand All @@ -65,33 +65,33 @@ module.exports = {
title: "Inner list",
items: {
type: "string",
default: "lorem ipsum"
}
}
default: "lorem ipsum",
},
},
},
unorderable: {
title: "Unorderable items",
type: "array",
items: {
type: "string",
default: "lorem ipsum"
}
default: "lorem ipsum",
},
},
unremovable: {
title: "Unremovable items",
type: "array",
items: {
type: "string",
default: "lorem ipsum"
}
default: "lorem ipsum",
},
},
noToolbar: {
title: "No add, remove and order buttons",
type: "array",
items: {
type: "string",
default: "lorem ipsum"
}
default: "lorem ipsum",
},
},
fixedNoToolbar: {
title: "Fixed array without buttons",
Expand All @@ -100,56 +100,56 @@ module.exports = {
{
title: "A number",
type: "number",
default: 42
default: 42,
},
{
title: "A boolean",
type: "boolean",
default: false
}
default: false,
},
],
additionalItems: {
title: "A string",
type: "string",
default: "lorem ipsum"
}
}
}
default: "lorem ipsum",
},
},
},
},
uiSchema: {
multipleChoicesList: {
"ui:widget": "checkboxes"
"ui:widget": "checkboxes",
},
fixedItemsList: {
items: [{ "ui:widget": "textarea" }, { "ui:widget": "select" }],
additionalItems: {
"ui:widget": "updown"
}
"ui:widget": "updown",
},
},
unorderable: {
"ui:options": {
orderable: false
}
orderable: false,
},
},
unremovable: {
"ui:options": {
removable: false
}
removable: false,
},
},
noToolbar: {
"ui:options": {
addable: false,
orderable: false,
removable: false
}
removable: false,
},
},
fixedNoToolbar: {
"ui:options": {
addable: false,
orderable: false,
removable: false
}
}
removable: false,
},
},
},
formData: {
listOfStrings: ["foo", "bar"],
Expand All @@ -159,6 +159,6 @@ module.exports = {
unorderable: ["one", "two"],
unremovable: ["one", "two"],
noToolbar: ["one", "two"],
fixedNoToolbar: [42, true, "additional item one", "additional item two"]
}
fixedNoToolbar: [42, true, "additional item one", "additional item two"],
},
};
14 changes: 7 additions & 7 deletions playground/samples/custom.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@ module.exports = {
required: ["lat", "lon"],
properties: {
lat: {
type: "number"
type: "number",
},
lon: {
type: "number"
}
}
type: "number",
},
},
},
uiSchema: {
"ui:field": "geo"
"ui:field": "geo",
},
formData: {
lat: 0,
lon: 0
}
lon: 0,
},
};
Loading

0 comments on commit 7206a2a

Please sign in to comment.