Skip to content

Commit 876bed1

Browse files
add prettier
1 parent 15973e3 commit 876bed1

File tree

142 files changed

+533
-627
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

142 files changed

+533
-627
lines changed

.eslintrc

+6-36
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
{
2+
"extends": [
3+
"prettier"
4+
],
25
"plugins": [
3-
"import"
6+
"import",
7+
"prettier"
48
],
59
"settings": {
610
"import/extensions": [".js"]
@@ -18,20 +22,9 @@
1822
"node": true
1923
},
2024
"rules": {
21-
"arrow-parens": ["error", "as-needed", { "requireForBlockBody": true }],
22-
"arrow-spacing": "error",
23-
"block-spacing": "error",
24-
"comma-dangle": ["error", "only-multiline"],
25-
"comma-spacing": ["error", { "before": false, "after": true }],
26-
"comma-style": ["error", "last"],
27-
"computed-property-spacing": ["error", "never"],
2825
"constructor-super": "error",
29-
"curly": ["error", "multi-line"],
30-
"dot-location": ["error", "property"],
3126
"dot-notation": ["error", { "allowKeywords": true }],
32-
"eol-last": "error",
3327
"eqeqeq": ["error", "smart"],
34-
"func-call-spacing": ["error", "never"],
3528
"import/default": "error",
3629
"import/export": "error",
3730
"import/first": "error",
@@ -44,9 +37,6 @@
4437
"import/no-named-as-default": "error",
4538
"import/no-named-as-default-member": "error",
4639
"import/no-unresolved": "error",
47-
"indent": ["error", 2, { "SwitchCase": 1, "MemberExpression": 1 }],
48-
"key-spacing": ["error", { "beforeColon": false, "afterColon": true }],
49-
"keyword-spacing": ["error", { "before": true, "after": true }],
5040
"linebreak-style": "error",
5141
"lines-around-comment": ["error", { "beforeBlockComment": true, "afterBlockComment": true, "allowBlockStart": true, "allowObjectStart": true, "allowArrayStart": true }],
5242
"new-parens": "error",
@@ -68,9 +58,6 @@
6858
"no-func-assign": "error",
6959
"no-invalid-regexp": "error",
7060
"no-lonely-if": "error",
71-
"no-mixed-spaces-and-tabs": ["error", false],
72-
"no-multi-spaces": "error",
73-
"no-multiple-empty-lines": ["error", { "max": 2, "maxEOF": 1 }],
7461
"no-native-reassign": "error",
7562
"no-negated-in-lhs": "error",
7663
"no-new-object": "error",
@@ -81,11 +68,9 @@
8168
"no-sequences": "error",
8269
"no-shadow": "error",
8370
"no-shadow-restricted-names": "error",
84-
"no-spaced-func": "error",
8571
"no-tabs": "error",
8672
"no-this-before-super": "error",
8773
"no-throw-literal": "error",
88-
"no-trailing-spaces": "error",
8974
"no-undef": "error",
9075
"no-unneeded-ternary": "error",
9176
"no-unreachable": "error",
@@ -99,31 +84,16 @@
9984
"no-useless-rename": "error",
10085
"no-var": "error",
10186
"no-void": "error",
102-
"no-whitespace-before-property": "error",
10387
"no-with": "error",
104-
"object-curly-spacing": ["error", "always", { "objectsInObjects": false }],
105-
"object-property-newline": ["error", { "allowMultiplePropertiesPerLine": true }],
10688
"object-shorthand": ["error", "always"],
107-
"operator-linebreak": ["error", "after", { "overrides": { "?": "ignore", ":": "ignore" }}],
108-
"padded-blocks": ["error", { "blocks": "never", "classes": "always" }],
10989
"prefer-arrow-callback": "error",
11090
"prefer-const": ["error", { "destructuring": "all", "ignoreReadBeforeAssign": true }],
11191
"prefer-rest-params": "error",
11292
"prefer-spread": "error",
11393
"prefer-template": "error",
114-
"quotes": ["error", "single", { "allowTemplateLiterals": true }],
94+
"prettier/prettier": "error",
11595
"radix": "error",
116-
"rest-spread-spacing": ["error", "never"],
117-
"semi": ["error", "never"],
118-
"space-before-blocks": "error",
119-
"space-before-function-paren": ["error", { "anonymous": "always", "named": "never" }],
120-
"space-in-parens": "error",
121-
"space-infix-ops": "error",
122-
"space-unary-ops": ["error", { "words": true, "nonwords": false }],
12396
"spaced-comment": ["error", "always", { "exceptions": ["-"]}],
124-
"template-curly-spacing": "error",
125-
"template-tag-spacing": ["error", "never"],
126-
"unicode-bom": ["error", "never"],
12797
"use-isnan": "error",
12898
"valid-jsdoc": ["error", { "prefer": { "return": "returns" }, "requireReturn": false }],
12999
"valid-typeof": "error",

.prettierignore

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
lib/
2+
node_modules/
3+
umd/
4+
.babelrc
5+
.eslintrc
6+
package.json

.prettierrc

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"singleQuote": true,
3+
"semi": false,
4+
"trailingComma": "es5"
5+
}

Changelog.md

+11-24
Original file line numberDiff line numberDiff line change
@@ -1,80 +1,67 @@
1-
21
# Changelog
32

43
This document maintains a list of changes to the `superstruct` package with each new version. Until `1.0.0` is released, breaking changes will be added as minor version bumps, and smaller changes and fixes won't be detailed.
54

6-
75
---
86

9-
107
### `0.5.0` — December 21, 2017
118

129
###### BREAKING
1310

14-
- **Validators must now return `true`, `false` or an error reason string.** Previously any truthy value would be considered valid. Now you can provide more information for the thrown errors by providing a string which will be attached as `error.reason`. However, this means that truthy string values now equate to invalid, not valid.
11+
* **Validators must now return `true`, `false` or an error reason string.** Previously any truthy value would be considered valid. Now you can provide more information for the thrown errors by providing a string which will be attached as `error.reason`. However, this means that truthy string values now equate to invalid, not valid.
1512

16-
- **Property validators now receive `data` as their second argument.** Previously you only had access to the property `value`, but now you also have access to the entire object's `data`.
13+
* **Property validators now receive `data` as their second argument.** Previously you only had access to the property `value`, but now you also have access to the entire object's `data`.
1714

1815
###### NEW
1916

20-
- **Errors can now contain reason information.** Validator functions can now return string instead of a boolean, denoting the reason a value was invalid. This can then be used to create more helpful error messages.
21-
17+
* **Errors can now contain reason information.** Validator functions can now return string instead of a boolean, denoting the reason a value was invalid. This can then be used to create more helpful error messages.
2218

2319
---
2420

25-
2621
### `0.4.0` — December 1, 2017
2722

2823
###### BREAKING
2924

30-
- **`object` structs are no longer optional-ish.** Previously object struct types would not throw if `undefined` was passed and no properties were required. This was not only confusing, but complex to maintain. Now if you want an object struct to be optional, use the `struct.optional(...)` helper.
25+
* **`object` structs are no longer optional-ish.** Previously object struct types would not throw if `undefined` was passed and no properties were required. This was not only confusing, but complex to maintain. Now if you want an object struct to be optional, use the `struct.optional(...)` helper.
3126

32-
- **Removed the `Struct.default` method.** If you need to get the default value, use the `Struct.validate` or `Struct.assert` methods's return value instead.
27+
* **Removed the `Struct.default` method.** If you need to get the default value, use the `Struct.validate` or `Struct.assert` methods's return value instead.
3328

3429
###### NEW
3530

36-
- **Added the `dict`, `enum`, `intersection`, `union` and `tuple` structs.** These are all available as `struct.dict`, `struct.enum`, etc.
37-
31+
* **Added the `dict`, `enum`, `intersection`, `union` and `tuple` structs.** These are all available as `struct.dict`, `struct.enum`, etc.
3832

3933
---
4034

41-
4235
### `0.3.0` — November 30, 2017
4336

4437
###### BREAKING
4538

46-
- **The `validate()` method now returns `[ error, result ]`.** Previously it only had a single return value, which necessitated extra type checking to see if the value was an error or a result. Now you can just destructure the array to get either return value, for easier coding.
47-
48-
- **Errors have been simplified, removing "codes".** Previously there were multiple types of errors that were thrown and you could differentiate between them with the `error.code` property. But the other properties of the error already let you infer the code, so having multiple types of errors made for a larger API surface without much benefit.
39+
* **The `validate()` method now returns `[ error, result ]`.** Previously it only had a single return value, which necessitated extra type checking to see if the value was an error or a result. Now you can just destructure the array to get either return value, for easier coding.
4940

41+
* **Errors have been simplified, removing "codes".** Previously there were multiple types of errors that were thrown and you could differentiate between them with the `error.code` property. But the other properties of the error already let you infer the code, so having multiple types of errors made for a larger API surface without much benefit.
5042

5143
---
5244

53-
5445
### `0.2.0` — November 30, 2017
5546

5647
###### BREAKING
5748

58-
- **Structs are now functions again.** :smile: They are built on the same underlying schema classes underneath though, since that helps the code structure. But to allow for the `struct = Struct({ ... })` syntax the structs themselves have changed to be function.
49+
* **Structs are now functions again.** :smile: They are built on the same underlying schema classes underneath though, since that helps the code structure. But to allow for the `struct = Struct({ ... })` syntax the structs themselves have changed to be function.
5950

6051
###### NEW
6152

62-
- **The basic case is now `Struct(data)`.** Previously you had to use `Struct.assert(data)`. Although the `assert` method (and others) are still there, the basic case is a bit terser and more similar to the struct-initializing APIs in other languages.
63-
53+
* **The basic case is now `Struct(data)`.** Previously you had to use `Struct.assert(data)`. Although the `assert` method (and others) are still there, the basic case is a bit terser and more similar to the struct-initializing APIs in other languages.
6454

6555
---
6656

67-
6857
### `0.1.0` — November 29, 2017
6958

7059
###### BREAKING
7160

72-
- **Structs are now classes instead of functions.** This is better in terms of the API being a bit less magic-y. It's also useful so that we can add other helpful methods to structs besides the `assert` method. What was previously `struct(data)` is now `struct.assert(data)`.
73-
61+
* **Structs are now classes instead of functions.** This is better in terms of the API being a bit less magic-y. It's also useful so that we can add other helpful methods to structs besides the `assert` method. What was previously `struct(data)` is now `struct.assert(data)`.
7462

7563
---
7664

77-
7865
### `0.0.0` — November 24, 2017
7966

8067
:tada:

0 commit comments

Comments
 (0)