Skip to content

Commit f27168c

Browse files
committed
chore: add eslint
1 parent 2953faa commit f27168c

File tree

5 files changed

+34
-2
lines changed

5 files changed

+34
-2
lines changed

.editorconfig

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
root = true
2+
3+
[*]
4+
indent_style = space
5+
indent_size = 2
6+
end_of_line = lf
7+
charset = utf-8
8+
max_line_length = 120
9+
trim_trailing_whitespace = true
10+
insert_final_newline = true

.eslintrc.js

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
const { overrides } = require('@netlify/eslint-config-node')
2+
3+
module.exports = {
4+
extends: '@netlify/eslint-config-node',
5+
rules: {},
6+
overrides: [...overrides],
7+
}

.gitattributes

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* text=auto eol=lf

.github/workflows/test.yml

+3
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,8 @@ jobs:
2626
uses: actions/setup-node@v2
2727
with:
2828
node-version: ${{ matrix.node-version }}
29+
- name: Linting
30+
run: npm run format:ci
31+
if: "${{ matrix.node-version == '15.x' }}"
2932
- run: npm install
3033
- run: npm test

package.json

+13-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,15 @@
1111
"!src/tests"
1212
],
1313
"scripts": {
14-
"format": "prettier --write .",
1514
"build": "next build test/sample",
15+
"format": "run-s format:check-fix:*",
16+
"format:ci": "run-s format:check:*",
17+
"format:check-fix:lint": "run-e format:check:lint format:fix:lint",
18+
"format:check:lint": "cross-env-shell eslint $npm_package_config_eslint",
19+
"format:fix:lint": "cross-env-shell eslint --fix $npm_package_config_eslint",
20+
"format:check-fix:prettier": "run-e format:check:prettier format:fix:prettier",
21+
"format:check:prettier": "cross-env-shell prettier --check $npm_package_config_prettier",
22+
"format:fix:prettier": "cross-env-shell prettier --write $npm_package_config_prettier",
1623
"test:plugin": "npm run build && jest",
1724
"test:src": "jest --config src/tests/jest.config.js",
1825
"test": "npm run test:plugin && npm run test:src",
@@ -26,6 +33,10 @@
2633
"prepublishOnly:install": "npm ci",
2734
"prepublishOnly:test": "npm test"
2835
},
36+
"config": {
37+
"eslint": "--ignore-path .gitignore --cache --format=codeframe --max-warnings=0 \"{src,scripts,tests,.github}/**/*.{js,md,html}\" \"*.{js,md,html}\" \".*.{js,md,html}\"",
38+
"prettier": "--ignore-path .gitignore --loglevel=warn \"{src,scripts,tests,.github}/**/*.{js,md,yml,json,html}\" \"*.{js,yml,json,html}\" \".*.{js,yml,json,html}\" \"!package-lock.json\""
39+
},
2940
"repository": {
3041
"type": "git",
3142
"url": "git+https://github.com/netlify/netlify-plugin-nextjs.git"
@@ -77,7 +88,7 @@
7788
"husky": {
7889
"hooks": {
7990
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS",
80-
"pre-commit": "prettier --check ."
91+
"pre-push": "npm run format"
8192
}
8293
},
8394
"engines": {

0 commit comments

Comments
 (0)