Skip to content

Commit 395c94d

Browse files
authored
Add Eslint (#6)
* Pretty rollup file * Rename test files sto fit our standards * Add eslint * change warnings to errors
1 parent 5cd5bee commit 395c94d

8 files changed

Lines changed: 1409 additions & 104 deletions

File tree

.eslintrc.js

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
module.exports = {
2+
extends: ["airbnb/base", "prettier"],
3+
parser: "babel-eslint",
4+
ignorePatterns: ["/dist/**"],
5+
rules: {
6+
"prettier/prettier": "error",
7+
"arrow-body-style": ["error", "as-needed"],
8+
complexity: ["error", 10],
9+
curly: "error",
10+
"default-case": "off",
11+
eqeqeq: ["error", "always"],
12+
"func-style": ["error", "expression"],
13+
"func-names": ["error"],
14+
"generator-star-spacing": ["error", { before: false, after: true }],
15+
"jsx-quotes": ["error", "prefer-double"],
16+
"max-depth": ["error", 10],
17+
"newline-before-return": "error",
18+
"no-alert": "error",
19+
"no-confusing-arrow": ["error", { allowParens: false }],
20+
"no-constant-condition": "error",
21+
"no-console": "off",
22+
"no-empty-function": "error",
23+
"no-eq-null": "error",
24+
"no-implicit-coercion": [
25+
"error",
26+
{ boolean: false, number: true, string: true, allow: [] },
27+
],
28+
"no-invalid-this": "error",
29+
"no-magic-numbers": [
30+
"error",
31+
{
32+
ignore: [-1, 0, 1],
33+
ignoreArrayIndexes: true,
34+
ignoreDefaultValues: true,
35+
enforceConst: false,
36+
detectObjects: false,
37+
},
38+
],
39+
"no-process-env": "error",
40+
"no-process-exit": "error",
41+
"no-restricted-imports": ["error", "lodash"],
42+
"no-sync": "error",
43+
"no-undefined": "error",
44+
"no-underscore-dangle": ["error", { allow: ["__INIT_MATERIAL_UI__"] }],
45+
"no-unmodified-loop-condition": "error",
46+
"no-useless-call": "error",
47+
"no-warning-comments": [
48+
"warn",
49+
{
50+
terms: ["todo", "fixme"],
51+
location: "anywhere",
52+
},
53+
],
54+
"require-atomic-updates": "error",
55+
"require-await": "error",
56+
"require-unicode-regexp": "error",
57+
"template-curly-spacing": ["error", "never"],
58+
"import/default": "error",
59+
"import/exports-last": "error",
60+
"import/extensions": [
61+
"error",
62+
"always",
63+
{
64+
js: "never",
65+
jsx: "never",
66+
ts: "never",
67+
tsx: "never",
68+
json: "never",
69+
},
70+
],
71+
"import/max-dependencies": ["error", { max: 20 }],
72+
"import/no-unassigned-import": "error",
73+
"import/no-unused-modules": [
74+
"error",
75+
{ missingExports: true, unusedExports: true },
76+
],
77+
"import/order": [
78+
"error",
79+
{
80+
groups: [
81+
"builtin",
82+
"external",
83+
"internal",
84+
"parent",
85+
"sibling",
86+
"index",
87+
],
88+
"newlines-between": "never",
89+
},
90+
],
91+
"filenames/match-exported": ["error", "kebab"],
92+
"filenames/match-regex": ["error", "(^[a-z-]*[a-z]+$)|(.config$)"],
93+
},
94+
overrides: [
95+
{
96+
files: [
97+
"jest.config.js",
98+
"jest.setup.js",
99+
"rollup.config.js",
100+
".eslintrc.js",
101+
],
102+
rules: {
103+
"filenames/match-exported": "off",
104+
"filenames/match-regex": "off",
105+
"import/no-unused-modules": "off",
106+
"no-magic-numbers": "off",
107+
},
108+
},
109+
{
110+
files: ["*.test.js", "*.test.jsx"],
111+
rules: {
112+
"filenames/match-regex": "off",
113+
"import/no-unused-modules": "off",
114+
"no-process-env": "off",
115+
"no-undefined": "off",
116+
"no-magic-numbers": "off",
117+
},
118+
},
119+
{
120+
files: ["src/cli.js", "src/index.js"],
121+
rules: {
122+
"import/no-unused-modules": "off",
123+
},
124+
},
125+
{
126+
files: ["__mocks__/**/*"],
127+
rules: {
128+
"filenames/match-exported": "off",
129+
"filenames/match-regex": "off",
130+
"import/no-unused-modules": "off",
131+
},
132+
},
133+
],
134+
plugins: ["prettier", "import", "filenames"],
135+
env: {
136+
node: true,
137+
jest: true,
138+
},
139+
};

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
node_modules/
22
coverage/
3+
.eslintcache

package.json

Lines changed: 83 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,85 @@
11
{
2-
"name": "lcov-reporter-action",
3-
"version": "0.2.17",
4-
"description": "Comments a pull request with the lcov code coverage",
5-
"license": "MIT",
6-
"author": "Romeo Van Snick",
7-
"repository": "https://github.com/romeovs/lcov-reporter-action",
8-
"keywords": [
9-
"actions",
10-
"pull-request",
11-
"comment",
12-
"message"
13-
],
14-
"main": "index.js",
15-
"scripts": {
16-
"build": "rollup -c",
17-
"test": "jest --passWithNoTests --coverage",
18-
"local": "babel-node src/cli",
19-
"format": "prettier --write src/*.js src/**/*.js"
20-
},
21-
"dependencies": {
22-
"@actions/core": "^1.2.0",
23-
"@actions/github": "^4.0.0",
24-
"lcov-parse": "^1.0.0"
25-
},
26-
"devDependencies": {
27-
"@babel/core": "^7.8.6",
28-
"@babel/node": "^7.8.4",
29-
"@babel/preset-env": "^7.8.6",
30-
"@rollup/plugin-commonjs": "^11.0.2",
31-
"@rollup/plugin-json": "^4.0.2",
32-
"@rollup/plugin-node-resolve": "^7.1.1",
33-
"babel-jest": "^25.1.0",
34-
"core-js": "3",
35-
"jest": "^25.1.0",
36-
"prettier": "^1.19.1",
37-
"regenerator-runtime": "^0.13.3",
38-
"rollup": "^1.32.0",
39-
"rollup-plugin-node-externals": "^2.1.3"
40-
},
41-
"babel": {
42-
"presets": [
43-
[
44-
"@babel/preset-env",
45-
{
46-
"useBuiltIns": "usage",
47-
"corejs": 3
48-
}
49-
]
50-
]
51-
},
52-
"jest": {
53-
"testMatch": [
54-
"<rootDir>/src/*_test.js",
55-
"<rootDir>/src/**/*_test.js"
56-
]
57-
},
58-
"prettier": {
59-
"tabWidth": 4,
60-
"useTabs": false,
61-
"bracketSpacing": true,
62-
"trailingComma": "all"
63-
}
2+
"name": "lcov-reporter-action",
3+
"version": "0.2.17",
4+
"description": "Comments a pull request with the lcov code coverage",
5+
"license": "MIT",
6+
"author": "Romeo Van Snick",
7+
"repository": "https://github.com/romeovs/lcov-reporter-action",
8+
"keywords": [
9+
"actions",
10+
"pull-request",
11+
"comment",
12+
"message"
13+
],
14+
"main": "index.js",
15+
"scripts": {
16+
"build": "rollup -c",
17+
"test": "jest --passWithNoTests --coverage",
18+
"local": "babel-node src/cli",
19+
"format": "prettier --write src/*.js src/**/*.js *.js",
20+
"eslint": "eslint --ext .js ."
21+
},
22+
"dependencies": {
23+
"@actions/core": "^1.2.0",
24+
"@actions/github": "^4.0.0",
25+
"lcov-parse": "^1.0.0"
26+
},
27+
"devDependencies": {
28+
"@babel/core": "^7.8.6",
29+
"@babel/node": "^7.8.4",
30+
"@babel/preset-env": "^7.8.6",
31+
"@rollup/plugin-commonjs": "^11.0.2",
32+
"@rollup/plugin-json": "^4.0.2",
33+
"@rollup/plugin-node-resolve": "^7.1.1",
34+
"babel-eslint": "^10.1.0",
35+
"babel-jest": "^25.1.0",
36+
"core-js": "3",
37+
"eslint": "^7.15.0",
38+
"eslint-config-airbnb": "18.2.1",
39+
"eslint-config-prettier": "^7.0.0",
40+
"eslint-plugin-filenames": "1.3.2",
41+
"eslint-plugin-import": "2.22.1",
42+
"eslint-plugin-prettier": "3.2.0",
43+
"husky": ">=4",
44+
"jest": "^25.1.0",
45+
"lint-staged": "^10.5.3",
46+
"prettier": "^1.19.1",
47+
"regenerator-runtime": "^0.13.3",
48+
"rollup": "^1.32.0",
49+
"rollup-plugin-node-externals": "^2.1.3"
50+
},
51+
"babel": {
52+
"presets": [
53+
[
54+
"@babel/preset-env",
55+
{
56+
"useBuiltIns": "usage",
57+
"corejs": 3
58+
}
59+
]
60+
]
61+
},
62+
"jest": {
63+
"testMatch": [
64+
"<rootDir>/src/*_test.js",
65+
"<rootDir>/src/**/*_test.js"
66+
]
67+
},
68+
"prettier": {
69+
"tabWidth": 4,
70+
"useTabs": false,
71+
"bracketSpacing": true,
72+
"trailingComma": "all"
73+
},
74+
"husky": {
75+
"hooks": {
76+
"pre-commit": "lint-staged"
77+
}
78+
},
79+
"lint-staged": {
80+
"*.js": [
81+
"eslint --cache --fix",
82+
"prettier --write"
83+
]
84+
}
6485
}

rollup.config.js

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
1-
import commonjs from "@rollup/plugin-commonjs"
2-
import resolve from "@rollup/plugin-node-resolve"
3-
import json from "@rollup/plugin-json"
4-
import externals from "rollup-plugin-node-externals"
1+
import commonjs from "@rollup/plugin-commonjs";
2+
import resolve from "@rollup/plugin-node-resolve";
3+
import json from "@rollup/plugin-json";
4+
import externals from "rollup-plugin-node-externals";
55

66
export default {
7-
input: "src/index.js",
8-
output: {
9-
file: "dist/main.js",
10-
format: "cjs",
11-
},
12-
treeshake: true,
13-
plugins: [
14-
externals({
15-
builtin: true,
16-
deps: false,
17-
}),
18-
resolve({
19-
preferBuiltins: true,
20-
mainFields: [ "main" ],
21-
}),
22-
commonjs(),
23-
json(),
24-
],
25-
}
7+
input: "src/index.js",
8+
output: {
9+
file: "dist/main.js",
10+
format: "cjs",
11+
},
12+
treeshake: true,
13+
plugins: [
14+
externals({
15+
builtin: true,
16+
deps: false,
17+
}),
18+
resolve({
19+
preferBuiltins: true,
20+
mainFields: ["main"],
21+
}),
22+
commonjs(),
23+
json(),
24+
],
25+
};
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)