Skip to content

[BUG] Lint rules missing some ESM components #5

@js07

Description

@js07

Describe the bug
Some ESM components seem to not be validated according to eslint-plugin-pipedream rules. Specifically, the linter misses components whose default export declaration is preceded by other statements. For example:

❌ The component in the following file would not be linted because the export default declaration is the 4th statement.

import { axios } from "@pipedream/platform";
import spotify from "../../spotify.app.mjs";
import get from "lodash/get.js";

export default {
  name: "Add Items to a Playlist",
  description: "Add one or more items to a user’s playlist. [See the docs here](https://developer.spotify.com/documentation/web-api/reference/#/operations/add-tracks-to-playlist).",
  // ...

✅ The component in the following file would be linted because the export default declaration is the 1st statement.

export default {
  name: "Add Items to a Playlist",
  description: "Add one or more items to a user’s playlist. [See the docs here](https://developer.spotify.com/documentation/web-api/reference/#/operations/add-tracks-to-playlist).",
  // ...

To Reproduce

  1. Clone the repo
git clone https://github.com/PipedreamHQ/pipedream.git
cd pipedream
  1. Install dependencies
npm install
  1. Open file components/spotify/actions/add-items-to-playlist/add-items-to-playlist.mjs
  2. Remove line 10 (type: "action",) and save file
  3. Run ESLint on file
npx eslint ./components/spotify/actions/add-items-to-playlist/add-items-to-playlist.mjs
  1. Don't see expected error:
Components must export a type property ("source" or "action") eslint(pipedream/required-properties-type)

Expected behavior
Components whose default export declaration is preceded by other statements are linted.

Additional context
The isDefaultExport function checks if the first element of the node.body has type DefaultExportDeclaration, but not other elements in node.body.

  • Node.js v14.18.1
  • ESLint v7.26.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions