Skip to content

Instantly share code, notes, and snippets.

@bantic
Last active April 14, 2025 10:15
Show Gist options
  • Save bantic/da604b51a8d412cf76a9e32064872fb9 to your computer and use it in GitHub Desktop.
Save bantic/da604b51a8d412cf76a9e32064872fb9 to your computer and use it in GitHub Desktop.

Revisions

  1. bantic revised this gist Apr 14, 2025. No changes.
  2. bantic created this gist Apr 14, 2025.
    16 changes: 16 additions & 0 deletions .eslintrc.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    // eslint-disable-next-line no-undef
    module.exports = {
    // If the line below is commented out, the eslint default parser is used,
    // and the parserOptions.ecmaVersion becomes meaningful; it must be incremented
    // to a value greater than 2024 to parse the entire test.js file.
    // When the babel eslint-parser is used, the ecmaVersion option is ignored.
    parser: "@babel/eslint-parser",
    parserOptions: {
    ecmaVersion: 2017,
    requireConfigFile: false,
    babelOptions: {
    plugins: [["@babel/plugin-proposal-decorators", { version: "2023-11" }]],
    },
    },
    extends: ["eslint:recommended"],
    };
    17 changes: 17 additions & 0 deletions package.json
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    {
    "name": "test-eslint",
    "version": "1.0.0",
    "description": "",
    "main": "index.js",
    "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
    },
    "keywords": [],
    "author": "",
    "license": "ISC",
    "devDependencies": {
    "@babel/eslint-parser": "^7.27.0",
    "@babel/plugin-proposal-decorators": "^7.25.9",
    "eslint": "^8.0.0"
    }
    }
    22 changes: 22 additions & 0 deletions test.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,22 @@
    let tests = {};

    tests.objspread = { ...{} }; // es2018
    tests.bign_syntaxt = 10n; // es2020
    let undef;
    tests.nullish = undef ?? "foo"; // es2020
    tests.logical_assign ??= true; // es2021
    tests.regexp_indices = /foo/dg; // es2022
    tests.regexp_unicode = /foo/v; // es2024

    // class annotation below requires:
    // parser: @babel/eslint-parser
    // with babelOptions:
    // plugins: [["@babel/plugin-proposal-decorators", { version: "2023-11" }]],

    // @annotation
    // // eslint-disable-next-line no-unused-vars
    // class MyClass {}

    // function annotation(target) {
    // target.annotated = true;
    // }