Search


    status: released —

    assoc2many-ambiguous-key

    Model Validation

    Rule Details

    Ambiguous key with a to-many relationship. Entries could appear multiple times with the same key if they point to an entity using a to-many relationship.

    Examples

    ✔️   Example of correct code for this rule:

    
    entity Books {
      key ID: UUID;
      author: Association to Author;
    };
    
    entity Author {
      key ID: UUID;
      books: Association to many Books on books.author = $self;
    }
    

    ❌   Example of incorrect code for this rule:

    
    entity Books {
      key ID: UUID;
      author: Association to Author;
    };
    
    entity Author {
      key ID: UUID;
      books: Association to many Books on books.author = $self;
    }
    
    view AuthorView as select from Author {
      key ID,
      books.ID as bookIDs
    };
    

    Version

    This rule was introduced in @sap/eslint-plugin-cds 1.0.1.


    require-2many-oncond

    Model Validation

    Rule Details

    In relational databases, the foreign key information of a TO MANY relationship must be defined within the target and specified in an ON condition. Therefore, all TO MANY relationships must have a defined ON condition.

    Examples

    ✔️   Example of correct code for this rule:

    
    namespace my.bookshop;
    
    entity Authors {
      key ID: UUID;
      firstName: String;
      lastName: String;
    }
    
    entity Pages {
      key ID: UUID;
      pageNo: Integer;
    }
    
    entity Books {
      key ID : Integer;
    }
    

    ❌   Example of incorrect code for this rule:

    
    namespace my.bookshop;
    
    entity Authors {
      key ID: UUID;
      firstName: String;
      lastName: String;
    }
    
    entity Pages {
      key ID: UUID;
      pageNo: Integer;
    }
    
    entity Books {
      key ID : Integer;
      authors: Association to many Authors;
      pages: Composition of many Pages;
    }
    entity MoreBooks {
      key ID: UUID;
      favorites: {
        special: {
          authors: Association to many Authors;
        }
      }
    }
    
    

    Version

    This rule was introduced in @sap/eslint-plugin-cds 2.1.0.


    sql-cast-suggestion

    Model Validation

    Rule Details

    Should make suggestions for possible missing sql casts.

    Examples

    ✔️   Example of correct code for this rule:

    
    entity Employees {
      key ID : UUID;
      firstname : String;
      lastname : String;
    }
    entity ListOfEmployees as SELECT from Employees {
      *, ID,
      1 as one : Integer,
      firstname || lastname as name1 : String,
      cast (firstname || lastname as String) as name2,
      cast (firstname || lastname as String) as name3 : String,
    };
    

    ❌   Example of incorrect code for this rule:

    
    entity Employees {
        key ID : UUID;
        firstname : String;
        lastname : String;
      }
      entity ListOfEmployees as SELECT from Employees {
        *, ID,
        1 as one : Integer,
        firstname || lastname as name1 : String,
        cast (firstname || lastname as String) as name2,
        cast (firstname || lastname as String) as name3 : String,
      };
      entity ListOfEmployees2 as (
        SELECT from Employees {
          firstname || lastname as name1 : String,
        }
      ) UNION (
        SELECT from Employees {
          firstname || lastname as name1 : String,
        }
      );
    

    Version

    This rule was introduced in @sap/eslint-plugin-cds 1.0.8.


    start-elements-lowercase

    Model Validation

    Rule Details

    Regular element names should all be in lowercase.

    Examples

    ✔️   Example of correct code for this rule:

    
    entity Books {
      key ID: UUID;
      title: localized String(1111);
    };
    

    ❌   Example of incorrect code for this rule:

    
    entity Books {
      key ID: UUID;
      Title: localized String(1111);
    };
    

    Version

    This rule was introduced in @sap/eslint-plugin-cds 1.0.4.


    start-entities-uppercase

    Model Validation

    Rule Details

    Entity names should all be in uppercase.

    Examples

    ✔️   Example of correct code for this rule:

    
    entity Books {
      key ID: UUID;
      title: localized String(1111);
    };
    
    event reviewed { book: Books:ID };
    action review  ( book: Books:ID );
    
    

    ❌   Example of incorrect code for this rule:

    
    entity books {
      key ID: UUID;
      title: localized String(1111);
    };
    

    Version

    This rule was introduced in @sap/eslint-plugin-cds 1.0.4.


    latest-cds-version

    Environment

    Rule Details

    Checks whether the latest cds version is being used.

    Examples

    ✔️   Example of correct code for this rule:

    
    {
      "@sap/cds": {
        "current": "5.1.0",
        "wanted": "5.1.0",
        "latest": "5.1.0",
        "location": "node_modules\\@sap\\cds"
      }
    }
    
    

    ❌   Example of incorrect code for this rule:

    
    {
      "@sap/cds": {
        "current": "5.0.6",
        "wanted": "5.1.0",
        "latest": "5.1.0",
        "location": "node_modules\\@sap\\cds"
      }
    }
    
    

    Version

    This rule was introduced in @sap/eslint-plugin-cds 1.0.4.


    min-node-version

    Environment

    Rule Details

    Checks whether the minimum node version required by the @sap/cds is achieved.

    Examples

    ✔️   Example of correct code for this rule:

    
    {
      "nodeVersion": "v14.0.0",
      "nodeVersionCDS": ">=12"
    }
    
    

    ❌   Example of incorrect code for this rule:

    
    {
      "nodeVersion": "v10.0.0",
      "nodeVersionCDS": ">=12"
    }
    
    

    Version

    This rule was introduced in @sap/eslint-plugin-cds 1.0.0.


    no-db-keywords

    Model Validation

    Rule Details

    Avoid using reserved SQL keywords.

    Examples

    ✔️   Example of correct code for this rule:

    
    entity Groups {}
    
    entity Orders {}
    

    ❌   Example of incorrect code for this rule:

    
    entity GROUP {}
    
    entity Order {}
    

    Version

    This rule was introduced in @sap/eslint-plugin-cds 2.1.0.


    Show/Hide Beta Features