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

(Issue #51) Disabled prefer-immutable-types #52

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 1 addition & 10 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ const config = {
},
],
curly: ["error"],
"functional/prefer-immutable-types": "off",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not clear, but this is actually a generated file. index.ts is the one to update. I forget why we were forced (?) to commit the generated js. It certainly needs to part of the bundle that becomes published npm package but maybe we can remove from git to reduce confusion.

Copy link
Contributor Author

@dspasojevic dspasojevic Jan 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've updated .ts instead and rebuilt the .js files. How is this package published?

},
overrides: [
{
Expand All @@ -77,10 +78,6 @@ const config = {
"functional/no-expression-statements": "off",
"functional/no-throw-statements": "off",
"functional/no-conditional-statements": "off",
"functional/prefer-immutable-types": [
"error",
{ enforcement: "ReadonlyDeep" },
],
},
},
{
Expand All @@ -94,12 +91,6 @@ const config = {
],
// This is a common pattern in React for hooks and callbacks.
"functional/no-return-void": "off",
"functional/prefer-immutable-types": [
"error",
{
ignoreTypePattern: ["JSX"],
},
],
},
},
],
Expand Down
11 changes: 1 addition & 10 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ const config: TSESLint.Linter.Config = {
},
],
curly: ["error"],
"functional/prefer-immutable-types": "off",
},
overrides: [
{
Expand All @@ -79,10 +80,6 @@ const config: TSESLint.Linter.Config = {
"functional/no-expression-statements": "off",
"functional/no-throw-statements": "off",
"functional/no-conditional-statements": "off",
"functional/prefer-immutable-types": [
"error",
{ enforcement: "ReadonlyDeep" },
],
},
},
{
Expand All @@ -96,12 +93,6 @@ const config: TSESLint.Linter.Config = {
],
// This is a common pattern in React for hooks and callbacks.
"functional/no-return-void": "off",
"functional/prefer-immutable-types": [
"error",
{
ignoreTypePattern: ["JSX"],
},
],
},
},
],
Expand Down
2 changes: 1 addition & 1 deletion test-fixtures/base-react.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const Foo = () => {
exports.Foo = Foo;
// Note: no functional/functional-parameters error here
// Note: Report functional immutable type error if JSX.Element return type is not explicitly specified.
// eslint-disable-next-line functional/prefer-immutable-types
// Note: functional/prefer-immutable-types should not be triggered (it is disabled until library issue is resolved)
const Boo = () => {
return (0, jsx_runtime_1.jsx)("div", {});
};
Expand Down
2 changes: 1 addition & 1 deletion test-fixtures/base-react.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const Foo = (): JSX.Element => {

// Note: no functional/functional-parameters error here
// Note: Report functional immutable type error if JSX.Element return type is not explicitly specified.
// eslint-disable-next-line functional/prefer-immutable-types
// Note: functional/prefer-immutable-types should not be triggered (it is disabled until library issue is resolved)
export const Boo = () => {
return <div></div>;
};
4 changes: 2 additions & 2 deletions test-fixtures/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ console.warn("");
// eslint-disable-next-line no-restricted-properties
exports.a = JSON.stringify("");
// NB JSON.stringify is not detected when accessed via an alias.
// eslint-disable-next-line functional/prefer-immutable-types
// Note: functional/prefer-immutable-types should not be triggered (it is disabled until library issue is resolved)
const JSONAlias = JSON;
exports.b = JSONAlias.stringify("");
// Note: no-template-curly-in-string is on
Expand All @@ -25,7 +25,7 @@ exports.whoops = "${whoops}";
const myFunction = () => "";
exports.myFunction = myFunction;
// Note: report the expected functional parameters errors.
// eslint-disable-next-line functional/functional-parameters, functional/prefer-immutable-types, @typescript-eslint/no-unused-vars
// eslint-disable-next-line functional/functional-parameters, @typescript-eslint/no-unused-vars
const myFunctionWithParam = (..._args) => {
return "";
};
Expand Down
4 changes: 2 additions & 2 deletions test-fixtures/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ console.warn("");
export const a = JSON.stringify("");

// NB JSON.stringify is not detected when accessed via an alias.
// eslint-disable-next-line functional/prefer-immutable-types
// Note: functional/prefer-immutable-types should not be triggered (it is disabled until library issue is resolved)
const JSONAlias = JSON;
export const b = JSONAlias.stringify("");

Expand All @@ -26,7 +26,7 @@ export const whoops = "${whoops}";
export const myFunction = (): string => "";

// Note: report the expected functional parameters errors.
// eslint-disable-next-line functional/functional-parameters, functional/prefer-immutable-types, @typescript-eslint/no-unused-vars
// eslint-disable-next-line functional/functional-parameters, @typescript-eslint/no-unused-vars
export const myFunctionWithParam = (..._args: string[]): string => {
return "";
};
Expand Down
68 changes: 3 additions & 65 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -835,14 +835,6 @@
"@typescript-eslint/types" "6.17.0"
"@typescript-eslint/visitor-keys" "6.17.0"

"@typescript-eslint/[email protected]":
version "6.7.3"
resolved "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-6.7.3.tgz"
integrity sha512-wOlo0QnEou9cHO2TdkJmzF7DFGvAKEnB82PuPNHpT8ZKKaZu6Bm63ugOTn9fXNJtvuDPanBc78lGUGGytJoVzQ==
dependencies:
"@typescript-eslint/types" "6.7.3"
"@typescript-eslint/visitor-keys" "6.7.3"

"@typescript-eslint/[email protected]", "@typescript-eslint/type-utils@^5.55.0", "@typescript-eslint/type-utils@^5.62.0":
version "5.62.0"
resolved "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-5.62.0.tgz"
Expand All @@ -853,7 +845,7 @@
debug "^4.3.4"
tsutils "^3.21.0"

"@typescript-eslint/[email protected]":
"@typescript-eslint/[email protected]", "@typescript-eslint/type-utils@^6.0.0":
version "6.17.0"
resolved "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-6.17.0.tgz"
integrity sha512-hDXcWmnbtn4P2B37ka3nil3yi3VCQO2QEB9gBiHJmQp5wmyQWqnjA85+ZcE8c4FqnaB6lBwMrPkgd4aBYz3iNg==
Expand All @@ -863,16 +855,6 @@
debug "^4.3.4"
ts-api-utils "^1.0.1"

"@typescript-eslint/type-utils@^6.0.0":
version "6.7.3"
resolved "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-6.7.3.tgz"
integrity sha512-Fc68K0aTDrKIBvLnKTZ5Pf3MXK495YErrbHb1R6aTpfK5OdSFj0rVN7ib6Tx6ePrZ2gsjLqr0s98NG7l96KSQw==
dependencies:
"@typescript-eslint/typescript-estree" "6.7.3"
"@typescript-eslint/utils" "6.7.3"
debug "^4.3.4"
ts-api-utils "^1.0.1"

"@typescript-eslint/[email protected]":
version "5.62.0"
resolved "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.62.0.tgz"
Expand All @@ -883,11 +865,6 @@
resolved "https://registry.npmjs.org/@typescript-eslint/types/-/types-6.17.0.tgz"
integrity sha512-qRKs9tvc3a4RBcL/9PXtKSehI/q8wuU9xYJxe97WFxnzH8NWWtcW3ffNS+EWg8uPvIerhjsEZ+rHtDqOCiH57A==

"@typescript-eslint/[email protected]":
version "6.7.3"
resolved "https://registry.npmjs.org/@typescript-eslint/types/-/types-6.7.3.tgz"
integrity sha512-4g+de6roB2NFcfkZb439tigpAMnvEIg3rIjWQ+EM7IBaYt/CdJt6em9BJ4h4UpdgaBWdmx2iWsafHTrqmgIPNw==

"@typescript-eslint/[email protected]":
version "5.62.0"
resolved "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.62.0.tgz"
Expand Down Expand Up @@ -915,19 +892,6 @@
semver "^7.5.4"
ts-api-utils "^1.0.1"

"@typescript-eslint/[email protected]":
version "6.7.3"
resolved "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-6.7.3.tgz"
integrity sha512-YLQ3tJoS4VxLFYHTw21oe1/vIZPRqAO91z6Uv0Ss2BKm/Ag7/RVQBcXTGcXhgJMdA4U+HrKuY5gWlJlvoaKZ5g==
dependencies:
"@typescript-eslint/types" "6.7.3"
"@typescript-eslint/visitor-keys" "6.7.3"
debug "^4.3.4"
globby "^11.1.0"
is-glob "^4.0.3"
semver "^7.5.4"
ts-api-utils "^1.0.1"

"@typescript-eslint/[email protected]", "@typescript-eslint/utils@^5.10.0", "@typescript-eslint/utils@^5.62.0":
version "5.62.0"
resolved "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-5.62.0.tgz"
Expand All @@ -942,7 +906,7 @@
eslint-scope "^5.1.1"
semver "^7.3.7"

"@typescript-eslint/[email protected]":
"@typescript-eslint/[email protected]", "@typescript-eslint/utils@^6.2.0":
version "6.17.0"
resolved "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-6.17.0.tgz"
integrity sha512-LofsSPjN/ITNkzV47hxas2JCsNCEnGhVvocfyOcLzT9c/tSZE7SfhS/iWtzP1lKNOEfLhRTZz6xqI8N2RzweSQ==
Expand All @@ -955,19 +919,6 @@
"@typescript-eslint/typescript-estree" "6.17.0"
semver "^7.5.4"

"@typescript-eslint/[email protected]", "@typescript-eslint/utils@^6.2.0":
version "6.7.3"
resolved "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-6.7.3.tgz"
integrity sha512-vzLkVder21GpWRrmSR9JxGZ5+ibIUSudXlW52qeKpzUEQhRSmyZiVDDj3crAth7+5tmN1ulvgKaCU2f/bPRCzg==
dependencies:
"@eslint-community/eslint-utils" "^4.4.0"
"@types/json-schema" "^7.0.12"
"@types/semver" "^7.5.0"
"@typescript-eslint/scope-manager" "6.7.3"
"@typescript-eslint/types" "6.7.3"
"@typescript-eslint/typescript-estree" "6.7.3"
semver "^7.5.4"

"@typescript-eslint/[email protected]":
version "5.62.0"
resolved "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.62.0.tgz"
Expand All @@ -984,14 +935,6 @@
"@typescript-eslint/types" "6.17.0"
eslint-visitor-keys "^3.4.1"

"@typescript-eslint/[email protected]":
version "6.7.3"
resolved "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-6.7.3.tgz"
integrity sha512-HEVXkU9IB+nk9o63CeICMHxFWbHWr3E1mpilIQBe9+7L/lH97rleFLVtYsfnWB+JVMaiFnEaxvknvmIzX+CqVg==
dependencies:
"@typescript-eslint/types" "6.7.3"
eslint-visitor-keys "^3.4.1"

"@ungap/structured-clone@^1.2.0":
version "1.2.0"
resolved "https://registry.npmjs.org/@ungap/structured-clone/-/structured-clone-1.2.0.tgz"
Expand Down Expand Up @@ -3150,16 +3093,11 @@ minimist@1, minimist@^1.2.0, minimist@^1.2.6:
resolved "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz"
integrity sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==

[email protected]:
[email protected], ms@^2.1.1:
version "2.1.2"
resolved "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz"
integrity sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==

ms@^2.1.1:
version "2.1.3"
resolved "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz"
integrity sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==

natural-compare-lite@^1.4.0:
version "1.4.0"
resolved "https://registry.npmjs.org/natural-compare-lite/-/natural-compare-lite-1.4.0.tgz"
Expand Down