Skip to content

Commit 7bfff4d

Browse files
vicaryj0k3r
authored andcommitted
feat(eslint): support yml and expand lint scope
1 parent 333b1fe commit 7bfff4d

File tree

8 files changed

+144
-35
lines changed

8 files changed

+144
-35
lines changed

.eslintrc.yml

Lines changed: 31 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,12 @@ extends:
1111
- plugin:import/errors
1212
- plugin:import/warnings
1313
- prettier
14-
parser: "@babel/eslint-parser"
14+
overrides:
15+
- files:
16+
- '*.yml'
17+
- '*.yaml'
18+
parser: 'yaml-eslint-parser'
19+
parser: '@babel/eslint-parser'
1520
parserOptions:
1621
requireConfigFile: false
1722
sourceType: module
@@ -20,36 +25,41 @@ plugins:
2025
- lodash
2126
- import
2227
- prettier
28+
- yml
2329
rules:
24-
linebreak-style: [ error, unix ]
25-
semi: [ error, always ]
26-
quotes: [ error, single, { avoidEscape: true } ]
30+
linebreak-style: [error, unix]
31+
semi: [error, always]
32+
quotes: [error, single, { avoidEscape: true }]
2733
no-mixed-spaces-and-tabs: error
2834
space-before-blocks: error
2935
arrow-spacing: error
30-
key-spacing: [ error, { afterColon: true, mode: minimum } ]
31-
brace-style: [ error, '1tbs' ]
32-
comma-spacing: [ error, { before: false, after: true } ]
33-
comma-style: [ error, last, { exceptions: { VariableDeclaration: true } } ]
34-
computed-property-spacing: [ error, never ]
35-
object-curly-spacing: [ error, always ]
36+
key-spacing: [error, { afterColon: true, mode: minimum }]
37+
brace-style: [error, '1tbs']
38+
comma-spacing: [error, { before: false, after: true }]
39+
comma-style: [error, last, { exceptions: { VariableDeclaration: true } }]
40+
computed-property-spacing: [error, never]
41+
object-curly-spacing: [error, always]
3642
prefer-const: error
3743
no-var: error
3844
promise/no-nesting: off
3945
import/first: error
4046
import/newline-after-import: error
4147
import/no-named-as-default: off
42-
import/no-extraneous-dependencies: [ error, { devDependencies: true } ]
48+
import/no-extraneous-dependencies: [error, { devDependencies: true }]
4349
lodash/import-scope: off
4450
lodash/preferred-alias: off
4551
lodash/prop-shorthand: off
46-
lodash/prefer-lodash-method: [ error, { ignoreObjects: [ BbPromise, path ] } ]
47-
max-len: [ error, { code: 120, ignoreStrings: true, ignoreComments: true, ignoreTemplateLiterals: true } ]
48-
prettier/prettier: [ error, {
49-
printWidth: 120,
50-
arrowParens: 'avoid',
51-
bracketSpacing: true,
52-
semi: true,
53-
singleQuote: true,
54-
trailingComma: 'none',
55-
} ]
52+
lodash/prefer-lodash-method: [error, { ignoreObjects: [BbPromise, path] }]
53+
max-len: [error, { code: 120, ignoreStrings: true, ignoreComments: true, ignoreTemplateLiterals: true }]
54+
prettier/prettier:
55+
[
56+
error,
57+
{
58+
printWidth: 120,
59+
arrowParens: 'avoid',
60+
bracketSpacing: true,
61+
semi: true,
62+
singleQuote: true,
63+
trailingComma: 'none'
64+
}
65+
]

.github/workflows/lint.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,17 @@ jobs:
1717

1818
steps:
1919
- name: "Checkout"
20-
uses: actions/checkout@v2
20+
uses: actions/checkout@v3
2121
with:
22-
fetch-depth: 2
22+
fetch-depth: 0
2323

2424
- name: "Install Node.js"
25-
uses: actions/setup-node@v2
25+
uses: actions/setup-node@v3
2626
with:
27-
node-version: "12"
27+
node-version: 16
2828

2929
- name: "Install dependencies"
3030
run: npm ci
3131

3232
- name: "Lint files"
33-
run: "npm run eslint"
33+
run: "npm run eslint -- --ignore-pattern examples/"

examples/babel-multiple-statically-entries/first.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
export const hello = (event, context, cb) => {
2-
const p = new Promise((resolve, reject) => {
1+
/* eslint-disable promise/no-callback-in-promise */
2+
export const hello = (event, _, cb) => {
3+
const p = new Promise(resolve => {
34
resolve('success');
45
});
5-
p.then(r =>
6+
p.then(() =>
67
cb(null, {
78
message: 'Go Serverless Webpack (Babel) v1.0! First module!',
89
event

examples/babel-multiple-statically-entries/second.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
export const hello = (event, context, cb) => {
2-
const p = new Promise((resolve, reject) => {
1+
/* eslint-disable promise/no-callback-in-promise */
2+
export const hello = (event, _, cb) => {
3+
const p = new Promise(resolve => {
34
resolve('success');
45
});
5-
p.then(r =>
6+
p.then(() =>
67
cb(null, {
78
message: 'Go Serverless Webpack (Babel) v1.0! Second module!',
89
event

examples/include-external-npm-packages-lock-file/handler.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Should keep side-effects scripts
22
import 'dotenv/config';
33
// Should be included as fbgraph is not marked as sideEffect free
4+
// eslint-disable-next-line no-unused-vars
45
import { fbgraph } from 'fbgraph';
56
// Should keep named imports
67
import { toUpper } from 'lodash';
@@ -11,7 +12,7 @@ function getMessage() {
1112
return isEqual(true, false) ? 'noop' : toUpper('hello fb & aws');
1213
}
1314

14-
export const hello = function (event, context, cb) {
15+
export const hello = function (event, _, cb) {
1516
const message = getMessage();
1617
cb(null, { message, event });
1718
};
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1+
/* eslint-disable no-unused-vars */
12
'use strict';
23

34
const AWS = require('aws-sdk');
45
const fbgraph = require('fbgraph');
56

6-
module.exports.hello = function (event, context, cb) {
7+
module.exports.hello = function (event, _, cb) {
78
cb(null, { message: 'hello fb & aws', event });
89
};

package-lock.json

Lines changed: 94 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"scripts": {
3131
"test": "jest --verbose",
3232
"test-coverage": "jest --coverage",
33-
"eslint": "eslint --ext .js *.js lib tests"
33+
"eslint": "eslint ."
3434
},
3535
"dependencies": {
3636
"archiver": "^5.3.1",
@@ -54,6 +54,7 @@
5454
"eslint-plugin-lodash": "^7.4.0",
5555
"eslint-plugin-prettier": "^4.2.1",
5656
"eslint-plugin-promise": "^6.1.1",
57+
"eslint-plugin-yml": "^1.3.0",
5758
"husky": "^4.3.8",
5859
"jest": "^27.5.1",
5960
"lint-staged": "^10.5.4",

0 commit comments

Comments
 (0)