Hi all! Does anyone have an eslint config they pre...
# suitescript
k
Hi all! Does anyone have an eslint config they prefer for working with SuiteScript 2?
m
Copy code
const LEGACY_SUITE_SCRIPT_1_FILES = [];

// eslint-disable-next-line no-undef
module.exports = exports = {
  root: true,
  parserOptions: { ecmaVersion: "latest" },
  plugins: ["jsdoc", "suitescript", "@typescript-eslint"],
  extends: [
    "eslint:recommended",
    "plugin:@typescript-eslint/recommended",
    "google",
    "prettier",
    "plugin:jsdoc/recommended",
    "plugin:suitescript/recommended",
  ],
  rules: {
    "valid-jsdoc": "off",
    "jsdoc/require-param-description": "off",
    "jsdoc/valid-types": "off",
    "jsdoc/check-alignment": "off",
    "jsdoc/tag-lines": "off",
  },
  overrides: [
    {
      files: "*.js",
      excludedFiles: LEGACY_SUITE_SCRIPT_1_FILES,
      env: {
        amd: true,
        es6: true,
        browser: true,
      },
      globals: {
        log: "readonly",
      },
      rules: {
        // Rules to enforce modern (ES6+) JavaScript
        "@typescript-eslint/prefer-for-of": "error",
        "arrow-body-style": ["error", "as-needed"],
        "no-var": "error",
        "object-shorthand": ["error", "always"],
        "prefer-arrow-callback": "error",
        "prefer-template": "error",
        "prefer-const": "error",
        "prefer-destructuring": ["error", { object: true, array: true }],
        "prefer-rest-params": "error",
        "prefer-spread": "error",
        "prefer-object-spread": "error",

        "jsdoc/check-tag-names": [
          "error",
          {
            definedTags: ["NApiVersion", "NScriptType", "NModuleScope"],
          },
        ],

        "suitescript/log-args": ["error", { requireDetails: false }],
      },
    },
    {
      files: LEGACY_SUITE_SCRIPT_1_FILES,
      parserOptions: { ecmaVersion: 5 },
      env: {
        es6: false,
        browser: true,
        "suitescript/suitescript1": true,
      },
      rules: {
        "no-var": "off",
        "@typescript-eslint/no-this-alias": "off",
        "@typescript-eslint/no-unused-vars": "off", // duplicate of no-unused-vars
        "no-invalid-this": "off",
        "new-cap": [
          "error",
          {
            newIsCapExceptions: [
              "nlobjCredentialBuilder",
              "nlobjSearchColumn",
              "nlobjSearchFilter",
            ],
          },
        ],
        "jsdoc/no-defaults": "off",
        "jsdoc/no-undefined-types": [
          "warn",
          {
            definedTypes: [
              "NLObjForm",
              "NLObjRecord",
              "NLObjRecord",
              "NLObjRequest",
              "NLObjResponse",
              "NLObjSearch",
              "NLObjSearchColumn",
              "NLObjSearchFilter",
              "NLObjSearchResult",
              "NLObjServerResponse",
            ],
          },
        ],
      },
    },
  ],
};
👍 1
k
Nice! How are you transpiling / uploading your scripts?
m
I'm not transpiling, I use Typescript only in JSDoc
k
Oh ok cool 🙂
I'm using typescript in JSDoc at the moment but didn't think to put it in eslint. 🙂
e
I use similar plugins as above with very few overrides:
Copy code
extends: [
    "eslint:recommended",
    "google",
    "plugin:jsdoc/recommended",
    "plugin:suitescript/recommended",
  ],
👍 1
k
I'm using similar but with airbnb instead of google
👍 1
e
There's also https://standardjs.com/ that I recently came across and might look into using