diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 0000000000..c2658d7d1b --- /dev/null +++ b/.eslintignore @@ -0,0 +1 @@ +node_modules/ diff --git a/.eslintrc.yml b/.eslintrc.yml index 5e4560c791..449b93417d 100644 --- a/.eslintrc.yml +++ b/.eslintrc.yml @@ -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 @@ -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' + } + ] diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 76ff11f1dd..c506df5f56 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -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 diff --git a/examples/babel-multiple-statically-entries/first.js b/examples/babel-multiple-statically-entries/first.js index b6be064f4e..8fa0419e41 100644 --- a/examples/babel-multiple-statically-entries/first.js +++ b/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 diff --git a/examples/babel-multiple-statically-entries/second.js b/examples/babel-multiple-statically-entries/second.js index ac76a34ad7..f2c31f3fe2 100644 --- a/examples/babel-multiple-statically-entries/second.js +++ b/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 diff --git a/examples/include-external-npm-packages-lock-file/handler.js b/examples/include-external-npm-packages-lock-file/handler.js index 17621c6ae9..af7f265ba0 100644 --- a/examples/include-external-npm-packages-lock-file/handler.js +++ b/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'; @@ -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 }); }; diff --git a/examples/include-external-npm-packages/handler.js b/examples/include-external-npm-packages/handler.js index e37d2c6042..8632f25e14 100644 --- a/examples/include-external-npm-packages/handler.js +++ b/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 }); }; diff --git a/package-lock.json b/package-lock.json index 6e2fb68f91..0127d5151b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -30,6 +30,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", @@ -5235,6 +5236,27 @@ "eslint": "^7.0.0 || ^8.0.0" } }, + "node_modules/eslint-plugin-yml": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-yml/-/eslint-plugin-yml-1.3.0.tgz", + "integrity": "sha512-TEkIaxutVPRZMRc0zOVptP/vmrf1td/9woUAiKII4kRLJLWWUCz1CYM98NsAfeOrVejFBFhHCSwOp+C1TqmtRg==", + "dev": true, + "dependencies": { + "debug": "^4.3.2", + "lodash": "^4.17.21", + "natural-compare": "^1.4.0", + "yaml-eslint-parser": "^1.1.0" + }, + "engines": { + "node": "^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/ota-meshi" + }, + "peerDependencies": { + "eslint": ">=6.0.0" + } + }, "node_modules/eslint-scope": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.1.tgz", @@ -14194,6 +14216,41 @@ "integrity": "sha512-2PTINUwsRqSd+s8XxKaJWQlUuEMHJQyEuh2edBbW8KNJz0SJPwUSD2zRWqezFEdN7IzAgeuYHFUCF7o8zRdZ0A==", "dev": true }, + "node_modules/yaml-eslint-parser": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/yaml-eslint-parser/-/yaml-eslint-parser-1.1.0.tgz", + "integrity": "sha512-b464Q1fYiX1oYx2kE8k4mEp6S9Prk+tfDsY/IPxQ0FCjEuj3AKko5Skf3/yQJeYTTDyjDE+aWIJemnv29HvEWQ==", + "dev": true, + "dependencies": { + "eslint-visitor-keys": "^3.0.0", + "lodash": "^4.17.21", + "yaml": "^2.0.0" + }, + "engines": { + "node": "^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/ota-meshi" + } + }, + "node_modules/yaml-eslint-parser/node_modules/eslint-visitor-keys": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.3.0.tgz", + "integrity": "sha512-mQ+suqKJVyeuwGYHAdjMFqjCyfl8+Ldnxuyp3ldiMBFKkvytrXUZWaiPCEav8qDHKty44bD+qV1IP4T+w+xXRA==", + "dev": true, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + } + }, + "node_modules/yaml-eslint-parser/node_modules/yaml": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.1.3.tgz", + "integrity": "sha512-AacA8nRULjKMX2DvWvOAdBZMOfQlypSFkjcOcu9FalllIDJ1kvlREzcdIZmidQUqqeMv7jorHjq2HlLv/+c2lg==", + "dev": true, + "engines": { + "node": ">= 14" + } + }, "node_modules/yamljs": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/yamljs/-/yamljs-0.3.0.tgz", @@ -18581,6 +18638,18 @@ "dev": true, "requires": {} }, + "eslint-plugin-yml": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-yml/-/eslint-plugin-yml-1.3.0.tgz", + "integrity": "sha512-TEkIaxutVPRZMRc0zOVptP/vmrf1td/9woUAiKII4kRLJLWWUCz1CYM98NsAfeOrVejFBFhHCSwOp+C1TqmtRg==", + "dev": true, + "requires": { + "debug": "^4.3.2", + "lodash": "^4.17.21", + "natural-compare": "^1.4.0", + "yaml-eslint-parser": "^1.1.0" + } + }, "eslint-scope": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.1.tgz", @@ -25139,6 +25208,31 @@ "integrity": "sha512-2PTINUwsRqSd+s8XxKaJWQlUuEMHJQyEuh2edBbW8KNJz0SJPwUSD2zRWqezFEdN7IzAgeuYHFUCF7o8zRdZ0A==", "dev": true }, + "yaml-eslint-parser": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/yaml-eslint-parser/-/yaml-eslint-parser-1.1.0.tgz", + "integrity": "sha512-b464Q1fYiX1oYx2kE8k4mEp6S9Prk+tfDsY/IPxQ0FCjEuj3AKko5Skf3/yQJeYTTDyjDE+aWIJemnv29HvEWQ==", + "dev": true, + "requires": { + "eslint-visitor-keys": "^3.0.0", + "lodash": "^4.17.21", + "yaml": "^2.0.0" + }, + "dependencies": { + "eslint-visitor-keys": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.3.0.tgz", + "integrity": "sha512-mQ+suqKJVyeuwGYHAdjMFqjCyfl8+Ldnxuyp3ldiMBFKkvytrXUZWaiPCEav8qDHKty44bD+qV1IP4T+w+xXRA==", + "dev": true + }, + "yaml": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.1.3.tgz", + "integrity": "sha512-AacA8nRULjKMX2DvWvOAdBZMOfQlypSFkjcOcu9FalllIDJ1kvlREzcdIZmidQUqqeMv7jorHjq2HlLv/+c2lg==", + "dev": true + } + } + }, "yamljs": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/yamljs/-/yamljs-0.3.0.tgz", diff --git a/package.json b/package.json index 7e9ba9ab0e..b98515864b 100644 --- a/package.json +++ b/package.json @@ -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", @@ -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",