Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed package.json lint script #533

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
96 changes: 50 additions & 46 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,59 +1,63 @@
module.exports = {
'parser': 'babel-eslint',
'parserOptions': {
'ecmaVersion': 6,
'ecmaFeatures': {
'jsx': true,
'experimentalObjectRestSpread': true
}
parser: `@babel/eslint-parser`,
parserOptions: {
babelOptions: {
presets: [`@babel/preset-react`],
},
ecmaVersion: 6,
ecmaFeatures: {
jsx: true,
experimentalObjectRestSpread: true,
},
requireConfigFile: false,
},
plugins: ['ghost', 'react'],
plugins: [`ghost`, `react`],
extends: [
'plugin:ghost/node',
'plugin:ghost/ember',
'plugin:react/recommended'
`plugin:ghost/node`,
`plugin:ghost/ember`,
`plugin:react/recommended`,
],
"settings": {
"react": {
"createClass": "createReactClass",
"pragma": "React",
"version": "16.0",
"flowVersion": "0.53"
settings: {
react: {
createClass: `createReactClass`,
pragma: `React`,
version: `16.0`,
flowVersion: `0.53`,
},
"propWrapperFunctions": ["forbidExtraProps"]
propWrapperFunctions: [`forbidExtraProps`],
},
"rules": {
"ghost/sort-imports-es6-autofix/sort-imports-es6": "off",
"ghost/ember/use-ember-get-and-set": "off",
"no-console": "off",
"no-inner-declarations": "off",
"valid-jsdoc": "off",
"require-jsdoc": "off",
"quotes": ["error", "backtick"],
"consistent-return": ["error"],
rules: {
"ghost/sort-imports-es6-autofix/sort-imports-es6": `off`,
"ghost/ember/use-ember-get-and-set": `off`,
"no-console": `off`,
"no-inner-declarations": `off`,
"valid-jsdoc": `off`,
"require-jsdoc": `off`,
quotes: [`error`, `backtick`],
"consistent-return": [`error`],
"arrow-body-style": [
"error",
"as-needed",
{ "requireReturnForObjectLiteral": true }
`error`,
`as-needed`,
{ requireReturnForObjectLiteral: true },
],
"jsx-quotes": ["error", "prefer-double"],
"semi": ["error", "never"],
"object-curly-spacing": ["error", "always"],
"jsx-quotes": [`error`, `prefer-double`],
semi: [`error`, `never`],
"object-curly-spacing": [`error`, `always`],
"comma-dangle": [
"error",
`error`,
{
"arrays": "always-multiline",
"objects": "always-multiline",
"imports": "always-multiline",
"exports": "always-multiline",
"functions": "ignore"
}
arrays: `always-multiline`,
objects: `always-multiline`,
imports: `always-multiline`,
exports: `always-multiline`,
functions: `ignore`,
},
],
"react/prop-types": [
"error",
`error`,
{
"ignore": ["children"]
}
]
}
};
ignore: [`children`],
},
],
},
}
2 changes: 1 addition & 1 deletion gatsby-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ module.exports = {
siteMetadata: {
siteUrl: process.env.SITEURL || config.siteUrl,
},
trailingSlash: 'always',
trailingSlash: `always`,
plugins: [
/**
* Content Plugins
Expand Down
84 changes: 41 additions & 43 deletions gatsby-node.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
const path = require(`path`);
const { postsPerPage } = require(`./src/utils/siteConfig`);
const { paginate } = require(`gatsby-awesome-pagination`);
const path = require(`path`)
const { postsPerPage } = require(`./src/utils/siteConfig`)
const { paginate } = require(`gatsby-awesome-pagination`)

/**
* Here is the place where Gatsby creates the URLs for all the
* posts, tags, pages and authors that we fetched from the Ghost site.
*/
exports.createPages = async ({ graphql, actions }) => {
const { createPage } = actions;
const { createPage } = actions

const result = await graphql(`
{
Expand Down Expand Up @@ -45,79 +45,77 @@ exports.createPages = async ({ graphql, actions }) => {
}
}
}
`);
`)

// Check for any errors
if (result.errors) {
throw new Error(result.errors);
throw new Error(result.errors) // eslint-disable-line no-restricted-syntax
}

// Extract query results
const tags = result.data.allGhostTag.edges;
const authors = result.data.allGhostAuthor.edges;
const pages = result.data.allGhostPage.edges;
const posts = result.data.allGhostPost.edges;
const tags = result.data.allGhostTag.edges
const authors = result.data.allGhostAuthor.edges
const pages = result.data.allGhostPage.edges
const posts = result.data.allGhostPost.edges

// Load templates
const indexTemplate = path.resolve(`./src/templates/index.js`);
const tagsTemplate = path.resolve(`./src/templates/tag.js`);
const authorTemplate = path.resolve(`./src/templates/author.js`);
const pageTemplate = path.resolve(`./src/templates/page.js`);
const postTemplate = path.resolve(`./src/templates/post.js`);
const indexTemplate = path.resolve(`./src/templates/index.js`)
const tagsTemplate = path.resolve(`./src/templates/tag.js`)
const authorTemplate = path.resolve(`./src/templates/author.js`)
const pageTemplate = path.resolve(`./src/templates/page.js`)
const postTemplate = path.resolve(`./src/templates/post.js`)

// Create tag pages
tags.forEach(({ node }) => {
const totalPosts = node.postCount !== null ? node.postCount : 0;
const totalPosts = node.postCount !== null ? node.postCount : 0

// This part here defines, that our tag pages will use
// a `/tag/:slug/` permalink.
const url = `/tag/${node.slug}`;
const url = `/tag/${node.slug}`

const items = Array.from({ length: totalPosts });
const items = Array.from({ length: totalPosts })

// Create pagination
paginate({
createPage,
items: items,
itemsPerPage: postsPerPage,
component: tagsTemplate,
pathPrefix: ({ pageNumber }) =>
pageNumber === 0 ? url : `${url}/page`,
pathPrefix: ({ pageNumber }) => (pageNumber === 0 ? url : `${url}/page`),
context: {
slug: node.slug,
},
});
});
})
})

// Create author pages
authors.forEach(({ node }) => {
const totalPosts = node.postCount !== null ? node.postCount : 0;
const totalPosts = node.postCount !== null ? node.postCount : 0

// This part here defines, that our author pages will use
// a `/author/:slug/` permalink.
const url = `/author/${node.slug}`;
const url = `/author/${node.slug}`

const items = Array.from({ length: totalPosts });
const items = Array.from({ length: totalPosts })

// Create pagination
paginate({
createPage,
items: items,
itemsPerPage: postsPerPage,
component: authorTemplate,
pathPrefix: ({ pageNumber }) =>
pageNumber === 0 ? url : `${url}/page`,
pathPrefix: ({ pageNumber }) => (pageNumber === 0 ? url : `${url}/page`),
context: {
slug: node.slug,
},
});
});
})
})

// Create pages
pages.forEach(({ node }) => {
// This part here defines, that our pages will use
// a `/:slug/` permalink.
node.url = `/${node.slug}/`;
node.url = `/${node.slug}/`

createPage({
path: node.url,
Expand All @@ -127,14 +125,14 @@ exports.createPages = async ({ graphql, actions }) => {
// in page queries as GraphQL variables.
slug: node.slug,
},
});
});
})
})

// Create post pages
posts.forEach(({ node }) => {
// This part here defines, that our posts will use
// a `/:slug/` permalink.
node.url = `/${node.slug}/`;
node.url = `/${node.slug}/`

createPage({
path: node.url,
Expand All @@ -144,8 +142,8 @@ exports.createPages = async ({ graphql, actions }) => {
// in page queries as GraphQL variables.
slug: node.slug,
},
});
});
})
})

// Create pagination
paginate({
Expand All @@ -155,18 +153,18 @@ exports.createPages = async ({ graphql, actions }) => {
component: indexTemplate,
pathPrefix: ({ pageNumber }) => {
if (pageNumber === 0) {
return `/`;
return `/`
} else {
return `/page`;
return `/page`
}
},
});
};
})
}

exports.onCreateWebpackConfig = ({ stage, actions }) => {
exports.onCreateWebpackConfig = ({ actions }) => {
actions.setWebpackConfig({
resolve: {
fallback: { url: require.resolve("url/") },
fallback: { url: require.resolve(`url/`) },
},
});
};
})
}
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,16 @@
"build": "gatsby build",
"dev": "gatsby develop",
"lint": "eslint . --ext .js --cache",
"lint-fix": "eslint . --ext .js --cache --fix",
"develop": "gatsby develop",
"start": "gatsby serve",
"format": "prettier --write \"**/*.{js,jsx,json,md}\"",
"clean": "gatsby clean",
"test": "echo \"Error: no test specified\" && exit 1"
},
"devDependencies": {
"babel-eslint": "10.1.0",
"@babel/eslint-parser": "^7.18.9",
"@babel/preset-react": "^7.18.6",
"eslint": "8.22.0",
"eslint-plugin-ghost": "2.15.1",
"eslint-plugin-react": "7.30.1"
Expand Down
38 changes: 19 additions & 19 deletions src/components/common/Layout.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import * as React from "react";
import PropTypes from "prop-types";
import { Helmet } from "react-helmet";
import { Link, StaticQuery, graphql } from "gatsby";
import { GatsbyImage } from "gatsby-plugin-image";
import * as React from "react"
import PropTypes from "prop-types"
import { Helmet } from "react-helmet"
import { Link, StaticQuery, graphql } from "gatsby"
import { GatsbyImage } from "gatsby-plugin-image"

import { Navigation } from ".";
import config from "../../utils/siteConfig";
import { Navigation } from "."
import config from "../../utils/siteConfig"

// Styles
import "../../styles/app.css";
import "../../styles/app.css"

/**
* Main layout component
Expand All @@ -19,13 +19,13 @@ import "../../styles/app.css";
*
*/
const DefaultLayout = ({ data, children, bodyClass, isHome }) => {
const site = data.allGhostSettings.edges[0].node;
const site = data.allGhostSettings.edges[0].node
const twitterUrl = site.twitter
? `https://twitter.com/${site.twitter.replace(/^@/, ``)}`
: null;
: null
const facebookUrl = site.facebook
? `https://www.facebook.com/${site.facebook.replace(/^\//, ``)}`
: null;
: null

return <>
<Helmet>
Expand Down Expand Up @@ -145,7 +145,7 @@ const DefaultLayout = ({ data, children, bodyClass, isHome }) => {
<div className="site-foot-nav container">
<div className="site-foot-nav-left">
<Link to="/">{site.title}</Link> © 2021 &mdash;
Published with{" "}
Published with{` `}
<a
className="site-foot-nav-item"
href="https://ghost.org"
Expand All @@ -165,8 +165,8 @@ const DefaultLayout = ({ data, children, bodyClass, isHome }) => {
</footer>
</div>
</div>
</>;
};
</>
}

DefaultLayout.propTypes = {
children: PropTypes.node.isRequired,
Expand All @@ -176,9 +176,9 @@ DefaultLayout.propTypes = {
file: PropTypes.object,
allGhostSettings: PropTypes.object.isRequired,
}).isRequired,
};
}

const DefaultLayoutSettingsQuery = (props) => (
const DefaultLayoutSettingsQuery = props => (
<StaticQuery
query={graphql`query GhostSettings {
allGhostSettings {
Expand All @@ -195,8 +195,8 @@ const DefaultLayoutSettingsQuery = (props) => (
}
}
`}
render={(data) => <DefaultLayout data={data} {...props} />}
render={data => <DefaultLayout data={data} {...props} />}
/>
);
)

export default DefaultLayoutSettingsQuery;
export default DefaultLayoutSettingsQuery
Loading