Skip to content

Commit

Permalink
added eslint rules
Browse files Browse the repository at this point in the history
  • Loading branch information
Nick Rook committed Jul 4, 2020
1 parent f93771a commit 7027d47
Show file tree
Hide file tree
Showing 10 changed files with 1,046 additions and 30 deletions.
4 changes: 4 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
**/node_modules/*
**/out/*
**/.next/*
**/*.d.ts
15 changes: 15 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module.exports = {
extends: ["@rooknj/eslint-config"],
rules: {
"@typescript-eslint/explicit-module-boundary-types": 0,
// This rule is a workaround for Next.js Link API behavior https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/issues/402#issuecomment-368305051
"jsx-a11y/anchor-is-valid": [
"error",
{
components: ["Link"],
specialLink: ["hrefLeft", "hrefRight"],
aspects: ["invalidHref", "preferButton"],
},
],
},
};
1 change: 1 addition & 0 deletions components/date.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import React from "react"
import { parseISO, format } from "date-fns";

export default function Date({ dateString }: { dateString: string }) {
Expand Down
3 changes: 2 additions & 1 deletion components/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import React from "react"
import Head from "next/head";
import Link from "next/link";
import styles from "./layout.module.css";
import utilStyles from "../styles/utils.module.css";
import Link from "next/link";

const name = "Nick Rook";
export const siteTitle = "Next.js Sample Website";
Expand Down
4 changes: 2 additions & 2 deletions lib/posts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ export function getSortedPostsData() {
return allPostsData.sort((a, b) => {
if (a.date < b.date) {
return 1;
} else {
return -1;
}

return -1;
});
}

Expand Down
11 changes: 11 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,19 @@
"remark-html": "^11.0.2"
},
"devDependencies": {
"@rooknj/eslint-config": "^1.0.1",
"@types/node": "^14.0.14",
"@types/react": "^16.9.41",
"@typescript-eslint/eslint-plugin": "^3.5.0",
"@typescript-eslint/parser": "^3.5.0",
"eslint": "^7.4.0",
"eslint-config-airbnb": "^18.2.0",
"eslint-config-prettier": "^6.11.0",
"eslint-plugin-import": "^2.22.0",
"eslint-plugin-jsx-a11y": "^6.3.1",
"eslint-plugin-prettier": "^3.1.4",
"eslint-plugin-react": "^7.20.3",
"eslint-plugin-react-hooks": "^4.0.5",
"typescript": "^3.9.6"
}
}
1 change: 1 addition & 0 deletions pages/_app.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import React from "react";
import "../styles/global.css";
import { AppProps } from "next/app";

Expand Down
5 changes: 3 additions & 2 deletions pages/index.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import React from "react";
import Head from "next/head";
import Link from "next/link";
import { GetStaticProps } from "next";
import Layout, { siteTitle } from "../components/layout";
import utilStyles from "../styles/utils.module.css";
import { getSortedPostsData } from "../lib/posts";
import Link from "next/link";
import Date from "../components/date";
import { GetStaticProps } from "next";

export const getStaticProps: GetStaticProps = async () => {
const allPostsData = getSortedPostsData();
Expand Down
5 changes: 3 additions & 2 deletions pages/posts/[id].tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import React from "react";
import Head from "next/head";
import { GetStaticProps, GetStaticPaths } from "next";
import Layout from "../../components/layout";
import { getAllPostIds, getPostData } from "../../lib/posts";
import Head from "next/head";
import Date from "../../components/date";
import utilStyles from "../../styles/utils.module.css";
import { GetStaticProps, GetStaticPaths } from "next";

const Post: React.FC<{
postData: {
Expand Down
Loading

0 comments on commit 7027d47

Please sign in to comment.