Skip to content

Commit ce64163

Browse files
gdolleazu
authored andcommitted
Parser refactor (#43)
* rename and add new examples per template * Remove unrequired plugin Not required in fact. `gitbook-plugin-ace` is required only if user pass "ace" or "acefull" to the template option. It is specified in the README.md. * Update readme * Add check plugin load order - Add winston-color for color logs - produce a warning if gitbook-plugin-ace is not loaded (ace template won't work) - produce an error if gitbook-plugin-ace is loaded but before include-codeblock * update log message * update travis tests * Fix Readme * use path package * separate ace check * Improve example * Improve custom example * Improve default example * Refactor parser - Should be cleaner and less error prone - Define global book option map, and possible key-value map (same as in readme). - Use immutable Map to avoid unwanted changes. - Pass `template`, `unindent` function arguments into the key-value map directly for consistency. - Systemize key-value argument for each functions. * Add inline code remark - include-codeblock does not work if we use it inline. for example: ``` blabla [import](fixtures/test.js) blablabla ``` NB: we might have some works to add newline before and after block. * Update tests * Remove log * up package version * Add multi snippets feature * Update test using templates from map * Add support equal char for * Fix template quotes + up version 3.1.0 major - It seems ace does work with boolean instead of strings for booleans type keys. - Update version 3.1.0, changes will be major * Update readme * Rename options to avoid confusion * Separate options maps Options can be set globally or locally: - Set an immutable default map book.json global plugin options - Set an immutable default key-value map for local command options. - Add functions to check map types * Clean option file * Move convertValue * Refactor parser - Refactor parseVariableFromCommand regex to be more comprehensible. - Handle boolean type - Add parse check depending on the value type and convert the parsed value to its type (JSON.parse) - Fix type check. Default l/g options map should not have `undefined` value as value type is deduced from the map. * Update marker check with empty string - Update check for empty string which is not valid. * Update package options - Add default value options in package.json directly. Options map are updated from it. - Fix package default type to be consistent (avoid string). Now boolean is `true` and not `"true"`. * Revert options get * Update + new test - Update parse tests to handle better tests (simpler & different case). - Add test for multiple markers * Refactor lang key break backward compatibility - set hardcode lang as book option, or command option. - Remove `lang-javascript` and use standard key-val format `lang:"javascript"` or `lang:".js"`. If lang or extension (via lang) is not set, then lang is determined rom file extension. - Create template.js file for template specific codes. * Add support of URL (sync) issue #42 - Perform http GET request and retrieve url body. - Asynchronous http (module sync-request) with caching, gzip - Redirection not allowed. NB: Future optimization could be to provide async operation for the plugin. * Update readme * Update readme * Remove immutable.js - Remove immutable package - Remove Map object to use frozen Object instead (guaranty unmodified default map object). - Update tests. * Remove parser feature - Remove URL parser source code (different branch + need update async) - Remove URL parser test - Remove package.json dependencies * Add Eslint config #39 + fix coding style See issue #39 - Use this convention https://github.com/textlint/textlint/blob/master/.eslintrc.js - Change Error to Warn for unused vars and allow console logs. - Add new package script : check => run eslint for javascript files in src/ and test/. (Do not add test/fixtures, test/patterns, ...). - Add travis eslint check. * add eslint config * Update reviewed code
1 parent eda1d7a commit ce64163

File tree

73 files changed

+1119
-496
lines changed

Some content is hidden

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

73 files changed

+1119
-496
lines changed

.eslintrc.js

Lines changed: 233 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,233 @@
1+
module.exports = {
2+
"env": {
3+
"browser": true,
4+
"commonjs": true,
5+
"node": true,
6+
"es6": true,
7+
"mocha": true
8+
},
9+
"extends": "eslint:recommended",
10+
"parserOptions": {
11+
"sourceType": "module"
12+
},
13+
"rules": {
14+
"accessor-pairs": "error",
15+
"array-bracket-spacing": [
16+
"error",
17+
"never"
18+
],
19+
"array-callback-return": "error",
20+
"arrow-body-style": "off",
21+
"arrow-parens": "off",
22+
"arrow-spacing": [
23+
"error",
24+
{
25+
"after": true,
26+
"before": true
27+
}
28+
],
29+
"block-scoped-var": "error",
30+
"block-spacing": "error",
31+
"brace-style": [
32+
"error",
33+
"1tbs"
34+
],
35+
"callback-return": "off",
36+
"camelcase": "error",
37+
"comma-spacing": "off",
38+
"comma-style": [
39+
"error",
40+
"last"
41+
],
42+
"complexity": "error",
43+
"computed-property-spacing": [
44+
"error",
45+
"never"
46+
],
47+
"consistent-return": "off",
48+
"consistent-this": "error",
49+
"curly": "error",
50+
"default-case": "error",
51+
"dot-location": [
52+
"error",
53+
"property"
54+
],
55+
"dot-notation": "error",
56+
"eol-last": "off",
57+
"func-names": "off",
58+
"func-style": [
59+
"error",
60+
"declaration",
61+
{
62+
"allowArrowFunctions": true
63+
}
64+
],
65+
"generator-star-spacing": "error",
66+
"global-require": "off",
67+
"guard-for-in": "error",
68+
"handle-callback-err": "error",
69+
"id-blacklist": "error",
70+
"id-length": "off",
71+
"id-match": "error",
72+
"indent": "off",
73+
"init-declarations": "off",
74+
"jsx-quotes": "error",
75+
"key-spacing": "off",
76+
"keyword-spacing": "off",
77+
"linebreak-style": [
78+
"error",
79+
"unix"
80+
],
81+
"lines-around-comment": "off",
82+
"max-depth": "error",
83+
"max-len": "off",
84+
"max-nested-callbacks": "error",
85+
"max-params": "off",
86+
"max-statements": "off",
87+
"new-parens": "error",
88+
"newline-after-var": "off",
89+
"newline-before-return": "off",
90+
"newline-per-chained-call": "off",
91+
"no-alert": "error",
92+
"no-array-constructor": "error",
93+
"no-bitwise": "error",
94+
"no-caller": "error",
95+
"no-catch-shadow": "error",
96+
"no-confusing-arrow": "error",
97+
"no-continue": "error",
98+
"no-console": "off",
99+
"no-div-regex": "error",
100+
"no-else-return": "off",
101+
"no-empty-function": "error",
102+
"no-eq-null": "off",
103+
"no-eval": "error",
104+
"no-extend-native": "error",
105+
"no-extra-bind": "error",
106+
"no-extra-label": "error",
107+
"no-extra-parens": "off",
108+
"no-floating-decimal": "error",
109+
"no-implicit-coercion": "error",
110+
"no-implicit-globals": "error",
111+
"no-implied-eval": "error",
112+
"no-inline-comments": "off",
113+
"no-inner-declarations": [
114+
"error",
115+
"functions"
116+
],
117+
"no-invalid-this": "error",
118+
"no-iterator": "error",
119+
"no-label-var": "error",
120+
"no-labels": "error",
121+
"no-lone-blocks": "error",
122+
"no-lonely-if": "off",
123+
"no-loop-func": "error",
124+
"no-magic-numbers": "off",
125+
"no-mixed-requires": "error",
126+
"no-multi-spaces": "error",
127+
"no-multi-str": "error",
128+
"no-multiple-empty-lines": "off",
129+
"no-native-reassign": "error",
130+
"no-negated-condition": "off",
131+
"no-nested-ternary": "error",
132+
"no-new": "error",
133+
"no-new-func": "error",
134+
"no-new-object": "error",
135+
"no-new-require": "error",
136+
"no-new-wrappers": "error",
137+
"no-octal-escape": "error",
138+
"no-param-reassign": "off",
139+
"no-path-concat": "error",
140+
"no-plusplus": "off",
141+
"no-process-env": "off",
142+
"no-process-exit": "error",
143+
"no-proto": "error",
144+
"no-restricted-globals": "error",
145+
"no-restricted-imports": "error",
146+
"no-restricted-modules": "error",
147+
"no-restricted-syntax": "error",
148+
"no-return-assign": "error",
149+
"no-script-url": "error",
150+
"no-self-compare": "error",
151+
"no-sequences": "error",
152+
"no-shadow": "off",
153+
"no-shadow-restricted-names": "error",
154+
"no-spaced-func": "error",
155+
"no-sync": "off",
156+
"no-ternary": "off",
157+
"no-throw-literal": "error",
158+
"no-trailing-spaces": "off",
159+
"no-undef-init": "error",
160+
"no-undefined": "off",
161+
"no-underscore-dangle": "off",
162+
"no-unmodified-loop-condition": "error",
163+
"no-unneeded-ternary": "error",
164+
"no-unused-expressions": "error",
165+
"no-unused-vars" : "warn",
166+
"no-use-before-define": "error",
167+
"no-useless-call": "error",
168+
"no-useless-concat": "error",
169+
"no-useless-constructor": "error",
170+
"no-var": "off",
171+
"no-void": "error",
172+
"no-warning-comments": "off",
173+
"no-whitespace-before-property": "error",
174+
"no-with": "error",
175+
"object-curly-spacing": "off",
176+
"object-shorthand": "off",
177+
"one-var": "off",
178+
"one-var-declaration-per-line": "error",
179+
"operator-assignment": [
180+
"error",
181+
"always"
182+
],
183+
"operator-linebreak": "error",
184+
"padded-blocks": "off",
185+
"prefer-arrow-callback": "off",
186+
"prefer-const": "error",
187+
"prefer-reflect": "off",
188+
"prefer-rest-params": "off",
189+
"prefer-spread": "off",
190+
"prefer-template": "off",
191+
"quote-props": "off",
192+
"quotes": [
193+
"error",
194+
"double"
195+
],
196+
"radix": "error",
197+
"require-jsdoc": "off",
198+
"require-yield": "error",
199+
"semi": "error",
200+
"semi-spacing": [
201+
"error",
202+
{
203+
"after": true,
204+
"before": false
205+
}
206+
],
207+
"sort-imports": "off",
208+
"sort-vars": "error",
209+
"space-before-blocks": "off",
210+
"space-before-function-paren": "off",
211+
"space-in-parens": [
212+
"error",
213+
"never"
214+
],
215+
"space-infix-ops": "error",
216+
"space-unary-ops": "error",
217+
"spaced-comment": [
218+
"error",
219+
"always"
220+
],
221+
"strict": "off",
222+
"template-curly-spacing": "off",
223+
"valid-jsdoc": "off",
224+
"vars-on-top": "off",
225+
"wrap-iife": "error",
226+
"wrap-regex": "error",
227+
"yield-star-spacing": "error",
228+
"yoda": [
229+
"error",
230+
"never"
231+
]
232+
}
233+
};

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ sudo: false
22
language: node_js
33
node_js: "stable"
44
script:
5+
- npm run check
56
- npm test
67
- npm run test:example-default
78
- npm run test:example-ace

0 commit comments

Comments
 (0)