dankogai / js-base64

Base64 implementation for JavaScript
BSD 3-Clause "New" or "Revised" License
4.27k stars 1.33k forks source link

Usage of reserved word for a const. #138

Closed LaseII closed 3 years ago

LaseII commented 3 years ago

Hello,

Not sure if that is causing my issue


          ES-Check Error:
          ----
          · erroring file: myFile.js // here i do use js-base64 package
          · error: SyntaxError: The keyword 'const' is reserved (1:2882)
          · see the printed err.stack below for context
          ----
          SyntaxError: The keyword 'const' is reserved (1:2882)

But shouldn't this package avoid using reserved names. const encodeURI = (src) => encode(src, true);

LaseII commented 3 years ago

Who is willing to help with that to avoid a breaking change? And if this isn't an issue happy if someone could help me understanding my ES-Check Error.

LaseII commented 3 years ago
js-base64 git:(main) ✗ eslint base64.js

/Users/dlubos/Documents/GitHub/js-base64/base64.js
    6:1   error  Unnecessary semicolon                                        @typescript-eslint/no-extra-semi
    9:43  error  'define' is not defined                                      no-undef
   10:11  error  'define' is not defined                                      no-undef
   21:17  error  'Base64' is not defined                                      no-undef
   60:30  error  Unnecessary escape character: \/                             no-useless-escape
   60:52  error  Unnecessary escape character: \/                             no-useless-escape
   60:76  error  Unnecessary escape character: \/                             no-useless-escape
   66:17  error  Unnecessary escape character: \/                             no-useless-escape
   68:47  error  Unnecessary escape character: \+                             no-useless-escape
   68:49  error  Unnecessary escape character: \/                             no-useless-escape
  128:13  error  'cc' is already defined                                      no-redeclare
  137:17  error  Unexpected control character(s) in regular expression: \x00  no-control-regex
  249:27  error  Unnecessary escape character: \+                             no-useless-escape

✖ 13 problems (13 errors, 0 warnings)
  1 error and 0 warnings potentially fixable with the `--fix` option.

with following eslintrc.js

module.exports = {
  env: {
    browser: true,
    es6: true,
    node: true
  },
  ignorePatterns: [
    "*.d.ts",
    "node_modules",
    "dist",
    "src/tools/testing",
    "rendering-engine",
    "**/__tests__/**",
    "**/__mocks__/**"
  ],
  overrides: [
    {
      files: ["*.ts", "*.tsx"],
      extends: [
        "plugin:@typescript-eslint/recommended",
        "plugin:sonarjs/recommended",
        "prettier/@typescript-eslint",
        "plugin:prettier/recommended"
      ],
      parser: "@typescript-eslint/parser",
      parserOptions: {
        project: "tsconfig.json",
        sourceType: "module"
      },
      plugins: [
        "sonarjs",
        "eslint-plugin-import",
        "@typescript-eslint",
        "@typescript-eslint/tslint"
      ],
      rules: {
        "@typescript-eslint/explicit-member-accessibility": [
          "off",
          {
            accessibility: "explicit"
          }
        ],
        "@typescript-eslint/no-explicit-any": "error",
        "@typescript-eslint/no-non-null-assertion": "error",
        "@typescript-eslint/no-var-requires": "off",
        "@typescript-eslint/naming-convention": "off",
        "@typescript-eslint/explicit-module-boundary-types": "off",
        "comma-dangle": "off",
        "import/no-extraneous-dependencies": "off",
        "import/no-internal-modules": "off",
        "max-classes-per-file": "off",
        "no-console": "warn",
        "sonarjs/cognitive-complexity": "warn",
        "@typescript-eslint/no-inferrable-types": "warn",
        "@typescript-eslint/ban-ts-comment": "warn"
      }
    }
  ]
};
LaseII commented 3 years ago
js-base64 git:(main) ✗ eslint base64.ts

/Users/dlubos/Documents/GitHub/js-base64/base64.ts
   26:9   error    'tab' is never reassigned. Use 'const' instead               prefer-const
   31:20  error    Unnecessary escape character: \/                             no-useless-escape
   31:42  error    Unnecessary escape character: \/                             no-useless-escape
   31:66  error    Unnecessary escape character: \/                             no-useless-escape
   38:17  error    Unnecessary escape character: \/                             no-useless-escape
   40:55  error    Unnecessary escape character: \+                             no-useless-escape
   40:57  error    Unnecessary escape character: \/                             no-useless-escape
   44:22  warning  Missing return type on function                              @typescript-eslint/explicit-module-boundary-types
   74:13  error    'strs' is never reassigned. Use 'const' instead              prefer-const
   76:23  error    Use the spread operator instead of '.apply()'                prefer-spread
   85:24  warning  Missing return type on function                              @typescript-eslint/explicit-module-boundary-types
   92:9   error    Unexpected var, use let or const instead                     no-var
  100:9   error    Unexpected var, use let or const instead                     no-var
  109:17  error    Unexpected control character(s) in regular expression: \x00  no-control-regex
  115:14  warning  Missing return type on function                              @typescript-eslint/explicit-module-boundary-types
  127:16  warning  Missing return type on function                              @typescript-eslint/explicit-module-boundary-types
  134:19  warning  Missing return type on function                              @typescript-eslint/explicit-module-boundary-types
  142:13  error    Unexpected var, use let or const instead                     no-var
  167:14  warning  Missing return type on function                              @typescript-eslint/explicit-module-boundary-types
  171:22  warning  Missing return type on function                              @typescript-eslint/explicit-module-boundary-types
  217:16  warning  Missing return type on function                              @typescript-eslint/explicit-module-boundary-types
  222:17  warning  Missing return type on function                              @typescript-eslint/explicit-module-boundary-types
  222:18  warning  Argument 'src' should be typed with a non-any type           @typescript-eslint/explicit-module-boundary-types
  222:23  warning  Unexpected any. Specify a different type                     @typescript-eslint/no-explicit-any
  225:27  error    Unnecessary escape character: \+                             no-useless-escape
  236:22  warning  Missing return type on function                              @typescript-eslint/explicit-module-boundary-types
  249:26  warning  Missing return type on function                              @typescript-eslint/explicit-module-boundary-types
  260:24  warning  Missing return type on function                              @typescript-eslint/explicit-module-boundary-types

✖ 28 problems (14 errors, 14 warnings)
  2 errors and 0 warnings potentially fixable with the `--fix` option.
LaseII commented 3 years ago

maybe this is not really an issue as we should not parse node_modules in our repo. So feel free to ignore this but would recommend some linting in general for this repo, wdyt ?