mirror of
https://github.com/squidfunk/mkdocs-material.git
synced 2026-08-04 11:35:17 -04:00
Fixed issues with JSX.createElement definitions
This commit is contained in:
36
lib/declarations/fastclick.js
Normal file
36
lib/declarations/fastclick.js
Normal file
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright (c) 2016-2017 Martin Donath <martin.donath@squidfunk.com>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to
|
||||
* deal in the Software without restriction, including without limitation the
|
||||
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
* sell copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
* IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
* Declarations
|
||||
* ------------------------------------------------------------------------- */
|
||||
|
||||
declare module "fastclick" {
|
||||
|
||||
/* FastClick type */
|
||||
declare type FastClick = {
|
||||
attach(name: HTMLElement): null
|
||||
}
|
||||
|
||||
/* Exports */
|
||||
declare export default FastClick
|
||||
}
|
||||
43
lib/declarations/js-cookie.js
Normal file
43
lib/declarations/js-cookie.js
Normal file
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright (c) 2016-2017 Martin Donath <martin.donath@squidfunk.com>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to
|
||||
* deal in the Software without restriction, including without limitation the
|
||||
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
* sell copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
* IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
* Declarations
|
||||
* ------------------------------------------------------------------------- */
|
||||
|
||||
declare module "js-cookie" {
|
||||
|
||||
/* Options type for setting cookie values */
|
||||
declare type Options = {
|
||||
path?: string,
|
||||
expires?: number | string
|
||||
}
|
||||
|
||||
/* Cookie type */
|
||||
declare type Cookie = {
|
||||
getJSON(json: string): Object,
|
||||
set(key: string, value: string, options?: Options): string
|
||||
}
|
||||
|
||||
/* Exports */
|
||||
declare export default Cookie
|
||||
}
|
||||
34
lib/declarations/jsx.js
Normal file
34
lib/declarations/jsx.js
Normal file
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright (c) 2016-2017 Martin Donath <martin.donath@squidfunk.com>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to
|
||||
* deal in the Software without restriction, including without limitation the
|
||||
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
* sell copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
* IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
* Declarations
|
||||
* ------------------------------------------------------------------------- */
|
||||
|
||||
declare class Jsx {
|
||||
static createElement(tag: string, properties?: Object,
|
||||
...children?: Array<string | number | Array<HTMLElement>>
|
||||
): HTMLElement
|
||||
}
|
||||
|
||||
/* Exports */
|
||||
declare export default Jsx
|
||||
32
lib/declarations/lunr.js
Normal file
32
lib/declarations/lunr.js
Normal file
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright (c) 2016-2017 Martin Donath <martin.donath@squidfunk.com>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to
|
||||
* deal in the Software without restriction, including without limitation the
|
||||
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
* sell copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
* IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
* Declarations
|
||||
* ------------------------------------------------------------------------- */
|
||||
|
||||
declare module "lunr" {
|
||||
declare class lunr {
|
||||
// TODO
|
||||
}
|
||||
declare function exports(): lunr
|
||||
}
|
||||
32
lib/declarations/modernizr.js
Normal file
32
lib/declarations/modernizr.js
Normal file
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright (c) 2016-2017 Martin Donath <martin.donath@squidfunk.com>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to
|
||||
* deal in the Software without restriction, including without limitation the
|
||||
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
* sell copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
* IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
* Declarations
|
||||
* ------------------------------------------------------------------------- */
|
||||
|
||||
declare class Modernizr {
|
||||
static addTest(name: string, test: () => boolean): null
|
||||
}
|
||||
|
||||
/* Exports */
|
||||
declare export default Modernizr
|
||||
@@ -24,13 +24,13 @@
|
||||
* Module
|
||||
* ------------------------------------------------------------------------- */
|
||||
|
||||
export default /* JSX */ {
|
||||
export default /* Jsx */ {
|
||||
|
||||
/**
|
||||
* Create a native DOM node from JSX's intermediate representation
|
||||
*
|
||||
* @param {string} tag - Tag name
|
||||
* @param {object} properties - Properties
|
||||
* @param {Object} properties - Properties // TODO: nullable, as the second...
|
||||
* @param {...(string|number|Array)} children - Child nodes
|
||||
* @return {HTMLElement} Native DOM node
|
||||
*/
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
* IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
import { transform } from "babel-core"
|
||||
import jsdoc2flow from "flow-jsdoc"
|
||||
import through from "through2"
|
||||
|
||||
@@ -37,9 +38,18 @@ export default (gulp, config) => {
|
||||
if (file.isNull() || file.isStream())
|
||||
return done()
|
||||
|
||||
/* Perform Babel transformation to resolve JSX calls */
|
||||
const transformed = transform(file.contents.toString(), {
|
||||
plugins: [
|
||||
["transform-react-jsx", {
|
||||
"pragma": "Jsx.createElement"
|
||||
}]
|
||||
]
|
||||
})
|
||||
|
||||
/* Annotate contents */
|
||||
file.contents = new Buffer(jsdoc2flow(
|
||||
`/* @flow */\n\n${file.contents.toString()}`
|
||||
`/* @flow */\n\n${transformed.code}`
|
||||
).toString())
|
||||
|
||||
/* Push file to next stage */
|
||||
|
||||
@@ -70,7 +70,7 @@ export default (gulp, config, args) => {
|
||||
|
||||
/* Provide JSX helper */
|
||||
new webpack.ProvidePlugin({
|
||||
JSX: path.join(process.cwd(), `${config.lib}/providers/jsx.js`)
|
||||
Jsx: path.join(process.cwd(), `${config.lib}/providers/jsx.js`)
|
||||
})
|
||||
].concat(
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ const format = eslint.getFormatter()
|
||||
|
||||
export default (gulp, config) => {
|
||||
return () => {
|
||||
return gulp.src(`${config.assets.src}/javascripts/**/*.js`)
|
||||
return gulp.src(`${config.assets.src}/javascripts/**/*.{js,jsx}`)
|
||||
|
||||
/* Linting */
|
||||
.pipe(
|
||||
|
||||
Reference in New Issue
Block a user