Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
dd18987
chore: Eslint / Prettier integration.
Mar 2, 2019
793f15e
chore: Change ext order to overwrite eslint rules
Aug 23, 2019
7b44e37
chore: Add build to gitignore
Aug 23, 2019
b7d3161
chore: Eslint fixes after config change
Aug 23, 2019
22be1df
chore: Update yarn.lock after rebase
jonchurch Sep 9, 2019
66a6b07
chore: Add eslint-plugin-jest and extend w/ reccs
jonchurch Sep 9, 2019
71c218b
chore: Disable no-var-requires for .js files
jonchurch Sep 9, 2019
b4457ae
chore: Remove format-check from test script
jonchurch Sep 9, 2019
6a90367
chore: Fix eslint errors in js files
jonchurch Sep 9, 2019
c69d6bb
chore: Update husky pre-push to use lint script
jonchurch Sep 9, 2019
e2aca13
chore: Create new .eslintrc config
jonchurch Sep 13, 2019
6d327de
chore: Update lint script, add react settings to eslint config
jonchurch Sep 14, 2019
bfc83bb
chore: Ignore test dir when running lint script
jonchurch Sep 14, 2019
c964c35
chore: Add airbnb config and jest env to eslintrc
jonchurch Sep 14, 2019
6425206
chore: Disable react/jsx-filename-extension
jonchurch Sep 14, 2019
95b0836
chore: Recover .prettierrc config file that was deleted
jonchurch Sep 14, 2019
5ad42fd
chore: Extend eslint config with prettier/react
jonchurch Sep 14, 2019
8648621
chore: Fix all but a few eslint errors
jonchurch Sep 14, 2019
35e7478
Merge branch 'staging' into linter-prettier-integration
jonchurch Sep 14, 2019
7008ba1
chore: Update eslint-plugin-prettier
jonchurch Sep 14, 2019
afceb5a
chore: Disable prefer-default-exports rule
jonchurch Sep 14, 2019
2137808
chore: Fix eslint errors after merging with staging
jonchurch Sep 14, 2019
53ebbe1
Merge branch 'staging' of https://github.com/nodejs/nodejs.dev into l…
jonchurch Sep 14, 2019
08ff956
chore: Fix eslint errors in konami code
jonchurch Sep 14, 2019
91cb01c
chore: Disable import/extensions and consistent-return rules
jonchurch Sep 14, 2019
fe88889
chore: Set return type for setPage hook in click handler to void
jonchurch Sep 14, 2019
0db99e8
fix: Clean up some errors after all the merge fixing
jonchurch Sep 14, 2019
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
56 changes: 56 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
module.exports = {
parser: "@typescript-eslint/parser",
parserOptions: {
ecmaFeatures: {
jsx: true
}
// project: './tsconfig.json'
},
extends: [
"airbnb",
"plugin:react/recommended",
"plugin:@typescript-eslint/recommended",
"prettier/@typescript-eslint",
"prettier/react",
"plugin:prettier/recommended"
],
settings: {
react: {
version: "detect"
},
"import/resolver": {
typescript: {}
}
},
env: {
browser: true,
node: true,
jest: true
},
rules: {
"react/jsx-filename-extension": "off",
"react-hooks/rules-of-hooks": "error",
"react-hooks/exhaustive-deps": "warn",
"import/prefer-default-export": "off",
"import/extensions": "off",
"consistent-return": "off",
// "camelcase": "off",
// "@typescript-eslint/camelcase": ["error", { "properties": "never" }],
// "no-unused-vars": "off",
// "@typescript-eslint/no-unused-vars": "error",
// "@typescript-eslint/indent": ["error", 2]
},
plugins: [
"@typescript-eslint",
"react-hooks"
// "prettier"
],
overrides: [
{
files: ["**/*.js"],
rules: {
"@typescript-eslint/no-var-requires": "off"
}
}
]
};
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ package-lock.json
# Build directory
/public
.DS_Store
build

.env
.firebase/*
Expand Down
20 changes: 10 additions & 10 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"printWidth": 80,
"tabWidth": 2,
"useTabs": false,
"semi": true,
"singleQuote": true,
"jsxSingleQuote": false,
"trailingComma": "es5",
"bracketSpacing": true,
"jsxBracketSameLine": false,
"arrowParens": "avoid"
printWidth: 80,
tabWidth: 2,
useTabs: false,
semi: true,
singleQuote: true,
jsxSingleQuote: false,
trailingComma: "es5",
bracketSpacing: true,
jsxBracketSameLine: false,
arrowParens: "avoid"
}
62 changes: 31 additions & 31 deletions gatsby-config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
if (process.env.ENVIROMENT !== 'production') {
// eslint-disable-next-line global-require
require('dotenv').config();
}

Expand All @@ -17,50 +18,54 @@ module.exports = {
'gatsby-plugin-catch-links',
'gatsby-plugin-react-helmet',
{
resolve: `gatsby-plugin-canonical-urls`,
resolve: 'gatsby-plugin-canonical-urls',
options: {
siteUrl: config.siteUrl,
},
},
`gatsby-plugin-sharp`,
'gatsby-plugin-sharp',
{
resolve: `gatsby-source-filesystem`,
resolve: 'gatsby-source-filesystem',
options: {
name: `learn`,
name: 'learn',
path: `${__dirname}/src/documentation/`,
include: [`**/*.md`], // ignore files starting with a dot
include: ['**/*.md'], // ignore files starting with a dot
},
},

{
resolve: `gatsby-plugin-manifest`,
resolve: 'gatsby-plugin-manifest',
options: {
name: config.title,
/* eslint-disable @typescript-eslint/camelcase */
short_name: config.title,
start_url: '/',
background_color: config.color,
theme_color: config.color,
/* eslint-disable @typescript-eslint/camelcase */
display: config.display,
icon: config.icon,
},
},
'gatsby-plugin-offline',
`gatsby-plugin-typescript`,
'gatsby-plugin-typescript',
{
resolve: 'gatsby-transformer-remark',
options: {
plugins: [
{
resolve: `gatsby-remark-autolink-headers`,
resolve: 'gatsby-remark-autolink-headers',
options: {
offsetY: `125`,
icon: `<svg aria-hidden="true" height="20" version="1.1" viewBox="0 0 16 16" width="20"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg>`,
className: `autolink-headers`,
offsetY: '125',
icon:
'<svg aria-hidden="true" height="20" version="1.1" viewBox="0 0 16 16" width="20"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg>',
className: 'autolink-headers',
maintainCase: false,
removeAccents: true,
},
},
{
resolve: `gatsby-remark-prismjs`,
resolve: 'gatsby-remark-prismjs',
options: {
classPrefix: 'language-',
inlineCodeMarker: null,
Expand All @@ -70,7 +75,7 @@ module.exports = {
},
},
{
resolve: `gatsby-remark-images`,
resolve: 'gatsby-remark-images',
options: {
maxWidth: 590,
},
Expand All @@ -79,7 +84,7 @@ module.exports = {
},
},
{
resolve: `gatsby-plugin-sitemap`,
resolve: 'gatsby-plugin-sitemap',
options: {
query: `{
site {
Expand All @@ -106,28 +111,23 @@ module.exports = {
}
}`,
serialize: ({ site, allSitePage, allMarkdownRemark }) => {
let pages = [];
allSitePage.edges.map(edge => {
pages.push({
url: site.siteMetadata.siteUrlNoSlash + edge.node.path,
changefreq: `daily`,
priority: 0.7,
});
});
allMarkdownRemark.edges.map(edge => {
pages.push({
url: `${site.siteMetadata.siteUrlNoSlash}/${edge.node.fields.slug}`,
changefreq: `daily`,
priority: 0.7,
});
});
const sitePages = allSitePage.edges.map(edge => ({
url: site.siteMetadata.siteUrlNoSlash + edge.node.path,
changefreq: 'daily',
priority: 0.7,
}));
const markdownRemark = allMarkdownRemark.edges.map(edge => ({
url: `${site.siteMetadata.siteUrlNoSlash}/${edge.node.fields.slug}`,
changefreq: 'daily',
priority: 0.7,
}));

return pages;
return sitePages.concat(markdownRemark);
},
},
},
{
resolve: `gatsby-plugin-emotion`,
resolve: 'gatsby-plugin-emotion',
},
],
};
24 changes: 14 additions & 10 deletions gatsby-node.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
const createSlug = require('./src/util/createSlug');
/* eslint-disable @typescript-eslint/no-var-requires */
// Use in this file CommonJS syntax see https://www.gatsbyjs.org/docs/migrating-from-v1-to-v2/#convert-to-either-pure-commonjs-or-pure-es6
const path = require('path');
const createSlug = require('./src/util/createSlug');

exports.createPages = ({ graphql, actions }) => {
const { createPage, createRedirect, createNodeField } = actions;
const { createPage } = actions;

return new Promise((resolve, reject) => {
const docTemplate = path.resolve('./src/templates/learn.tsx');
Expand Down Expand Up @@ -57,6 +59,7 @@ exports.createPages = ({ graphql, actions }) => {
`
).then(result => {
if (result.errors) {
// eslint-disable-next-line no-console
console.log(result.errors);
reject(result.errors);
}
Expand All @@ -65,7 +68,7 @@ exports.createPages = ({ graphql, actions }) => {
const docPages = [];
edges.forEach(({ node }, index) => {
const {
fields: { slug, authors },
fields: { slug },
frontmatter: { title, section },
parent: { relativePath },
} = node;
Expand Down Expand Up @@ -117,10 +120,10 @@ exports.createPages = ({ graphql, actions }) => {
next: page.next,
previous: page.previous,
relativePath: page.relativePath,
navigationData: navigationData,
navigationData,
},
});
if (page.slug === 'introduction-to-nodejs')
if (page.slug === 'introduction-to-nodejs') {
createPage({
path: `/learn`,
component: docTemplate,
Expand All @@ -129,32 +132,33 @@ exports.createPages = ({ graphql, actions }) => {
next: page.next,
previous: page.previous,
relativePath: page.relativePath,
navigationData: navigationData,
navigationData,
},
});
}
});
})
);
});
};

exports.onCreateNode = ({ node, getNode, actions }) => {
exports.onCreateNode = ({ node, actions }) => {
if (node.internal.type === 'MarkdownRemark') {
const { createNodeField } = actions;

const slug = createSlug(node.frontmatter.title);
createNodeField({
node,
name: `slug`,
name: 'slug',
value: slug,
});

let authors = node.frontmatter.authors;
let { authors } = node.frontmatter;
if (authors) {
authors = authors.split(',');
createNodeField({
node,
name: `authors`,
name: 'authors',
value: authors,
});
}
Expand Down
24 changes: 17 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"dotenv": "^6.0.0",
"emotion": "^10.0.7",
"emotion-server": "^10.0.7",
"eslint-plugin-jest": "^22.17.0",
"gatsby": "^2.13.13",
"gatsby-plugin-canonical-urls": "^2.0.10",
"gatsby-plugin-catch-links": "^2.0.9",
Expand All @@ -31,7 +32,6 @@
"react-dom": "^16.8.0",
"react-emotion": "^10.0.0",
"react-helmet": "^5.2.0",
"tslint": "^5.11.0",
"typescript": "^3.1.1"
},
"keywords": [
Expand All @@ -43,14 +43,15 @@
"build": "gatsby build",
"build-ci": "gatsby build --prefix-paths",
"start": "gatsby develop",
"format": "prettier --write '**/*.{ts,tsx,js}'",
"format": "yarn lint:fix",
"format-check": "prettier --check '**/*.{ts,tsx,js}'",
"jest": "jest",
"update-snapshot": "jest --updateSnapshot",
"test": "yarn format-check && yarn tslint && yarn jest",
"test": "yarn lint && yarn jest",
"test-watch": "yarn jest --watch",
"test-ci": "yarn test --coverage && codecov",
"tslint": "tslint --project ./tsconfig.json",
"lint": "eslint . --ext .js,.ts,.tsx --ignore-pattern test/",
"lint:fix": "yarn lint --fix",
"serve": "yarn build && clear && gatsby serve"
},
"devDependencies": {
Expand All @@ -60,16 +61,25 @@
"@commitlint/config-conventional": "^7.3.1",
"@types/jest": "^24.0.5",
"@types/react-test-renderer": "^16.8.1",
"@typescript-eslint/eslint-plugin": "^1.4.2",
"babel-jest": "^24.1.0",
"babel-preset-gatsby": "^0.1.7",
"codecov": "^3.3.0",
"eslint": "^5.14.1",
"eslint-config-airbnb": "^17.1.0",
"eslint-config-prettier": "^4.1.0",
"eslint-import-resolver-typescript": "^1.1.1",
"eslint-plugin-import": "^2.16.0",
"eslint-plugin-jsx-a11y": "^6.2.1",
"eslint-plugin-prettier": "^3.1.0",
"eslint-plugin-react": "^7.12.4",
"eslint-plugin-react-hooks": "^1.4.0",
"husky": "^1.3.1",
"identity-obj-proxy": "^3.0.0",
"jest": "^24.1.0",
"prettier": "^1.16.4",
"react-test-renderer": "^16.8.2",
"tslint-config-prettier": "^1.15.0",
"tslint-react": "^3.6.0"
"typescript": "~3.2.1"
},
"repository": {
"type": "git",
Expand Down Expand Up @@ -103,7 +113,7 @@
"husky": {
"hooks": {
"commit-msg": "commitlint --edit $HUSKY_GIT_PARAMS",
"pre-push": "yarn format-check && yarn tslint"
"pre-push": "yarn lint"
}
}
}
Loading