Security News
NIST Misses 2024 Deadline to Clear NVD Backlog
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.
@lego/eslint-config-angular
Advanced tools
This package will setup and config ESLinting rules for your Angular TypeScript files. If you want, and you do, to also lint Angular Templates (HTML) then you also need @lego/eslint-config-angular-template in addition to @lego/eslint-config-angular
.
Install this config package:
$ npm i -D @lego/eslint-config-angular
NOTE: @lego/eslint-config-angular
includes @lego/eslint-config-typescript
which includes @lego/eslint-config
Make a tsconfig.eslint.json
that targets everything.
Else @typescript-eslint
will complain if it encounters a file that is not covered by your tsconfig
.
For example environment.prod.ts
.
// tsconfig.eslint.json
{
"extends": "tsconfig.json" // this is the generated tsconfig from the angular-cli
}
Extend your eslint.json
, and make sure @lego/eslint-config-angular
has been added, but make sure it's add at the end.
Note that the config for this linting config is added via overrides
. This is a requirement from @angular-eslint which this is built on top of.
"overrides": [
{
"files": ["*.ts"],
"parserOptions": {
"project": "tsconfig.eslint.json"
// "createDefaultProgram": true <-- REMOVE THIS from your config
},
"extends": ["@lego/eslint-config-angular"]
}
]
with Prettier:
"overrides": [
{
"files": ["*.ts"],
"parserOptions": {
"project": "tsconfig.eslint.json"
// "createDefaultProgram": true <-- REMOVE THIS from your config
},
"extends": [
"@lego/eslint-config-angular",
"@lego/eslint-config-prettier" // note prettier MUST come last
]
}
]
NOTE: the above examples will only lint TypeScript files. In order to lint Angular Templates (HTML) check out @lego/eslint-config-angular-template
With the above eslint.json
configuration example, you can still use or override already defined rules as such:
"overrides": [
{
"parserOptions": {
"project": "tsconfig.eslint.json"
// "createDefaultProgram": true <-- REMOVE THIS from your config
},
"extends": [
"@lego/eslint-config-angular",
"@lego/eslint-config-prettier"
],
"rules": {
// eslint-config rules
"camelcase": "warn",
// @typescript-eslint/eslint-plugin rules
"@typescript-eslint/no-useless-constructor": "error",
// @angular-eslint rules
"@angular-eslint/component-class-suffix": [
"error",
{
"suffixes": ["Component", "Page", "Modal", "Drawer"]
}
],
// eslint-plugin-prettier rules
"prettier/prettier": [
"error",
{
"singleQuote": false
}
]
}
}
]
Are you using the multi-project workspace structure (stuff is in the projects
folder) then you can put project specific rules in the related project folder.
You still need to make a tsconfig.eslint.json
file that targets everything within your project. Put the below file next to your projects/<YOUR_PROJECT_NAME>/tsconfig.lib.prod.json
file
// projects/<YOUR_PROJECT_NAME>/tsconfig.eslint.json
{
"extends": "../../tsconfig.json"
}
Then alter the ESLint config to your heart's content
// projects/<YOUR_PROJECT_NAME>/.eslintrc.json
{
"extends": "../../.eslintrc",
"ignorePatterns": ["!**/*"],
"overrides": [
{
"files": ["*.ts"],
"parserOptions": {
"project": "projects/<YOUR_PROJECT_NAME>/tsconfig.eslint.json" // <-- replace <YOUR_PROJECT_NAME>
// "createDefaultProgram": true <-- REMOVE THIS from your config
},
"rules": {
"@angular-eslint/component-selector": [
"error", { "type": "element", "style": "kebab-case", "prefix": "<YOUR_PROJECT_PREFIX>" }
],
"@angular-eslint/directive-selector": [
"error", { "type": "attribute", "style": "camelCase", "prefix": "<YOUR_PROJECT_PREFIX>" }
],
"@angular-eslint/pipe-prefix": [
"error", { "prefixes": ["<YOUR_PROJECT_PREFIX>"] }
]
}
}
]
}
It's recommended to inspect the defined rule's configurations where the reasoning for the configuration lives. If a configuration could benefit more than just the project you're working on, feel free to create a pull request.
FAQs
LEGO shareable eslint config for Angular projects
The npm package @lego/eslint-config-angular receives a total of 0 weekly downloads. As such, @lego/eslint-config-angular popularity was classified as not popular.
We found that @lego/eslint-config-angular demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.
Security News
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
Security News
The Socket Research team breaks down a malicious npm package targeting the legitimate DOMPurify library. It uses obfuscated code to hide that it is exfiltrating browser and crypto wallet data.