Skip to content

Commit 1d2804c

Browse files
committed
Initial commit: project skeleton
0 parents  commit 1d2804c

File tree

12 files changed

+419
-0
lines changed

12 files changed

+419
-0
lines changed

.eslintignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules
2+
bower_components

.eslintrc

Lines changed: 216 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,216 @@
1+
{
2+
"env": {
3+
"es6": true,
4+
"browser": true
5+
},
6+
7+
"plugins": [],
8+
9+
"ecmaFeatures": {
10+
"arrowFunctions": true,
11+
"binaryLiterals": true,
12+
"blockBindings": true,
13+
"classes": true,
14+
"defaultParams": true,
15+
"destructuring": true,
16+
"forOf": true,
17+
"generators": true,
18+
"modules": true,
19+
"objectLiteralComputedProperties": true,
20+
"objectLiteralDuplicateProperties": true,
21+
"objectLiteralShorthandMethods": true,
22+
"objectLiteralShorthandProperties": true,
23+
"octalLiterals": true,
24+
"regexUFlag": true,
25+
"regexYFlag": true,
26+
"spread": true,
27+
"superInFunctions": true,
28+
"templateStrings": true,
29+
"unicodeCodePointEscapes": true,
30+
"globalReturn": true
31+
},
32+
33+
"rules": {
34+
35+
//
36+
//Possible Errors
37+
//
38+
// The following rules point out areas where you might have made mistakes.
39+
//
40+
"comma-dangle": 2, // disallow or enforce trailing commas
41+
"no-cond-assign": 2, // disallow assignment in conditional expressions
42+
"no-console": 1, // disallow use of console (off by default in the node environment)
43+
"no-constant-condition": 2, // disallow use of constant expressions in conditions
44+
"no-control-regex": 2, // disallow control characters in regular expressions
45+
"no-debugger": 2, // disallow use of debugger
46+
"no-dupe-args": 2, // disallow duplicate arguments in functions
47+
"no-dupe-keys": 2, // disallow duplicate keys when creating object literals
48+
"no-duplicate-case": 2, // disallow a duplicate case label.
49+
"no-empty": 2, // disallow empty statements
50+
"no-empty-character-class": 2, // disallow the use of empty character classes in regular expressions
51+
"no-ex-assign": 2, // disallow assigning to the exception in a catch block
52+
"no-extra-boolean-cast": 2, // disallow double-negation boolean casts in a boolean context
53+
"no-extra-parens": 0, // disallow unnecessary parentheses (off by default)
54+
"no-extra-semi": 2, // disallow unnecessary semicolons
55+
"no-func-assign": 2, // disallow overwriting functions written as function declarations
56+
"no-inner-declarations": 2, // disallow function or variable declarations in nested blocks
57+
"no-invalid-regexp": 2, // disallow invalid regular expression strings in the RegExp constructor
58+
"no-irregular-whitespace": 2, // disallow irregular whitespace outside of strings and comments
59+
"no-negated-in-lhs": 2, // disallow negation of the left operand of an in expression
60+
"no-obj-calls": 2, // disallow the use of object properties of the global object (Math and JSON) as functions
61+
"no-regex-spaces": 2, // disallow multiple spaces in a regular expression literal
62+
"quote-props": 2, // disallow reserved words being used as object literal keys (off by default)
63+
"no-sparse-arrays": 2, // disallow sparse arrays
64+
"no-unreachable": 2, // disallow unreachable statements after a return, throw, continue, or break statement
65+
"use-isnan": 2, // disallow comparisons with the value NaN
66+
"valid-jsdoc": 2, // Ensure JSDoc comments are valid (off by default)
67+
"valid-typeof": 2, // Ensure that the results of typeof are compared against a valid string
68+
69+
//
70+
// Best Practices
71+
//
72+
// These are rules designed to prevent you from making mistakes.
73+
// They either prescribe a better way of doing something or help you avoid footguns.
74+
//
75+
"block-scoped-var": 0, // treat var statements as if they were block scoped (off by default). 0: deep destructuring is not compatible https://github.com/eslint/eslint/issues/1863
76+
"complexity": 0, // specify the maximum cyclomatic complexity allowed in a program (off by default)
77+
"consistent-return": 2, // require return statements to either always or never specify values
78+
"curly": 2, // specify curly brace conventions for all control statements
79+
"default-case": 2, // require default case in switch statements (off by default)
80+
"dot-notation": 2, // encourages use of dot notation whenever possible
81+
"eqeqeq": 2, // require the use of === and !==
82+
"guard-for-in": 2, // make sure for-in loops have an if statement (off by default)
83+
"no-alert": 2, // disallow the use of alert, confirm, and prompt
84+
"no-caller": 2, // disallow use of arguments.caller or arguments.callee
85+
"no-div-regex": 2, // disallow division operators explicitly at beginning of regular expression (off by default)
86+
"no-else-return": 2, // disallow else after a return in an if (off by default)
87+
"no-empty-label": 2, // disallow use of labels for anything other then loops and switches
88+
"no-eq-null": 2, // disallow comparisons to null without a type-checking operator (off by default)
89+
"no-eval": 2, // disallow use of eval()
90+
"no-extend-native": 2, // disallow adding to native types
91+
"no-extra-bind": 2, // disallow unnecessary function binding
92+
"no-fallthrough": 2, // disallow fallthrough of case statements
93+
"no-floating-decimal": 2, // disallow the use of leading or trailing decimal points in numeric literals (off by default)
94+
"no-implied-eval": 2, // disallow use of eval()-like methods
95+
"no-iterator": 2, // disallow usage of __iterator__ property
96+
"no-labels": 2, // disallow use of labeled statements
97+
"no-lone-blocks": 2, // disallow unnecessary nested blocks
98+
"no-loop-func": 2, // disallow creation of functions within loops
99+
"no-multi-spaces": 2, // disallow use of multiple spaces
100+
"no-multi-str": 2, // disallow use of multiline strings
101+
"no-native-reassign": 2, // disallow reassignments of native objects
102+
"no-new": 2, // disallow use of new operator when not part of the assignment or comparison
103+
"no-new-func": 2, // disallow use of new operator for Function object
104+
"no-new-wrappers": 2, // disallows creating new instances of String,Number, and Boolean
105+
"no-octal": 2, // disallow use of octal literals
106+
"no-octal-escape": 2, // disallow use of octal escape sequences in string literals, such as var foo = "Copyright \251";
107+
"no-process-env": 2, // disallow use of process.env (off by default)
108+
"no-proto": 2, // disallow usage of __proto__ property
109+
"no-redeclare": 2, // disallow declaring the same variable more then once
110+
"no-return-assign": 2, // disallow use of assignment in return statement
111+
"no-script-url": 2, // disallow use of javascript: urls.
112+
"no-self-compare": 2, // disallow comparisons where both sides are exactly the same (off by default)
113+
"no-sequences": 2, // disallow use of comma operator
114+
"no-throw-literal": 2, // restrict what can be thrown as an exception (off by default)
115+
"no-unused-expressions": 2, // disallow usage of expressions in statement position
116+
"no-void": 2, // disallow use of void operator (off by default)
117+
"no-warning-comments": [0, {"terms": ["todo", "fixme"], "location": "start"}], // disallow usage of configurable warning terms in comments": 2, // e.g. TODO or FIXME (off by default)
118+
"no-with": 2, // disallow use of the with statement
119+
"radix": 2, // require use of the second argument for parseInt() (off by default)
120+
"vars-on-top": 2, // requires to declare all vars on top of their containing scope (off by default)
121+
"wrap-iife": 2, // require immediate function invocation to be wrapped in parentheses (off by default)
122+
"yoda": 2, // require or disallow Yoda conditions
123+
124+
//
125+
// Strict Mode
126+
//
127+
// These rules relate to using strict mode.
128+
//
129+
"strict": 0, // controls location of Use Strict Directives. 0: required by `babel-eslint`
130+
131+
//
132+
// Variables
133+
//
134+
// These rules have to do with variable declarations.
135+
//
136+
"no-catch-shadow": 2, // disallow the catch clause parameter name being the same as a variable in the outer scope (off by default in the node environment)
137+
"no-delete-var": 2, // disallow deletion of variables
138+
"no-label-var": 2, // disallow labels that share a name with a variable
139+
"no-shadow": 2, // disallow declaration of variables already declared in the outer scope
140+
"no-shadow-restricted-names": 2, // disallow shadowing of names such as arguments
141+
"no-undef": 2, // disallow use of undeclared variables unless mentioned in a /*global */ block
142+
"no-undef-init": 2, // disallow use of undefined when initializing variables
143+
"no-undefined": 2, // disallow use of undefined variable (off by default)
144+
"no-unused-vars": 2, // disallow declaration of variables that are not used in the code
145+
"no-use-before-define": [2, "nofunc"], // disallow use of variables before they are defined
146+
147+
//
148+
//Stylistic Issues
149+
//
150+
// These rules are purely matters of style and are quite subjective.
151+
//
152+
"indent": [1, 2], // this option sets a specific tab width for your code (off by default)
153+
"brace-style": 1, // enforce one true brace style (off by default)
154+
"camelcase": 1, // require camel case names
155+
"comma-spacing": [1, {"before": false, "after": true}], // enforce spacing before and after comma
156+
"comma-style": [1, "last"], // enforce one true comma style (off by default)
157+
"consistent-this": [1, "_this"], // enforces consistent naming when capturing the current execution context (off by default)
158+
"eol-last": 1, // enforce newline at the end of file, with no multiple empty lines
159+
"func-names": 0, // require function expressions to have a name (off by default)
160+
"func-style": 0, // enforces use of function declarations or expressions (off by default)
161+
"key-spacing": [1, {"beforeColon": false, "afterColon": true}], // enforces spacing between keys and values in object literal properties
162+
"max-nested-callbacks": [1, 3], // specify the maximum depth callbacks can be nested (off by default)
163+
"new-cap": [1, {newIsCap: true, capIsNew: false}], // require a capital letter for constructors
164+
"new-parens": 1, // disallow the omission of parentheses when invoking a constructor with no arguments
165+
"newline-after-var": 0, // allow/disallow an empty newline after var statement (off by default)
166+
"no-array-constructor": 1, // disallow use of the Array constructor
167+
"no-lonely-if": 1, // disallow if as the only statement in an else block (off by default)
168+
"no-mixed-spaces-and-tabs": 1, // disallow mixed spaces and tabs for indentation
169+
"no-multiple-empty-lines": [1, {"max": 2}], // disallow multiple empty lines (off by default)
170+
"no-nested-ternary": 1, // disallow nested ternary expressions (off by default)
171+
"no-new-object": 1, // disallow use of the Object constructor
172+
"no-spaced-func": 1, // disallow space between function identifier and application
173+
"no-ternary": 0, // disallow the use of ternary operators (off by default)
174+
"no-trailing-spaces": 1, // disallow trailing whitespace at the end of lines
175+
"no-underscore-dangle": 1, // disallow dangling underscores in identifiers
176+
"no-extra-parens": 1, // disallow wrapping of non-IIFE statements in parens
177+
"one-var": [1, "never"], // allow just one var statement per function (off by default)
178+
"operator-assignment": [1, "never"], // require assignment operator shorthand where possible or prohibit it entirely (off by default)
179+
"quote-props": [1, "as-needed"], // require quotes around object literal property names (off by default)
180+
"quotes": [1, "single"], // specify whether double or single quotes should be used
181+
"semi": [1, "always"], // require or disallow use of semicolons instead of ASI
182+
"semi-spacing": [1, {"before": false, "after": true}], // enforce spacing before and after semicolons
183+
"sort-vars": 0, // sort variables within the same declaration block (off by default)
184+
"space-after-keywords": [1, "always"], // require a space after certain keywords (off by default)
185+
"space-before-blocks": [1, "always"], // require or disallow space before blocks (off by default)
186+
"space-before-function-paren": [1, {"anonymous": "always", "named": "never"}], // require or disallow space before function opening parenthesis (off by default)
187+
// "space-in-brackets": [1, "never"], // require or disallow spaces inside brackets (off by default)
188+
"space-in-parens": [1, "never"], // require or disallow spaces inside parentheses (off by default)
189+
"space-infix-ops": [1, {"int32Hint": false}], // require spaces around operators
190+
"space-return-throw-case": [2], // require a space after return, throw, and case
191+
"space-unary-ops": [1, {"words": true, "nonwords": false}], // Require or disallow spaces before/after unary operators (words on by default, nonwords off by default)
192+
"spaced-comment": [1, "always"], // require or disallow a space immediately following the // in a line comment (off by default)
193+
"wrap-regex": 0, // require regex literals to be wrapped in parentheses (off by default)
194+
195+
//
196+
// ECMAScript 6
197+
//
198+
// These rules are only relevant to ES6 environments and are off by default.
199+
//
200+
"no-var": 2, // require let or const instead of var (off by default)
201+
"generator-star-spacing": [2, "before"], // enforce the spacing around the * in generator functions (off by default)
202+
203+
//
204+
// Legacy
205+
//
206+
// The following rules are included for compatibility with JSHint and JSLint.
207+
// While the names of the rules may not match up with the JSHint/JSLint counterpart,
208+
// the functionality is the same.
209+
//
210+
"max-depth": [2, 3], // specify the maximum depth that blocks can be nested (off by default)
211+
"max-len": [2, 100, 2], // specify the maximum length of a line in your program (off by default)
212+
"max-params": [2, 5], // limits the number of parameters that can be used in the function declaration. (off by default)
213+
"max-statements": 0, // specify the maximum number of statement allowed in a function (off by default)
214+
"no-bitwise": 0 // disallow use of bitwise operators (off by default)
215+
}
216+
}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2015 Mohsen Azimi
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in
13+
all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.

README.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# JSON Schema from JSON
2+
3+
> JSON to JSON Schema. Convert a JSON to a JSON Schema describing that JSON
4+
5+
## Usage
6+
7+
```js
8+
import {convert} from 'json-schmea-from-json';
9+
10+
const myJson = {name: 'string'};
11+
12+
const mySchema = convert(myJson);
13+
14+
console.log(mySchema); // => {type: 'object', properties: {name: {type: 'string'}}}
15+
```
16+
17+
## Installation
18+
Use npm or Bower to install this package
19+
20+
```
21+
npm install --save json-schmea-from-json
22+
```
23+
```
24+
bower install --save json-schmea-from-json
25+
```
26+
27+
## Development
28+
To install dependencies
29+
30+
```
31+
npm install
32+
```
33+
34+
To run tests
35+
36+
```
37+
npm test
38+
```
39+
40+
To run tests continuously and watch for changes install [mocha](https://mochajs.org/) and run:
41+
42+
```
43+
mocha --compilers js:babel/register -w
44+
```
45+
46+
To make a new browser build run
47+
48+
```
49+
npm run browserify
50+
```
51+
52+
## License
53+
[MIT](./LICENSE)

bower.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"name": "json-to-json-schema",
3+
"description": "JSON to JSON Schema. Convert a JSON to a JSON Schema describing that JSON",
4+
"main": "index.js",
5+
"authors": [
6+
"Mohsen Azimi <[email protected]>"
7+
],
8+
"license": "MIT",
9+
"keywords": [
10+
"json",
11+
"schema",
12+
"json"
13+
],
14+
"moduleType": [
15+
"globals"
16+
],
17+
"homepage": "",
18+
"ignore": [
19+
"**/.*",
20+
"node_modules",
21+
"bower_components",
22+
"test",
23+
"tests"
24+
]
25+
}

dist/index.js

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"name": "json-to-json-schema",
3+
"version": "0.0.0",
4+
"description": "JSON to JSON Schema. Convert a JSON to a JSON Schema describing that JSON",
5+
"main": "index.js",
6+
"devDependencies": {
7+
"chai": "^3.3.0",
8+
"babel": "^5.8.23",
9+
"babelify": "^6.3.0",
10+
"browserify": "^11.2.0",
11+
"browserify-global-shim": "^1.0.0",
12+
"eslint": "^1.5.1",
13+
"mocha": "^2.3.3",
14+
"mocha-eslint": "^1.0.0"
15+
},
16+
"scripts": {
17+
"test": "mocha --compilers js:babel/register",
18+
"browserify": "browserify --debug src/index.js -t babelify --outfile dist/index.js",
19+
"prepublish": "npm run browserify"
20+
},
21+
"repository": {
22+
"type": "git",
23+
"url": "mohsen1/json-to-json-schema "
24+
},
25+
"keywords": [
26+
"json",
27+
"schema",
28+
"json"
29+
],
30+
"author": "Mohsen Azimi <[email protected]>",
31+
"license": "MIT"
32+
}

src/index.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
'use strict';
2+
3+
function convert (json, options = {}) {
4+
return {};
5+
}
6+
7+
export {convert};

0 commit comments

Comments
 (0)