From 6af53e4ec56fa3c01fd8eabd43f1806d919af724 Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Mon, 12 Nov 2018 12:39:11 +0100 Subject: [PATCH] linting and formatting for everything --- .markdownlint.json | 4 ++-- .prettierignore | 3 +++ README.md | 46 +++++++++++++++++++++++++++++++++------------- package.json | 32 +++++++++++++++++--------------- 4 files changed, 55 insertions(+), 30 deletions(-) create mode 100644 .prettierignore diff --git a/.markdownlint.json b/.markdownlint.json index baa3192e..109fff03 100644 --- a/.markdownlint.json +++ b/.markdownlint.json @@ -8,8 +8,8 @@ "no-bare-urls": false, "first-line-h1": false, "first-heading-h1": false, - "blanks-around-fences": false, "no-trailing-punctuation": false, "ol-prefix": false, - "ul-style": { "style": "dash" } + "ul-style": { "style": "dash" }, + "blanks-around-fences": false } diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 00000000..93090764 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,3 @@ +node_modules +public +.cache diff --git a/README.md b/README.md index 8ddca14c..d2b2e329 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,7 @@ - [Repositories](#repositories) - [Development](#development) - [Use Docker](#use-docker) +- [Linting & formatting](#linting--formatting) - [GitHub GraphQL API](#github-graphql-api) - [Authors](#authors) - [License](#license) @@ -126,8 +127,8 @@ Additionally, you can attach multiple links to a repo. The GitHub link is automa ```yaml - name: keeper-contracts links: - - name: Documentation - url: https://github.com/oceanprotocol/keeper-contracts/tree/develop/doc + - name: Documentation + url: https://github.com/oceanprotocol/keeper-contracts/tree/develop/doc ``` in [`/data/repositories.yml`](data/repositories.yml). @@ -175,6 +176,25 @@ docker-compose up This will expose a hot-reloading server under [localhost:8000](http://localhost:8000). +## Linting & formatting + +To enforce a consistent code style, linting is setup for pretty much every file. Linting is part of the test suite, meaning builds on Travis will fail in case of linting errors. + +In this repo the following tools are setup for that: + +- ESLint with [eslint-config-oceanprotocol]https://github.com/oceanprotocol/eslint-config-oceanprotocol +- Stylelint with [stylelint-config-bigchaindb]https://github.com/bigchaindb/stylelint-config-bigchaindb +- [markdownlint](https://github.com/DavidAnson/markdownlint) +- [Prettier](https://prettier.io) + +```bash +# only run linting checks +npm run lint + +# auto-formatting of all js, css, md, yml files +npm run format +``` + ## GitHub GraphQL API The GitHub GraphQL API integration is done through [gatsby-source-graphql](https://www.gatsbyjs.org/packages/gatsby-source-graphql/) and requires authorization. @@ -197,19 +217,19 @@ This query should get you started to explore what information you can get from G ```graphql query { - github { - organization(login: "oceanprotocol") { - repositories(first: 100) { - edges { - node { - name - description - url - } - } - } + github { + organization(login: "oceanprotocol") { + repositories(first: 100) { + edges { + node { + name + description + url + } } + } } + } } ``` diff --git a/package.json b/package.json index c18e7733..f1d528aa 100755 --- a/package.json +++ b/package.json @@ -3,6 +3,23 @@ "description": "One site to rule all docs", "version": "0.0.1", "author": "Ocean Protocol ", + "license": "Apache-2.0", + "scripts": { + "build": "gatsby build", + "start": "gatsby develop", + "ssr": "npm run build && serve -s public/", + "format:js": "prettier --write '**/*.{js,jsx}'", + "format:css": "prettier-stylelint --write --quiet 'src/**/*.{css,scss}'", + "format:md": "prettier --write '**/*.md'", + "format:yml": "prettier --write '**/*.{yml,yaml}'", + "format": "run-p format:js format:css format:md format:yml", + "lint:js": "eslint --ignore-path .gitignore --ignore-path .prettierignore --ext .js,.jsx .", + "lint:css": "stylelint './src/**/*.{css,scss}'", + "lint:md": "markdownlint './**/*.{md,markdown}' --ignore node_modules", + "lint:yml": "prettier '**/*.{yml,yaml}' --list-different", + "lint": "run-p --continue-on-error lint:js lint:css lint:md lint:yml", + "test": "npm run lint" + }, "dependencies": { "@oceanprotocol/art": "^1.0.2", "classnames": "^2.2.6", @@ -39,21 +56,6 @@ "react-helmet": "^5.2.0", "rehype-react": "^3.0.3" }, - "license": "Apache-2.0", - "scripts": { - "build": "gatsby build", - "start": "gatsby develop", - "ssr": "npm run build && serve -s public/", - "format:js": "prettier --write 'src/**/*.{js,jsx}'", - "format:css": "prettier-stylelint --write --quiet 'src/**/*.{css,scss}'", - "format:md": "prettier --write './content/**/*.md' --no-semi", - "format": "run-p format:js format:css", - "lint:js": "eslint ./gatsby-*.js && eslint ./src/**/*.{js,jsx}", - "lint:css": "stylelint ./src/**/*.{css,scss}", - "lint:md": "markdownlint './content/**/*.md'", - "lint": "run-p lint:js lint:css", - "test": "npm run lint" - }, "devDependencies": { "@svgr/webpack": "^4.0.2", "dotenv": "^6.1.0",