question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Best way for multiple prefix rules

See original GitHub issue

Is it possible to change prefixes for directory (without rewriting all rules)?

Styleguide says, that different modules can use different prefixes: toh-hero, admin-users. https://angular.io/styleguide#!#02-07

Module versions tslint: 3.13.0 codelyzer: 0.0.28

Now, I can write all prefixes in tslint.json in root directory.

"directive-selector-prefix": [true, "app", "toh", "admin"]
"component-selector-prefix": [true, "app", "toh", "admin"]

If I create app/heroes/tslint.ts, and write only rulesDirectory and prefixes rules, all other rules from ./tslint.ts will not work in app/heroes/ directory.

Example

./tslint.ts

{
  "rulesDirectory": [
    "node_modules/codelyzer"
  ],
  "rules": {
    ...
    "directive-selector-prefix": [true, "app"],
    "component-selector-prefix": [true, "app"],
    ...
  }
}

app/heroes/tslint.ts

{
  "rulesDirectory": [
    "../../node_modules/codelyzer"
  ],
  "rules": {
    "directive-selector-prefix": [true, "toh"],
    "component-selector-prefix": [true, "toh"],
  }
}

app/heroes/hero.component.ts

@Component({
  selector: 'toh-hero'
})
export class HeroComponent {}

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:2
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

6reactions
stocksrcommented, Dec 11, 2017

the tslint extends feature works for this: I simply add a tslint.json file in the relevant folder like this

{
    "extends": "../../../tslint.json",
    "rules": {
        "directive-selector": [true, "attribute", "av", "camelCase"],
        "component-selector": [true, "element", "av", "kebab-case"],
        "pipe-naming": [true, "camelCase", "av"]
    }
}
4reactions
mgechevcommented, Oct 2, 2016

The following format makes sense to be used:

"selector-prefixes": {
    "./": ["app", "baz"], // use “app” or “baz” by default
    "./heroes": ["toh"],  // use “toh” prefix for all D&C in “./heroes” except…:
    "./heroes/bar": ["bar"], // use “bar” for all D&C in “./heroes/bar”
    "./humans": ["hu"] // use “hu” for all directives & components in “./human”
 }

The keys are the directory names, relative to the project root, and the values are list of prefixes.

@ValeryVS any opinion?

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Teach Prefixes (Mini Teaching Guide + Download)
Rule 1: Hyphenate the word when you add a prefix to a proper noun or a numeral. hyphenated prefix examples. Rule 2: Hyphenate...
Read more >
Rootcast: A Multitude of "Multi-" Words - Membean
The English prefix multi- means “many.” Examples using this prefix include multivitamin and multiplication. An easy way to remember that the prefix multi-...
Read more >
The Ultimate Guide to Using Prefixes
1: Keep the root. The spelling of the base word never changes. Simply add the prefix to the beginning of the base word....
Read more >
Spelling Rules for Prefixes: Overview & Exceptions - Study.com
Identify and understand how to use prefixes. Examine the spelling rules and identify exceptions to the spelling rules. Study a list and ...
Read more >
Organizing objects using prefixes - AWS Documentation
A prefix is a string of characters at the beginning of the object key name. A prefix can be any length, subject to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found