From 90f609c7de9eba89b68a290fe0ed9e9d350daf00 Mon Sep 17 00:00:00 2001 From: pablopunk Date: Sun, 24 Jan 2021 14:10:32 +0100 Subject: [PATCH] Run eslint on tests --- .eslintrc.yml | 1 + README.md | 2 +- package.json | 4 +++- template/package.json | 7 +++++-- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/.eslintrc.yml b/.eslintrc.yml index a030b10..10a6a7a 100644 --- a/.eslintrc.yml +++ b/.eslintrc.yml @@ -6,4 +6,5 @@ extends: 'eslint:recommended' parserOptions: ecmaVersion: 12 sourceType: module +ignorePatterns: ['template/'] rules: {} diff --git a/README.md b/README.md index 3309f38..424885e 100644 --- a/README.md +++ b/README.md @@ -60,7 +60,7 @@ _miny_ comes with `prettier` built-in to automatically format your code on every It's also useful to use an actual linter for catching some bugs or not used code, so it also includes `eslint` to lint all your code and help you fixing potential bugs. -You can customize the rules it follows by modifying the section `prettier` in `package.json`. By default, it will use _2 spaces as tabs_, remove unnecessary semicolons and convert double quoutes to _single quoutes_. You can add/remove [all of these rules](https://prettier.io/docs/en/options.html). You can also edit the `eslint` rules in `.eslintrc.yml`. Take a look at [eslint docs](https://eslint.org/docs/user-guide/configuring). +You can customize the rules it follows by modifying the section `prettier` in `package.json`. By default, it will use _2 spaces as tabs_, remove unnecessary semicolons and convert double quoutes to _single quoutes_. You can add/remove [all of these rules](https://prettier.io/docs/en/options.html). You can also edit the `eslint` rules in `.eslintrc.yml`. Take a look at [eslint docs](https://eslint.org/docs/user-guide/configuring). Runnning `npm run lint` will run both prettier and eslint in your project. There's also a `lint-fix` npm script that can help fixing trivial errors. ### Offline diff --git a/package.json b/package.json index 4443044..d5965dd 100644 --- a/package.json +++ b/package.json @@ -59,6 +59,8 @@ "url": "https://github.com/pablopunk/miny" }, "scripts": { - "test": "ava" + "lint": "eslint --ext .js .", + "lint-fix": "eslint --fix --ext .js .", + "test": "npm run lint && ava" } } diff --git a/template/package.json b/template/package.json index 7d84b06..dcaf5d3 100644 --- a/template/package.json +++ b/template/package.json @@ -15,7 +15,8 @@ <% } %> "prettier": "*", "pretty-quick": "*", - "husky": "*" + "husky": "*", + "eslint": "*" }, "homepage": "<%- githubRepo %>", "keywords": [ <%- `${keywords.trim().split(/[, ]+/).map(k => `"${k.trim()}"`).join(', ')}` %> ], @@ -36,8 +37,10 @@ "url": "<%- githubRepo %>" }, "scripts": { + "lint": "eslint --ext .js .", + "lint-fix": "eslint --fix --ext .js .", <% if (test !== 'none') { %> - "test": "<%- test -%>" + "test": "npm run lint && <%- test -%>" <% } %> } }