Skip to content

Commit

Permalink
feat(eslint): support yml and expand lint scope
Browse files Browse the repository at this point in the history
  • Loading branch information
vicary committed Dec 16, 2022
1 parent a919614 commit 377a5b9
Show file tree
Hide file tree
Showing 9 changed files with 144 additions and 34 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules/
52 changes: 31 additions & 21 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
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'
}
]
8 changes: 4 additions & 4 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ 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
Expand Down
7 changes: 4 additions & 3 deletions examples/babel-multiple-statically-entries/first.js
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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 377a5b9

Please sign in to comment.