sorenabedi/artist-svelte

View on GitHub

Showing 464 of 465 total issues

Function debounce has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Confirmed

export default function debounce<originalFunction extends unknownFunction>(
    func: originalFunction,
    waitMilliseconds = 50,
    options: Options<ReturnType<originalFunction>> = {}
): DebouncedFunction<originalFunction> {
Severity: Minor
Found in src/lib/utilities/helper/debounce/index.ts - About 2 hrs to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Identical blocks of code found in 2 locations. Consider refactoring.
Confirmed

        replace: [
            [/process\.env\['NODE_ENV'\]/g, () => `import.meta.env.MODE`],
            [/process\.env\.NODE_ENV/g, () => `import.meta.env.MODE`],
            [/process\.env\['(\w+)'\]/g, (_, match) => JSON.stringify(process.env[match])],
            [/process\.env\.(\w+)/g, (_, match) => JSON.stringify(process.env[match])]
Severity: Major
Found in examples/getting-started/svelte.config.js and 1 other location - About 2 hrs to fix
examples/getting-started-sass/svelte.config.js on lines 9..14

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 80.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Identical blocks of code found in 2 locations. Consider refactoring.
Confirmed

        replace: [
            [/process\.env\['NODE_ENV'\]/g, () => `import.meta.env.MODE`],
            [/process\.env\.NODE_ENV/g, () => `import.meta.env.MODE`],
            [/process\.env\['(\w+)'\]/g, (_, match) => JSON.stringify(process.env[match])],
            [/process\.env\.(\w+)/g, (_, match) => JSON.stringify(process.env[match])]
Severity: Major
Found in examples/getting-started-sass/svelte.config.js and 1 other location - About 2 hrs to fix
examples/getting-started/svelte.config.js on lines 8..13

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 80.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Function debounce has 54 lines of code (exceeds 25 allowed). Consider refactoring.
Confirmed

export default function debounce<originalFunction extends unknownFunction>(
    func: originalFunction,
    waitMilliseconds = 50,
    options: Options<ReturnType<originalFunction>> = {}
): DebouncedFunction<originalFunction> {
Severity: Major
Found in src/lib/utilities/helper/debounce/index.ts - About 2 hrs to fix

Identical blocks of code found in 2 locations. Consider refactoring.
Confirmed

        if (!error) {
            fs.writeFileSync(
                GlobalStylesCSSFile,
                result.css.toString().replace(/:global /g, ''),
                function (err) {
Severity: Major
Found in scripts/postPKG.js and 1 other location - About 1 hr to fix
scripts/postPKG.js on lines 65..75

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 67.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Identical blocks of code found in 2 locations. Consider refactoring.
Confirmed

        if (!error) {
            fs.writeFileSync(NormalizeCSSFile, result.css, function (err) {
                if (err) console.log(`Error appeared while writing file "css/Normalize.css".`);
            });
            console.log(`SASS Compiler: _normalize.scss converted successfully.`);
Severity: Major
Found in scripts/postPKG.js and 1 other location - About 1 hr to fix
scripts/postPKG.js on lines 41..55

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 67.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

space indentation expected
Open

        /* istanbul ignore next */

Rule: indent

Enforces indentation with tabs or spaces.

Rationale

Using only one of tabs or spaces for indentation leads to more consistent editor behavior, cleaner diffs in version control, and easier programmatic manipulation.

Notes
  • Has Fix

Config

One of the following arguments must be provided:

  • spaces enforces consistent spaces.
  • tabs enforces consistent tabs.

A second optional argument specifies indentation size:

  • 2 enforces 2 space indentation.
  • 4 enforces 4 space indentation.

Indentation size is required for auto-fixing, but not for rule checking.

NOTE: auto-fixing will only convert invalid indent whitespace to the desired type, it will not fix invalid whitespace sizes.

Examples
"indent": true,spaces
"indent": true,spaces,4
"indent": true,tabs,2
Schema
{
  "type": "array",
  "items": [
    {
      "type": "string",
      "enum": [
        "tabs",
        "spaces"
      ]
    },
    {
      "type": "number",
      "enum": [
        2,
        4
      ]
    }
  ],
  "minLength": 0,
  "maxLength": 5
}

For more information see this page.

space indentation expected
Open

                if (accordionContext) accordionContext.remove({ id });

Rule: indent

Enforces indentation with tabs or spaces.

Rationale

Using only one of tabs or spaces for indentation leads to more consistent editor behavior, cleaner diffs in version control, and easier programmatic manipulation.

Notes
  • Has Fix

Config

One of the following arguments must be provided:

  • spaces enforces consistent spaces.
  • tabs enforces consistent tabs.

A second optional argument specifies indentation size:

  • 2 enforces 2 space indentation.
  • 4 enforces 4 space indentation.

Indentation size is required for auto-fixing, but not for rule checking.

NOTE: auto-fixing will only convert invalid indent whitespace to the desired type, it will not fix invalid whitespace sizes.

Examples
"indent": true,spaces
"indent": true,spaces,4
"indent": true,tabs,2
Schema
{
  "type": "array",
  "items": [
    {
      "type": "string",
      "enum": [
        "tabs",
        "spaces"
      ]
    },
    {
      "type": "number",
      "enum": [
        2,
        4
      ]
    }
  ],
  "minLength": 0,
  "maxLength": 5
}

For more information see this page.

Missing semicolon
Open

import type { useAction } from '../../types/global';

Rule: semicolon

Enforces consistent semicolon usage at the end of every statement.

Notes
  • Has Fix

Config

One of the following arguments must be provided:

  • "always" enforces semicolons at the end of every statement.
  • "never" disallows semicolons at the end of every statement except for when they are necessary.

The following arguments may be optionally provided:

  • "ignore-interfaces" skips checking semicolons at the end of interface members.
  • "ignore-bound-class-methods" skips checking semicolons at the end of bound class methods.
  • "strict-bound-class-methods" disables any special handling of bound class methods and treats them as any other assignment. This option overrides "ignore-bound-class-methods".
Examples
"semicolon": true,always
"semicolon": true,never
"semicolon": true,always,ignore-interfaces
"semicolon": true,always,ignore-bound-class-methods
Schema
{
  "type": "array",
  "items": [
    {
      "type": "string",
      "enum": [
        "always",
        "never"
      ]
    },
    {
      "type": "string",
      "enum": [
        "ignore-interfaces"
      ]
    }
  ],
  "additionalItems": false
}

For more information see this page.

Missing semicolon
Open

import type { Subscriber, Writable } from 'svelte/store';

Rule: semicolon

Enforces consistent semicolon usage at the end of every statement.

Notes
  • Has Fix

Config

One of the following arguments must be provided:

  • "always" enforces semicolons at the end of every statement.
  • "never" disallows semicolons at the end of every statement except for when they are necessary.

The following arguments may be optionally provided:

  • "ignore-interfaces" skips checking semicolons at the end of interface members.
  • "ignore-bound-class-methods" skips checking semicolons at the end of bound class methods.
  • "strict-bound-class-methods" disables any special handling of bound class methods and treats them as any other assignment. This option overrides "ignore-bound-class-methods".
Examples
"semicolon": true,always
"semicolon": true,never
"semicolon": true,always,ignore-interfaces
"semicolon": true,always,ignore-bound-class-methods
Schema
{
  "type": "array",
  "items": [
    {
      "type": "string",
      "enum": [
        "always",
        "never"
      ]
    },
    {
      "type": "string",
      "enum": [
        "ignore-interfaces"
      ]
    }
  ],
  "additionalItems": false
}

For more information see this page.

space indentation expected
Open

            close();

Rule: indent

Enforces indentation with tabs or spaces.

Rationale

Using only one of tabs or spaces for indentation leads to more consistent editor behavior, cleaner diffs in version control, and easier programmatic manipulation.

Notes
  • Has Fix

Config

One of the following arguments must be provided:

  • spaces enforces consistent spaces.
  • tabs enforces consistent tabs.

A second optional argument specifies indentation size:

  • 2 enforces 2 space indentation.
  • 4 enforces 4 space indentation.

Indentation size is required for auto-fixing, but not for rule checking.

NOTE: auto-fixing will only convert invalid indent whitespace to the desired type, it will not fix invalid whitespace sizes.

Examples
"indent": true,spaces
"indent": true,spaces,4
"indent": true,tabs,2
Schema
{
  "type": "array",
  "items": [
    {
      "type": "string",
      "enum": [
        "tabs",
        "spaces"
      ]
    },
    {
      "type": "number",
      "enum": [
        2,
        4
      ]
    }
  ],
  "minLength": 0,
  "maxLength": 5
}

For more information see this page.

space indentation expected
Open

        returnFn.push(() => {

Rule: indent

Enforces indentation with tabs or spaces.

Rationale

Using only one of tabs or spaces for indentation leads to more consistent editor behavior, cleaner diffs in version control, and easier programmatic manipulation.

Notes
  • Has Fix

Config

One of the following arguments must be provided:

  • spaces enforces consistent spaces.
  • tabs enforces consistent tabs.

A second optional argument specifies indentation size:

  • 2 enforces 2 space indentation.
  • 4 enforces 4 space indentation.

Indentation size is required for auto-fixing, but not for rule checking.

NOTE: auto-fixing will only convert invalid indent whitespace to the desired type, it will not fix invalid whitespace sizes.

Examples
"indent": true,spaces
"indent": true,spaces,4
"indent": true,tabs,2
Schema
{
  "type": "array",
  "items": [
    {
      "type": "string",
      "enum": [
        "tabs",
        "spaces"
      ]
    },
    {
      "type": "number",
      "enum": [
        2,
        4
      ]
    }
  ],
  "minLength": 0,
  "maxLength": 5
}

For more information see this page.

space indentation expected
Open

    if (scrollPosition.direction === 'up') {

Rule: indent

Enforces indentation with tabs or spaces.

Rationale

Using only one of tabs or spaces for indentation leads to more consistent editor behavior, cleaner diffs in version control, and easier programmatic manipulation.

Notes
  • Has Fix

Config

One of the following arguments must be provided:

  • spaces enforces consistent spaces.
  • tabs enforces consistent tabs.

A second optional argument specifies indentation size:

  • 2 enforces 2 space indentation.
  • 4 enforces 4 space indentation.

Indentation size is required for auto-fixing, but not for rule checking.

NOTE: auto-fixing will only convert invalid indent whitespace to the desired type, it will not fix invalid whitespace sizes.

Examples
"indent": true,spaces
"indent": true,spaces,4
"indent": true,tabs,2
Schema
{
  "type": "array",
  "items": [
    {
      "type": "string",
      "enum": [
        "tabs",
        "spaces"
      ]
    },
    {
      "type": "number",
      "enum": [
        2,
        4
      ]
    }
  ],
  "minLength": 0,
  "maxLength": 5
}

For more information see this page.

Class name must be in pascal case
Open

interface accordionStates {

Rule: class-name

Enforces PascalCased class and interface names.

Rationale

Makes it easy to differentiate classes from regular variables at a glance.

JavaScript and general programming convention is to refer to classes in PascalCase. It's confusing to use camelCase or other conventions for class names.

Config

Not configurable.

Examples
"class-name": true

For more information see this page.

space indentation expected
Open

            accordionStates.update((allItemStates) => {

Rule: indent

Enforces indentation with tabs or spaces.

Rationale

Using only one of tabs or spaces for indentation leads to more consistent editor behavior, cleaner diffs in version control, and easier programmatic manipulation.

Notes
  • Has Fix

Config

One of the following arguments must be provided:

  • spaces enforces consistent spaces.
  • tabs enforces consistent tabs.

A second optional argument specifies indentation size:

  • 2 enforces 2 space indentation.
  • 4 enforces 4 space indentation.

Indentation size is required for auto-fixing, but not for rule checking.

NOTE: auto-fixing will only convert invalid indent whitespace to the desired type, it will not fix invalid whitespace sizes.

Examples
"indent": true,spaces
"indent": true,spaces,4
"indent": true,tabs,2
Schema
{
  "type": "array",
  "items": [
    {
      "type": "string",
      "enum": [
        "tabs",
        "spaces"
      ]
    },
    {
      "type": "number",
      "enum": [
        2,
        4
      ]
    }
  ],
  "minLength": 0,
  "maxLength": 5
}

For more information see this page.

Shadowed name: 'accordionContext'
Open

    (_, accordionContext: ReturnType<typeof accordionContextInit>) => {

Rule: no-shadowed-variable

Disallows shadowing variable declarations.

Rationale

When a variable in a local scope and a variable in the containing scope have the same name, shadowing occurs. Shadowing makes it impossible to access the variable in the containing scope and obscures to what value an identifier actually refers. Compare the following snippets:

const a = 'no shadow';
function print() {
    console.log(a);
}
print(); // logs 'no shadow'.
const a = 'no shadow';
function print() {
    const a = 'shadow'; // TSLint will complain here.
    console.log(a);
}
print(); // logs 'shadow'.

ESLint has an equivalent rule. For more background information, refer to this MDN closure doc.

Config

You can optionally pass an object to disable checking for certain kinds of declarations. Possible keys are "class", "enum", "function", "import", "interface", "namespace", "typeAlias" and "typeParameter". You can also pass "underscore" to ignore variable names that begin with _. Just set the value to false for the check you want to disable. All checks default to true, i.e. are enabled by default. Note that you cannot disable variables and parameters.

The option "temporalDeadZone" defaults to true which shows errors when shadowing block scoped declarations in their temporal dead zone. When set to false parameters, classes, enums and variables declared with let or const are not considered shadowed if the shadowing occurs within their temporal dead zone.

The following example shows how the "temporalDeadZone" option changes the linting result:

function fn(value) {
    if (value) {
        const tmp = value; // no error on this line if "temporalDeadZone" is false
        return tmp;
    }
    let tmp = undefined;
    if (!value) {
        const tmp = value; // this line always contains an error
        return tmp;
    }
}
Examples
"no-shadowed-variable": true
"no-shadowed-variable": true,[object Object]
Schema
{
  "type": "object",
  "properties": {
    "class": {
      "type": "boolean"
    },
    "enum": {
      "type": "boolean"
    },
    "function": {
      "type": "boolean"
    },
    "import": {
      "type": "boolean"
    },
    "interface": {
      "type": "boolean"
    },
    "namespace": {
      "type": "boolean"
    },
    "typeAlias": {
      "type": "boolean"
    },
    "typeParameter": {
      "type": "boolean"
    },
    "temporalDeadZone": {
      "type": "boolean"
    },
    "underscore": {
      "type": "boolean"
    }
  }
}

For more information see this page.

unused expression, expected an assignment or function call
Open

import type { useAction } from '../../types/global';

Rule: no-unused-expression

Disallows unused expression statements.

Unused expressions are expression statements which are not assignments or function calls (and thus usually no-ops).

Rationale

Detects potential errors where an assignment or function call was intended.

Config

Three arguments may be optionally provided:

  • allow-fast-null-checks allows to use logical operators to perform fast null checks and perform method or function calls for side effects (e.g. e && e.preventDefault()).
  • allow-new allows 'new' expressions for side effects (e.g. new ModifyGlobalState();.
  • allow-tagged-template allows tagged templates for side effects (e.g. this.add\foo`;`.
Examples
"no-unused-expression": true
"no-unused-expression": true,allow-fast-null-checks
Schema
{
  "type": "array",
  "items": {
    "type": "string",
    "enum": [
      "allow-fast-null-checks",
      "allow-new",
      "allow-tagged-template"
    ]
  },
  "minLength": 0,
  "maxLength": 3
}

For more information see this page.

unused expression, expected an assignment or function call
Open

import type { Subscriber, Writable } from 'svelte/store';

Rule: no-unused-expression

Disallows unused expression statements.

Unused expressions are expression statements which are not assignments or function calls (and thus usually no-ops).

Rationale

Detects potential errors where an assignment or function call was intended.

Config

Three arguments may be optionally provided:

  • allow-fast-null-checks allows to use logical operators to perform fast null checks and perform method or function calls for side effects (e.g. e && e.preventDefault()).
  • allow-new allows 'new' expressions for side effects (e.g. new ModifyGlobalState();.
  • allow-tagged-template allows tagged templates for side effects (e.g. this.add\foo`;`.
Examples
"no-unused-expression": true
"no-unused-expression": true,allow-fast-null-checks
Schema
{
  "type": "array",
  "items": {
    "type": "string",
    "enum": [
      "allow-fast-null-checks",
      "allow-new",
      "allow-tagged-template"
    ]
  },
  "minLength": 0,
  "maxLength": 3
}

For more information see this page.

space indentation expected
Open

        e.stopPropagation();

Rule: indent

Enforces indentation with tabs or spaces.

Rationale

Using only one of tabs or spaces for indentation leads to more consistent editor behavior, cleaner diffs in version control, and easier programmatic manipulation.

Notes
  • Has Fix

Config

One of the following arguments must be provided:

  • spaces enforces consistent spaces.
  • tabs enforces consistent tabs.

A second optional argument specifies indentation size:

  • 2 enforces 2 space indentation.
  • 4 enforces 4 space indentation.

Indentation size is required for auto-fixing, but not for rule checking.

NOTE: auto-fixing will only convert invalid indent whitespace to the desired type, it will not fix invalid whitespace sizes.

Examples
"indent": true,spaces
"indent": true,spaces,4
"indent": true,tabs,2
Schema
{
  "type": "array",
  "items": [
    {
      "type": "string",
      "enum": [
        "tabs",
        "spaces"
      ]
    },
    {
      "type": "number",
      "enum": [
        2,
        4
      ]
    }
  ],
  "minLength": 0,
  "maxLength": 5
}

For more information see this page.

space indentation expected
Open

            entries.forEach((entryElement) => {

Rule: indent

Enforces indentation with tabs or spaces.

Rationale

Using only one of tabs or spaces for indentation leads to more consistent editor behavior, cleaner diffs in version control, and easier programmatic manipulation.

Notes
  • Has Fix

Config

One of the following arguments must be provided:

  • spaces enforces consistent spaces.
  • tabs enforces consistent tabs.

A second optional argument specifies indentation size:

  • 2 enforces 2 space indentation.
  • 4 enforces 4 space indentation.

Indentation size is required for auto-fixing, but not for rule checking.

NOTE: auto-fixing will only convert invalid indent whitespace to the desired type, it will not fix invalid whitespace sizes.

Examples
"indent": true,spaces
"indent": true,spaces,4
"indent": true,tabs,2
Schema
{
  "type": "array",
  "items": [
    {
      "type": "string",
      "enum": [
        "tabs",
        "spaces"
      ]
    },
    {
      "type": "number",
      "enum": [
        2,
        4
      ]
    }
  ],
  "minLength": 0,
  "maxLength": 5
}

For more information see this page.

Severity
Category
Status
Source
Language