Skip to content

Commit

Permalink
Merge pull request #1319 from serverless-heaven/feat/eslint-yaml
Browse files Browse the repository at this point in the history
chore(eslint): support yml and expand lint scope
  • Loading branch information
j0k3r committed Dec 16, 2022
2 parents 333b1fe + 7bfff4d commit d49ff92
Show file tree
Hide file tree
Showing 8 changed files with 144 additions and 35 deletions.
52 changes: 31 additions & 21 deletions .eslintrc.yml
Expand Up @@ -11,7 +11,12 @@ extends:
- plugin:import/errors
- plugin:import/warnings
- prettier
parser: "@babel/eslint-parser"
overrides:
- files:
- '*.yml'
- '*.yaml'
parser: 'yaml-eslint-parser'
parser: '@babel/eslint-parser'
parserOptions:
requireConfigFile: false
sourceType: module
Expand All @@ -20,36 +25,41 @@ plugins:
- lodash
- import
- prettier
- yml
rules:
linebreak-style: [ error, unix ]
semi: [ error, always ]
quotes: [ error, single, { avoidEscape: true } ]
linebreak-style: [error, unix]
semi: [error, always]
quotes: [error, single, { avoidEscape: true }]
no-mixed-spaces-and-tabs: error
space-before-blocks: error
arrow-spacing: error
key-spacing: [ error, { afterColon: true, mode: minimum } ]
brace-style: [ error, '1tbs' ]
comma-spacing: [ error, { before: false, after: true } ]
comma-style: [ error, last, { exceptions: { VariableDeclaration: true } } ]
computed-property-spacing: [ error, never ]
object-curly-spacing: [ error, always ]
key-spacing: [error, { afterColon: true, mode: minimum }]
brace-style: [error, '1tbs']
comma-spacing: [error, { before: false, after: true }]
comma-style: [error, last, { exceptions: { VariableDeclaration: true } }]
computed-property-spacing: [error, never]
object-curly-spacing: [error, always]
prefer-const: error
no-var: error
promise/no-nesting: off
import/first: error
import/newline-after-import: error
import/no-named-as-default: off
import/no-extraneous-dependencies: [ error, { devDependencies: true } ]
import/no-extraneous-dependencies: [error, { devDependencies: true }]
lodash/import-scope: off
lodash/preferred-alias: off
lodash/prop-shorthand: off
lodash/prefer-lodash-method: [ error, { ignoreObjects: [ BbPromise, path ] } ]
max-len: [ error, { code: 120, ignoreStrings: true, ignoreComments: true, ignoreTemplateLiterals: true } ]
prettier/prettier: [ error, {
printWidth: 120,
arrowParens: 'avoid',
bracketSpacing: true,
semi: true,
singleQuote: true,
trailingComma: 'none',
} ]
lodash/prefer-lodash-method: [error, { ignoreObjects: [BbPromise, path] }]
max-len: [error, { code: 120, ignoreStrings: true, ignoreComments: true, ignoreTemplateLiterals: true }]
prettier/prettier:
[
error,
{
printWidth: 120,
arrowParens: 'avoid',
bracketSpacing: true,
semi: true,
singleQuote: true,
trailingComma: 'none'
}
]
10 changes: 5 additions & 5 deletions .github/workflows/lint.yml
Expand Up @@ -17,17 +17,17 @@ jobs:

steps:
- name: "Checkout"
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
fetch-depth: 2
fetch-depth: 0

- name: "Install Node.js"
uses: actions/setup-node@v2
uses: actions/setup-node@v3
with:
node-version: "12"
node-version: 16

- name: "Install dependencies"
run: npm ci

- name: "Lint files"
run: "npm run eslint"
run: "npm run eslint -- --ignore-pattern examples/"
7 changes: 4 additions & 3 deletions examples/babel-multiple-statically-entries/first.js
@@ -1,8 +1,9 @@
export const hello = (event, context, cb) => {
const p = new Promise((resolve, reject) => {
/* eslint-disable promise/no-callback-in-promise */
export const hello = (event, _, cb) => {
const p = new Promise(resolve => {
resolve('success');
});
p.then(r =>
p.then(() =>
cb(null, {
message: 'Go Serverless Webpack (Babel) v1.0! First module!',
event
Expand Down
7 changes: 4 additions & 3 deletions examples/babel-multiple-statically-entries/second.js
@@ -1,8 +1,9 @@
export const hello = (event, context, cb) => {
const p = new Promise((resolve, reject) => {
/* eslint-disable promise/no-callback-in-promise */
export const hello = (event, _, cb) => {
const p = new Promise(resolve => {
resolve('success');
});
p.then(r =>
p.then(() =>
cb(null, {
message: 'Go Serverless Webpack (Babel) v1.0! Second module!',
event
Expand Down
3 changes: 2 additions & 1 deletion examples/include-external-npm-packages-lock-file/handler.js
@@ -1,6 +1,7 @@
// Should keep side-effects scripts
import 'dotenv/config';
// Should be included as fbgraph is not marked as sideEffect free
// eslint-disable-next-line no-unused-vars
import { fbgraph } from 'fbgraph';
// Should keep named imports
import { toUpper } from 'lodash';
Expand All @@ -11,7 +12,7 @@ function getMessage() {
return isEqual(true, false) ? 'noop' : toUpper('hello fb & aws');
}

export const hello = function (event, context, cb) {
export const hello = function (event, _, cb) {
const message = getMessage();
cb(null, { message, event });
};
3 changes: 2 additions & 1 deletion examples/include-external-npm-packages/handler.js
@@ -1,8 +1,9 @@
/* eslint-disable no-unused-vars */
'use strict';

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

module.exports.hello = function (event, context, cb) {
module.exports.hello = function (event, _, cb) {
cb(null, { message: 'hello fb & aws', event });
};
94 changes: 94 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Expand Up @@ -30,7 +30,7 @@
"scripts": {
"test": "jest --verbose",
"test-coverage": "jest --coverage",
"eslint": "eslint --ext .js *.js lib tests"
"eslint": "eslint ."
},
"dependencies": {
"archiver": "^5.3.1",
Expand All @@ -54,6 +54,7 @@
"eslint-plugin-lodash": "^7.4.0",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-promise": "^6.1.1",
"eslint-plugin-yml": "^1.3.0",
"husky": "^4.3.8",
"jest": "^27.5.1",
"lint-staged": "^10.5.4",
Expand Down

0 comments on commit d49ff92

Please sign in to comment.