Skip to content

Commit

Permalink
intial eslint pre-commit setup
Browse files Browse the repository at this point in the history
  • Loading branch information
rahuldkjain committed Oct 31, 2021
1 parent fb6389f commit 004401a
Show file tree
Hide file tree
Showing 63 changed files with 4,383 additions and 3,578 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules/**
16 changes: 16 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"env": {
"browser": true,
"es2021": true
},
"extends": ["plugin:react/recommended", "airbnb"],
"parserOptions": {
"ecmaFeatures": {
"jsx": true
},
"ecmaVersion": 12,
"sourceType": "module"
},
"plugins": ["react"],
"rules": {}
}
5 changes: 2 additions & 3 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
---
name: Bug report
about: Create a report to help us improve
title: ""
title: ''
labels: bug
assignees: ""
assignees: ''
---

**Describe the bug**
Expand Down Expand Up @@ -39,7 +39,6 @@ If applicable, add screenshots to help explain your problem.
**Additional context**
Add any other context about the problem here.


Join the **Discord Server** for further discussions.

<a href="https://discord.gg/HHMs7Eg">
Expand Down
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/feature-enhancement-request.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
---
name: Feature/Enhancement request
about: Suggest an idea for this project
title: ""
title: ''
labels: enhancement, hacktoberfest
assignees: ""
assignees: ''
---

**Is your feature request related to a problem? Please describe.**
Expand Down
1 change: 0 additions & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,3 @@ as any relevant images for UI changes._
## Added to documentation?

- [ ] readme

12 changes: 11 additions & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
{
"printWidth": 80,
"tabWidth": 2,
"useTabs": false,
"semi": true,
"singleQuote": true,
"quoteProps": "as-needed",
"jsxSingleQuote": false,
"trailingComma": "all",
"bracketSpacing": true,
"jsxBracketSameLine": true,
"arrowParens": "avoid",
"semi": false
"endOfLine": "auto"
}
26 changes: 13 additions & 13 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,22 @@ appearance, race, religion, or sexual identity and orientation.
Examples of behavior that contributes to creating a positive environment
include:

* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members
- Using welcoming and inclusive language
- Being respectful of differing viewpoints and experiences
- Gracefully accepting constructive criticism
- Focusing on what is best for the community
- Showing empathy towards other community members

Examples of unacceptable behavior by participants include:

* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting
- The use of sexualized language or imagery and unwelcome sexual attention or
advances
- Trolling, insulting/derogatory comments, and personal or political attacks
- Public or private harassment
- Publishing others' private information, such as a physical or electronic
address, without explicit permission
- Other conduct which could reasonably be considered inappropriate in a
professional setting

## Our Responsibilities

Expand Down
108 changes: 57 additions & 51 deletions CODE_STYLE_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,23 @@

## Reusable components

* Do not make a new file for smaller components.
* Smaller, reusable components needed in the main components should be added **above** the main component, **not** inside it.
* Use ES6 arrow functions for defining components.
- Do not make a new file for smaller components.
- Smaller, reusable components needed in the main components should be added **above** the main component, **not** inside it.
- Use ES6 arrow functions for defining components.

## Spacing

1. **JS:**
* Use a space after `if`, `for`, `while`, `switch`.
* Do not use a space after the opening `(` and before the closing `)`.
* Use a space before and after destructuring objects.
```js
//good
const { apple, mangoes } = fruits;

//bad
const {apple, mangoes} = fruits;
- Use a space after `if`, `for`, `while`, `switch`.
- Do not use a space after the opening `(` and before the closing `)`.
- Use a space before and after destructuring objects.
```js
//good
const { apple, mangoes } = fruits;

//bad
const { apple, mangoes } = fruits;
```


//Same for destructuring props:
Expand All @@ -36,56 +37,61 @@
```
2. **JSX:**
* Use a space before the forward slash (`/`) of a self-closing tag
```js
//good
<Foo />
//bad
<Foo/>
```
* Do **not** use spaces for JSX curly braces
```js
//good
<Foo bar={baz} />
- Use a space before the forward slash (`/`) of a self-closing tag
//bad
<Foo bar={ baz } />
```
```js
//good
<Foo />
//bad
<Foo/>
```

- Do **not** use spaces for JSX curly braces

```js
//good
<Foo bar={baz} />

//bad
<Foo bar={ baz } />
```

## **Props:**

* Use camelCase for prop names, or PascalCase if the prop value is a React component.
* Use new lines when props do not fit on the same line.
```js
//good
<Foo
prop1={value1}
prop2={value2}
prop3={value3}
/>
//bad
<Foo prop1={value1} prop2={value2} prop3={value3} />
```
- Use camelCase for prop names, or PascalCase if the prop value is a React component.
- Use new lines when props do not fit on the same line.

```js
//good
<Foo
prop1={value1}
prop2={value2}
prop3={value3}
/>

//bad
<Foo prop1={value1} prop2={value2} prop3={value3} />
```

## **Best practices:**

* **Always** add semicolons after a line.
* Use ES6 arrow functions.
* Keep the indentation in your code correct.
* Use 4 spaces for tabs.
* Don't Repeat Yourself. If you think you're repeating too much code, make a smaller component, or a function.
* **Always** add alt prop to `img` tags.
* Add `rel="noopener"` for `a` tags which has `target="_blank"`.
* Don't do `outline: none` on user input elements. If you do not want outline, give them faint, visible background on focus. This is for accessibility.
- **Always** add semicolons after a line.
- Use ES6 arrow functions.
- Keep the indentation in your code correct.
- Use 4 spaces for tabs.
- Don't Repeat Yourself. If you think you're repeating too much code, make a smaller component, or a function.
- **Always** add alt prop to `img` tags.
- Add `rel="noopener"` for `a` tags which has `target="_blank"`.
- Don't do `outline: none` on user input elements. If you do not want outline, give them faint, visible background on focus. This is for accessibility.

### Other things to note

* We are using [octicons](https://primer.style/octicons/) for icons. Use this if you need to add icons. Do **not** add a new library for icons.
* Try to not commit changes in `package.json`, `package-lock.json`.
* Discuss with contributors on discord if you're planning to add/remove a package.
- We are using [octicons](https://primer.style/octicons/) for icons. Use this if you need to add icons. Do **not** add a new library for icons.
- Try to not commit changes in `package.json`, `package-lock.json`.
- Discuss with contributors on discord if you're planning to add/remove a package.

## Further reading:

This guide is based on [airbnb's react guide](https://github.com/airbnb/javascript/tree/master/react). You can read all the best practices there.
This guide is based on [airbnb's react guide](https://github.com/airbnb/javascript/tree/master/react). You can read all the best practices there.
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@

This tool provides an easy way to create a GitHub profile readme with the latest add-ons such as `visitors count`, `github stats`, etc.

## 🚀 Demo

## 🚀 Demo
<a href="https://rahuldkjain.github.io/gh-profile-readme-generator" target="blank">
<img src="https://img.shields.io/website?url=https%3A%2F%2Frahuldkjain.github.io%2Fgh-profile-readme-generator&logo=github&style=flat-square" />
</a>
Expand Down Expand Up @@ -126,11 +126,11 @@ Please contribute using [GitHub Flow](https://guides.github.com/introduction/flo
Please read [`CONTRIBUTING`](CONTRIBUTING.md) for details on our [`CODE OF CONDUCT`](CODE_OF_CONDUCT.md), and the process for submitting pull requests to us.

## 💻 Built with

- [Gatsby](https://www.gatsbyjs.com/)
- [Tailwind CSS](https://tailwindcss.com/): for styling
- [GSAP](https://greensock.com/gsap/): for small SVG Animations


## 🙇 Special Thanks

- [Anurag Hazra](https://github.com/anuraghazra) for amazing [github-readme-stats](https://github.com/anuraghazra/github-readme-stats)
Expand All @@ -146,7 +146,6 @@ Please read [`CONTRIBUTING`](CONTRIBUTING.md) for details on our [`CODE OF CONDU
- [Aadit Kamat](https://github.com/aaditkamat) find the tool useful and showed support with his donation. A big thanks to him.
- [Jean-Michel Fayard](https://github.com/jmfayard) used the generator to create his GitHub Profile README and he loved it. Thanks to him for showing support to the tool with the donation.


## 🙏 Support

<p align="left">
Expand All @@ -163,7 +162,6 @@ Please read [`CONTRIBUTING`](CONTRIBUTING.md) for details on our [`CODE OF CONDU
<a href="https://www.buymeacoffee.com/rahuldkjain" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/default-orange.png" alt="Buy Me A Coffee" height="23" width="100" style="border-radius:2px" />
</p>


<hr>
<p align="center">
Developed with ❤️ in India 🇮🇳
Expand Down
2 changes: 1 addition & 1 deletion __mocks__/file-mock.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
module.exports = "test-file-stub"
module.exports = 'test-file-stub';
20 changes: 5 additions & 15 deletions __mocks__/gatsby.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,17 @@
const React = require("react")
const gatsby = jest.requireActual("gatsby")
const React = require('react');
const gatsby = jest.requireActual('gatsby');

module.exports = {
...gatsby,
graphql: jest.fn(),
Link: jest.fn().mockImplementation(
// these props are invalid for an `a` tag
({
activeClassName,
activeStyle,
getProps,
innerRef,
partiallyActive,
ref,
replace,
to,
...rest
}) =>
React.createElement("a", {
({ activeClassName, activeStyle, getProps, innerRef, partiallyActive, ref, replace, to, ...rest }) =>
React.createElement('a', {
...rest,
href: to,
})
),
StaticQuery: jest.fn(),
useStaticQuery: jest.fn(),
}
};
4 changes: 2 additions & 2 deletions gatsby-browser.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
import "./src/styles/tailwind.css"
require("prismjs/themes/prism-okaidia.css")
import './src/styles/tailwind.css';
require('prismjs/themes/prism-okaidia.css');
6 changes: 3 additions & 3 deletions gatsby-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ module.exports = {
{
resolve: `gatsby-plugin-google-analytics`,
options: {
trackingId: "UA-168596085-3",
trackingId: 'UA-168596085-3',
// this option places the tracking script into the head of the DOM
head: true,
// other options
Expand All @@ -53,7 +53,7 @@ module.exports = {
{
resolve: `gatsby-plugin-postcss`,
options: {
postCssPlugins: [require("tailwindcss")],
postCssPlugins: [require('tailwindcss')],
},
},
{
Expand All @@ -69,4 +69,4 @@ module.exports = {
// this (optional) plugin enables Progressive Web App + Offline functionality
// To learn more, visit: https://gatsby.dev/offline
// `gatsby-plugin-offline`,
}
};
21 changes: 9 additions & 12 deletions gatsby-node.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
exports.createPages = async ({ actions, graphql, reporter }) => {
const { createPage } = actions
const { createPage } = actions;

const blogPostTemplate = require.resolve(`./src/templates/blogTemplate.js`)
const blogPostTemplate = require.resolve(`./src/templates/blogTemplate.js`);

const result = await graphql(`
{
allMarkdownRemark(
sort: { order: DESC, fields: [frontmatter___date] }
limit: 1000
) {
allMarkdownRemark(sort: { order: DESC, fields: [frontmatter___date] }, limit: 1000) {
edges {
node {
frontmatter {
Expand All @@ -18,12 +15,12 @@ exports.createPages = async ({ actions, graphql, reporter }) => {
}
}
}
`)
`);

// Handle errors
if (result.errors) {
reporter.panicOnBuild(`Error while running GraphQL query.`)
return
reporter.panicOnBuild(`Error while running GraphQL query.`);
return;
}

result.data.allMarkdownRemark.edges.forEach(({ node }) => {
Expand All @@ -34,6 +31,6 @@ exports.createPages = async ({ actions, graphql, reporter }) => {
// additional data can be passed via context
slug: node.frontmatter.slug,
},
})
})
}
});
});
};
Loading

0 comments on commit 004401a

Please sign in to comment.