Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new prefer-readonly-type rule #237

Closed
wants to merge 20 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
a0c5d09
chore: update minimum required node version to 12
RebeccaStevens Jul 22, 2021
d880946
chore: remove deprecated stylitic ruleset
RebeccaStevens Jul 22, 2021
dcb7f83
chore: set up new linting rules
RebeccaStevens Jul 22, 2021
bd8d550
chore: use the default linting output format
RebeccaStevens Jul 22, 2021
d01bc54
style: update file linting
RebeccaStevens Jul 22, 2021
b200df9
chore: remove unneeded incompatible dev-dependencies
RebeccaStevens Jul 22, 2021
e45c571
fix: bring rule meta data "recommended" into line with the recommend …
RebeccaStevens Jan 6, 2021
79d461a
chore: remove deprecated rule: prefer-type-literal
RebeccaStevens Jul 24, 2021
9898ab6
chore: setup tspaths
RebeccaStevens Jul 24, 2021
562b78f
chore: switch testing over to ava
RebeccaStevens Jul 24, 2021
df9fe59
chore: rename the test tsconfig file to avoid ides using it as an act…
RebeccaStevens Jul 24, 2021
e96541b
feat(external-recommended): update recommended external rules
RebeccaStevens Jul 25, 2021
dd0e499
feat: add stylistic rules to lite and recommended rule sets
RebeccaStevens Jul 25, 2021
62b1242
chore: update vscode launch config for ava
RebeccaStevens Jul 26, 2021
5ce1f0f
chore: fix testing of work file
RebeccaStevens Jul 26, 2021
f10e4cc
style: remove useless catch
RebeccaStevens Jul 30, 2021
c4ccf3d
docs: update readme for recommended standard rules
RebeccaStevens Jul 31, 2021
a37f2d3
feat(prefer-readonly-type): turn option "allowMutableReturnType" on b…
RebeccaStevens Jul 25, 2021
929ba5f
test(prefer-readonly-type): update rule test for new behavior
RebeccaStevens Jul 25, 2021
0e75bbe
fix: don't mark type aliases as violations
RebeccaStevens Jul 25, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
164 changes: 14 additions & 150 deletions .eslintrc.json
Expand Up @@ -6,7 +6,6 @@
"eslint-plugin",
"functional",
"import",
"jest",
"jsdoc",
"prettier"
],
Expand All @@ -15,173 +14,38 @@
"node": true
},
"extends": [
"eslint:recommended",
"plugin:import/errors",
"plugin:import/warnings",
"plugin:import/typescript",
"@rebeccastevens/eslint-config/modern",
"@rebeccastevens/eslint-config/typescript",
"@rebeccastevens/eslint-config/common-overrides",
"plugin:eslint-plugin/recommended",
"plugin:functional/recommended",
"plugin:prettier/recommended",
"prettier"
],
"parserOptions": {
"ecmaVersion": 10,
"project": [
"./tsconfig.json",
"./tests/tsconfig.json"
],
"project": ["./tsconfig.json", "./tests/tsconfig.json"],
"sourceType": "module"
},
"ignorePatterns": [
"build/",
"lib/"
],
"ignorePatterns": ["build/", "coverage/", "lib/"],
"rules": {
// Built in.
"no-param-reassign": "error",
"no-var": "error",
// Our rules.
"functional/prefer-readonly-type": [
"error",
{
"allowMutableReturnType": true
}
],
"functional/no-conditional-statement": [
"error",
{
"allowReturningBranches": true
}
],
"functional/functional-parameters": [
"error",
{
"ignorePattern": [
"^tsInstalled$"
]
}
]
"@typescript-eslint/no-unnecessary-condition": "off",
"import/no-relative-parent-imports": "error",
"node/no-unsupported-features/es-builtins": "off",
"node/no-unsupported-features/es-syntax": "off",
// enable once supported in all our supported node versions.
"unicorn/prefer-node-protocol": "off"
},
"overrides": [
// Top level files.
{
"files": [
"*"
],
"files": ["*"],
"rules": {
"functional/immutable-data": "off",
"functional/functional-parameters": "off",
"functional/no-expression-statement": "off"
}
},
// TypeScript files.
{
"files": [
"**/*.ts"
],
"extends": [
"plugin:@typescript-eslint/recommended"
],
"rules": {
"@typescript-eslint/array-type": [
"error",
{
"default": "generic"
}
],
"@typescript-eslint/ban-types": [
"error",
{
"types": {
"Object": {
"message": "Use object instead",
"fixWith": "object"
},
"{}": false,
"object": false
},
"extendDefaults": true
}
],
"@typescript-eslint/prefer-interface": "off",
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/no-require-imports": "error",
"@typescript-eslint/no-var-requires": "off",
"@typescript-eslint/no-unused-vars": "off",
"@typescript-eslint/no-unused-vars-experimental": [
"warn",
{
"ignoredNamesRegex": "^_",
"ignoreArgsIfArgsAfterAreUsed": true
}
],
"@typescript-eslint/no-use-before-define": [
"error",
{
"functions": false,
"classes": true,
"variables": true,
"typedefs": true
}
]
}
},
// Source files.
{
"files": [
"src/**/*"
],
"rules": {
// JSDoc.
"jsdoc/check-alignment": "warn",
"jsdoc/check-indentation": "warn",
"jsdoc/check-param-names": "warn",
"jsdoc/check-tag-names": "warn",
"jsdoc/implements-on-classes": "warn",
"jsdoc/newline-after-description": "warn",
"jsdoc/no-types": "warn",
"jsdoc/require-description": "warn",
"jsdoc/require-description-complete-sentence": "warn",
"jsdoc/require-hyphen-before-param-description": "warn",
"jsdoc/require-jsdoc": "warn",
"jsdoc/require-param-description": "warn",
"jsdoc/require-param-name": "warn",
"jsdoc/require-returns-check": "warn",
"jsdoc/require-returns-description": "warn"
}
},
// Testing Files.
{
"files": [
"tests/**/*"
],
"env": {
"jest/globals": true
},
"extends": [
"plugin:jest/recommended"
],
"rules": {
"functional/functional-parameters": "off",
"functional/no-conditional-statement": "off",
"functional/no-expression-statement": "off",
"jest/no-alias-methods": "error",
"jest/no-test-return-statement": "error",
"jest/prefer-called-with": "warn",
"jest/prefer-expect-assertions": "error",
"jest/prefer-spy-on": "warn",
"jest/prefer-strict-equal": "warn",
"jest/prefer-to-be-null": "warn",
"jest/prefer-to-be-undefined": "warn",
"jest/prefer-to-contain": "warn",
"jest/prefer-to-have-length": "warn",
"jest/prefer-todo": "error"
"functional/no-throw-statement": "off"
}
}
],
"settings": {
"import/ignore": [
"escape-string-regexp"
]
}
]
}
36 changes: 18 additions & 18 deletions .github/workflows/ci.yml
Expand Up @@ -30,7 +30,7 @@ jobs:
- name: Setup NodeJs
uses: actions/setup-node@v1
with:
node-version: "14"
node-version: "16"

- name: Install Dependencies
run: yarn install --frozen-lockfile
Expand All @@ -48,10 +48,9 @@ jobs:
os:
- "ubuntu-latest"
node_version:
- "10"
- "12"
- "14"
- "15"
- "16"
ts_version:
- "next"
- "latest"
Expand All @@ -60,19 +59,18 @@ jobs:
runs-on: ${{ matrix.os }}
continue-on-error: ${{ matrix.ts_version == 'next' }}
env:
# Use compiled tests on everything instances except this one.
USE_COMPILED_TEST: ${{ fromJSON('["false", "true"]')[matrix.ts_version != 'latest' || matrix.node_version != '14' || matrix.os != 'ubuntu-latest'] }}
REPORT_COVERAGE: ${{ fromJSON('["false", "true"]')[matrix.ts_version == 'latest' && matrix.node_version == '16' && matrix.os != 'ubuntu-latest'] }}
steps:
- name: Checkout
uses: actions/checkout@v2
with:
# Fetch all commits for codecov.
fetch-depth: ${{ fromJSON('[0, 1]')[ env.USE_COMPILED_TEST == 'true'] }}
fetch-depth: ${{ fromJSON('[0, 1]')[ env.REPORT_COVERAGE == 'true'] }}

- name: Setup NodeJs
- name: Setup NodeJs for building
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node_version }}
node-version: "16"

- name: Install Dependencies
run: yarn install --frozen-lockfile
Expand All @@ -81,26 +79,28 @@ jobs:
run: yarn build

- name: Compile Tests
if: env.USE_COMPILED_TEST == 'true'
if: env.REPORT_COVERAGE == 'false'
run: yarn compile-tests

- name: Setup NodeJs ${{ matrix.node_version }} for testing
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node_version }}

- name: Remove Dev TypeScript
run: yarn remove typescript
run: yarn remove typescript --ignore-engines

- name: Add TypeScript "${{ matrix.ts_version }}"
if: matrix.ts_version != 'JS'
run: yarn add -D typescript@"${{ matrix.ts_version }}"
run: yarn add -D typescript@"${{ matrix.ts_version }}" --ignore-engines

- name: Run Tests (Uncompiled)
if: env.USE_COMPILED_TEST != 'true'
- name: Run Tests
run: yarn test

- name: Run Tests (Compiled)
if: env.USE_COMPILED_TEST == 'true'
run: yarn test-compiled
env:
USE_COMPILED_TESTS: ${{ env.REPORT_COVERAGE == 'false' }}

- name: Report coverage
uses: codecov/codecov-action@v1
if: env.USE_COMPILED_TEST != 'true'
if: env.REPORT_COVERAGE == 'true'
with:
file: coverage/lcov.info
2 changes: 1 addition & 1 deletion .gitignore
@@ -1,7 +1,7 @@
.DS_Store
thumbs.db
*.log
.rpt2_cache/
.nyc_output/
node_modules/
/build/
/lib/
Expand Down
20 changes: 20 additions & 0 deletions .nycrc
@@ -0,0 +1,20 @@
{
"extends": "@istanbuljs/nyc-config-typescript",
"include": [
"src/**/*"
],
"exclude": [
"src/util/conditional-imports/**/*"
],
"reporter": [
"lcov",
"text"
],
"check-coverage": false,
"watermarks": {
"lines": [80, 95],
"functions": [80, 95],
"branches": [80, 95],
"statements": [80, 95]
}
}
13 changes: 9 additions & 4 deletions .vscode/launch.json
Expand Up @@ -7,13 +7,18 @@
{
"type": "node",
"request": "launch",
"name": "Jest Test Current Test File",
"program": "${workspaceFolder}/node_modules/.bin/jest",
"name": "AVA Test Current Test File",
"program": "${workspaceFolder}/node_modules/.bin/ava",
"args": [
"--runInBand",
"--no-coverage",
"${relativeFile}"
],
"outputCapture": "std",
"skipFiles": [
"<node_internals>/**/*.js"
],
"env": {
"TEST_ALL_FILE": "1"
},
"sourceMaps": true,
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
Expand Down
4 changes: 2 additions & 2 deletions .vscode/settings.json
@@ -1,12 +1,12 @@
{
"files.exclude": {
".rpt2_cache": true,
".nyc_output": true,
"coverage": true,
},
"files.trimTrailingWhitespace": true,
"search.exclude": {
"**/.git/": true,
"**/.rpt2_cache/": true,
"**/.nyc_output/": true,
"**/yarn.lock": true,
".vscode/": true,
"build/": true,
Expand Down