Adding ESLint config -- run yarn lint on prebuild

This commit is contained in:
kitajchuk
2021-04-26 20:47:17 -07:00
parent 7dcb1f5a8c
commit 27e3ca561b
13 changed files with 896 additions and 22 deletions

3
.eslintignore Normal file
View File

@@ -0,0 +1,3 @@
**/node_modules/*
**/out/*
**/.next/*

42
.eslintrc.json Normal file
View File

@@ -0,0 +1,42 @@
{
"settings": {
"react": {
"version": "detect"
}
},
"env": {
"browser": true,
"es2021": true,
"node": true
},
"extends": [
"eslint:recommended",
"plugin:react/recommended"
],
"parserOptions": {
"ecmaFeatures": {
"jsx": true
},
"ecmaVersion": 12,
"sourceType": "module"
},
"plugins": [
"react"
],
"rules": {
"react/prop-types": "off",
"react/react-in-jsx-scope": "off",
"indent": [
"error",
2
],
"quotes": [
"error",
"single"
],
"semi": [
"error",
"always"
]
}
}

7
.vscode/settings.json vendored Normal file
View File

@@ -0,0 +1,7 @@
{
"editor.tabSize": 2,
"editor.detectIndentation": false,
"eslint.options": {
"configFile": ".eslintrc.json"
}
}

View File

@@ -22,6 +22,10 @@ Clone this repository and install [yarn](https://yarnpkg.com/getting-started/ins
- Installs node packages
- `yarn dev`
- Serves local dev at [localhost:3000](http://localhost:3000)
- `yarn lint`
- Runs [ESLint](https://eslint.org/) validations on source JS
- ESLint errors will fail your builds so check your code before pushing
- Install the [ESLint plugin for Visual Studio Code](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint&ssr=false#overview)
- `yarn build && yarn start`
- Create an optimized Next.js production build and serve it locally
- `yarn build && yarn export`

View File

@@ -23,13 +23,13 @@ export default function Footer({ siteData }) {
<div className="foot__navs">
<ul className="foot__links">
{siteData.footer.links.map((obj) => {
return <FooterItem key={nanoid()} obj={obj} />
return <FooterItem key={nanoid()} obj={obj} />;
})}
</ul>
<ul className="foot__links">
<FooterItem key="home" obj={siteData.navi.home} />
{siteData.navi.links.map((obj) => {
return <FooterItem key={nanoid()} obj={obj} />
return <FooterItem key={nanoid()} obj={obj} />;
})}
</ul>
</div>

View File

@@ -37,7 +37,7 @@ export function useMobileMedia() {
return function cleanup() {
mql.removeListener(handleMedia);
}
};
}, [handleMedia, setMobile]);
return mobile;

View File

@@ -3,7 +3,7 @@ import Head from 'next/head';
import Navi from './navi';
import Footer from './footer';
export default function Layout({ children, siteData, title = "jambonz" }) {
export default function Layout({ children, siteData, title = 'jambonz' }) {
return (
<>
<Head>

View File

@@ -49,12 +49,12 @@ function NaviMobile({ active, handler, siteData }) {
<ul className="navi__mobile__links">
<NaviItem key="home" obj={siteData.navi.home} />
{siteData.navi.links.map((obj) => {
return <NaviItem key={nanoid()} obj={obj} />
return <NaviItem key={nanoid()} obj={obj} />;
})}
</ul>
<ul className="navi__mobile__footer">
{siteData.footer.links.map((obj) => {
return <NaviItem key={nanoid()} obj={obj} />
return <NaviItem key={nanoid()} obj={obj} />;
})}
</ul>
<div className="navi__mobile__support">
@@ -89,7 +89,7 @@ export default function Navi({ siteData }) {
</Link>
<ul className="navi__links">
{siteData.navi.links.map((obj) => {
return <NaviItem key={nanoid()} obj={obj} />
return <NaviItem key={nanoid()} obj={obj} />;
})}
</ul>
<div className="navi__icon" onClick={handleNavi}>

View File

@@ -30,9 +30,9 @@ export function getData(key) {
*******************************************************************************/
function _getCleanSlug(slug) {
return slug
.replace(docsDir, '')
.replace(/^\/+|\/+$/, '')
.split('/');
.replace(docsDir, '')
.replace(/^\/+|\/+$/, '')
.split('/');
}
// Load Markdown and YAML front-matter to generate the static props for Next.js docs component
@@ -43,16 +43,16 @@ async function _getDocs(filePath) {
// Use remark to convert markdown into HTML string
const processedContent = await remark()
.use(remarkGfm)
.use(remarkHtml)
.process(fileMatter.content);
.use(remarkGfm)
.use(remarkHtml)
.process(fileMatter.content);
const contentHtml = processedContent.toString();
// Combine the data with the slug and contentHtml
return {
contentHtml,
frontMatter,
}
};
}
// Walk the pages/docs file tree to generate the static paths for Next.js docs pages

View File

@@ -6,8 +6,10 @@
"scripts": {
"dev": "next",
"start": "next start",
"prebuild": "yarn lint",
"build": "next build",
"export": "next export"
"export": "next export",
"lint": "eslint ./ --ext js,jsx,ts,tsx"
},
"author": "Jambonz Developers",
"license": "MIT",
@@ -23,6 +25,8 @@
"devDependencies": {
"babel-plugin-prismjs": "^2.0.1",
"env-cmd": "^10.1.0",
"eslint": "^7.25.0",
"eslint-plugin-react": "^7.23.2",
"gray-matter": "^4.0.2",
"remark": "^13.0.0",
"remark-gfm": "^1.0.0",

View File

@@ -130,7 +130,7 @@ function BYO({data}) {
</div>
<div className="byo__icons icons">
{data.icons.map((icon) => {
return <Icon key={nanoid()} name={icon} style="fill" />
return <Icon key={nanoid()} name={icon} style="fill" />;
})}
</div>
<div className="byo__comment">

View File

@@ -75,7 +75,7 @@ function Services({data}) {
return (
<div key={nanoid()} className="services__option">
<P>
<a className="i" href={`${data.url}?subject=${service.title} Support`} target="_blank">
<a className="i" href={`${data.url}?subject=${service.title} Support`} target="_blank" rel="noreferrer">
<strong>{service.title}</strong>
<Icon name="ExternalLink" />
</a>

824
yarn.lock

File diff suppressed because it is too large Load Diff