lint fixes for react-components
This commit is contained in:
parent
f27aacc152
commit
3503d97fae
18 changed files with 38 additions and 9 deletions
|
@ -20,6 +20,7 @@ const frontendFiles = [
|
||||||
`**/pages/**/*.${jsSuffixes}`,
|
`**/pages/**/*.${jsSuffixes}`,
|
||||||
`**/page-templates/**/*.${jsSuffixes}`,
|
`**/page-templates/**/*.${jsSuffixes}`,
|
||||||
`packages/i18n/**/*.md/*.${jsSuffixes}`,
|
`packages/i18n/**/*.md/*.${jsSuffixes}`,
|
||||||
|
`packages/react-components/**/*.${jsSuffixes}`,
|
||||||
]
|
]
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
|
|
@ -133,6 +133,9 @@ plugintest:
|
||||||
'@freesewing/plugin-sprinkle': *freesewing
|
'@freesewing/plugin-sprinkle': *freesewing
|
||||||
'@freesewing/plugin-svgattr': *freesewing
|
'@freesewing/plugin-svgattr': *freesewing
|
||||||
'@freesewing/plugin-theme': *freesewing
|
'@freesewing/plugin-theme': *freesewing
|
||||||
|
react-components:
|
||||||
|
peer:
|
||||||
|
react: '>=14'
|
||||||
rehype-jargon:
|
rehype-jargon:
|
||||||
_:
|
_:
|
||||||
'unist-util-visit': &unist-util-visit '4.1.2'
|
'unist-util-visit': &unist-util-visit '4.1.2'
|
||||||
|
|
|
@ -45,6 +45,8 @@ rehype-jargon:
|
||||||
lint: "npx eslint 'src/*.mjs'"
|
lint: "npx eslint 'src/*.mjs'"
|
||||||
snapseries:
|
snapseries:
|
||||||
lint: "npx eslint 'src/*.mjs'"
|
lint: "npx eslint 'src/*.mjs'"
|
||||||
|
react-components:
|
||||||
|
lint: "eslint 'src/**/*.mjs'"
|
||||||
|
|
||||||
# Sites go here
|
# Sites go here
|
||||||
backend:
|
backend:
|
||||||
|
|
|
@ -31,12 +31,14 @@
|
||||||
"vbuild": "VERBOSE=1 node build.mjs",
|
"vbuild": "VERBOSE=1 node build.mjs",
|
||||||
"lab": "cd ../../sites/lab && yarn start",
|
"lab": "cd ../../sites/lab && yarn start",
|
||||||
"tips": "node ../../scripts/help.mjs",
|
"tips": "node ../../scripts/help.mjs",
|
||||||
"lint": "npx eslint 'src/**' 'tests/*.mjs'",
|
"lint": "eslint 'src/**/*.mjs'",
|
||||||
"cibuild_step6": "node build.mjs",
|
"cibuild_step6": "node build.mjs",
|
||||||
"wbuild": "node build.mjs",
|
"wbuild": "node build.mjs",
|
||||||
"wcibuild_step6": "node build.mjs"
|
"wcibuild_step6": "node build.mjs"
|
||||||
},
|
},
|
||||||
"peerDependencies": {},
|
"peerDependencies": {
|
||||||
|
"react": ">=14"
|
||||||
|
},
|
||||||
"dependencies": {},
|
"dependencies": {},
|
||||||
"devDependencies": {},
|
"devDependencies": {},
|
||||||
"files": [
|
"files": [
|
||||||
|
|
|
@ -21,7 +21,7 @@ export const Svg = SvgComponent
|
||||||
export const Defs = DefsComponent
|
export const Defs = DefsComponent
|
||||||
export const Group = GroupComponent
|
export const Group = GroupComponent
|
||||||
export const Stack = StackComponent
|
export const Stack = StackComponent
|
||||||
export const Part = DefsComponent
|
export const Part = PartComponent
|
||||||
export const Point = PointComponent
|
export const Point = PointComponent
|
||||||
export const Path = PathComponent
|
export const Path = PathComponent
|
||||||
export const Snippet = SnippetComponent
|
export const Snippet = SnippetComponent
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
|
|
||||||
export const Circle = ({ point }) =>
|
export const Circle = ({ point }) =>
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
|
|
||||||
const style = ` style="fill: none; stroke: currentColor;" `
|
const style = ` style="fill: none; stroke: currentColor;" `
|
||||||
|
@ -17,6 +18,9 @@ export const Defs = (props) => {
|
||||||
if (typeof part.points.gridAnchor !== 'undefined') anchor = part.points.gridAnchor
|
if (typeof part.points.gridAnchor !== 'undefined') anchor = part.points.gridAnchor
|
||||||
else if (typeof part.points.anchor !== 'undefined') anchor = part.points.anchor
|
else if (typeof part.points.anchor !== 'undefined') anchor = part.points.anchor
|
||||||
|
|
||||||
|
if (isNaN(anchor.x)) anchor.x = 0
|
||||||
|
if (isNaN(anchor.y)) anchor.y = 0
|
||||||
|
|
||||||
defs += `<pattern id="grid-${stack}" key="grid-${stack}" xlink:href="#grid" x="${anchor.x}" y="${anchor.y}" />`
|
defs += `<pattern id="grid-${stack}" key="grid-${stack}" xlink:href="#grid" x="${anchor.x}" y="${anchor.y}" />`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
|
|
||||||
export const Grid = ({ stack, stackName }) => (
|
export const Grid = ({ stack, stackName }) => (
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
import React, { forwardRef } from 'react'
|
import React, { forwardRef } from 'react'
|
||||||
|
|
||||||
export const Group = forwardRef((props, ref) => (
|
export const Group = forwardRef((props, ref) => (
|
||||||
|
@ -5,3 +6,5 @@ export const Group = forwardRef((props, ref) => (
|
||||||
{props.children}
|
{props.children}
|
||||||
</g>
|
</g>
|
||||||
))
|
))
|
||||||
|
|
||||||
|
Group.displayName = 'Group'
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
import React, { forwardRef } from 'react'
|
import React, { forwardRef } from 'react'
|
||||||
// Components that can be swizzled
|
// Components that can be swizzled
|
||||||
import { Svg as DefaultSvg } from './svg.mjs'
|
import { Svg as DefaultSvg } from './svg.mjs'
|
||||||
|
@ -84,3 +85,5 @@ export const Pattern = forwardRef(
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Pattern.displayName = 'Pattern'
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
import React, { forwardRef } from 'react'
|
import React, { forwardRef } from 'react'
|
||||||
import { getId, getProps } from './utils.mjs'
|
import { getId, getProps } from './utils.mjs'
|
||||||
|
|
||||||
|
@ -38,6 +39,8 @@ export const PartInner = forwardRef(
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
PartInner.displayName = 'PartInner'
|
||||||
|
|
||||||
export const Part = ({ stackName, partName, part, settings, components, t }) => {
|
export const Part = ({ stackName, partName, part, settings, components, t }) => {
|
||||||
const { Group } = components
|
const { Group } = components
|
||||||
|
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import { getId, getProps } from './utils.mjs'
|
import { getId, getProps } from './utils.mjs'
|
||||||
|
|
||||||
export const Path = ({ stackName, pathName, path, partName, part, settings, components, t }) => {
|
export const Path = ({ stackName, pathName, path, partName, settings, components, t }) => {
|
||||||
// Don't render hidden paths
|
// Don't render hidden paths
|
||||||
if (path.hidden) return null
|
if (path.hidden) return null
|
||||||
|
|
||||||
// Get potentially swizzled components
|
// Get potentially swizzled components
|
||||||
const { TextOnPath } = components
|
const { TextOnPath } = components
|
||||||
|
|
||||||
const output = []
|
|
||||||
const pathId = getId({ settings, stackName, partName, pathName })
|
const pathId = getId({ settings, stackName, partName, pathName })
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -19,6 +19,4 @@ export const Path = ({ stackName, pathName, path, partName, part, settings, comp
|
||||||
) : null}
|
) : null}
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
|
|
||||||
return output
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import { withinPartBounds } from './utils.mjs'
|
import { withinPartBounds } from './utils.mjs'
|
||||||
|
|
||||||
export const Point = ({ stackName, partName, pointName, part, point, settings, components, t }) => {
|
export const Point = ({ stackName, partName, pointName, part, point, components, t }) => {
|
||||||
// Don't include points outside the part bounding box
|
// Don't include points outside the part bounding box
|
||||||
if (!withinPartBounds(point, part)) return null
|
if (!withinPartBounds(point, part)) return null
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import { getProps } from './utils.mjs'
|
import { getProps } from './utils.mjs'
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import { getProps } from './utils.mjs'
|
import { getProps } from './utils.mjs'
|
||||||
|
|
||||||
|
@ -8,7 +9,7 @@ export const Stack = ({ stackName, stack, settings, components, t }) => {
|
||||||
<Group {...getProps(stack)}>
|
<Group {...getProps(stack)}>
|
||||||
{settings[0].paperless ? <Grid {...{ stack, stackName }} /> : null}
|
{settings[0].paperless ? <Grid {...{ stack, stackName }} /> : null}
|
||||||
{[...stack.parts].map((part, key) => (
|
{[...stack.parts].map((part, key) => (
|
||||||
<Part {...{ settings, components, t, part, stackName, key }} />
|
<Part {...{ settings, components, t, part, stackName }} key={key} />
|
||||||
))}
|
))}
|
||||||
</Group>
|
</Group>
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import { forwardRef } from 'react'
|
import { forwardRef } from 'react'
|
||||||
|
|
||||||
|
@ -39,3 +40,5 @@ export const Svg = forwardRef(
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Svg.displayName = 'Svg'
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import { translateStrings } from './utils.mjs'
|
import { translateStrings } from './utils.mjs'
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
|
|
||||||
export const getProps = (obj) => {
|
export const getProps = (obj) => {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue