Skip to content

Make the whole rambda type definition immutable #560

@peterreisz

Description

@peterreisz

It is an immutable library, so all the typings should be readonly and ReadonlyArray.

Eslint has a plugin for it (in the eslint-plugin-functional package), so it can be automatized:

Minimum eslint config only for this rule:

module.exports = {
  root: true,
  env: {
    browser: true,
    node: true,
    es6: true,
    jest: true,
  },
  parser: '@typescript-eslint/parser',
  plugins: ['@typescript-eslint', 'functional'],
  extends: [
  ],
  parserOptions: {
    project: './tsconfig.json',
  },
  rules: {
    'functional/prefer-readonly-type': [
      1
    ]
  },
}

The following command will do all the work (you will need a tsconfig.json):

eslint -c .eslintrc.js index.d.ts --fix

On the latest version (6.3.1) it founds and fixes 255 non-readonly types.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions