Skip to content

Commit a8e4a62

Browse files
committed
added flat config eslint
1 parent d3a7574 commit a8e4a62

File tree

3 files changed

+114
-0
lines changed

3 files changed

+114
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/** @type {import("prettier").Config} */
2+
const config = {
3+
printWidth: 120, // max 120 chars in line, code is easy to read
4+
useTabs: false, // use spaces instead of tabs
5+
tabWidth: 2, // "visual width" of of the "tab"
6+
trailingComma: "es5", // add trailing commas in objects, arrays, etc.
7+
semi: true, // add ; when needed
8+
singleQuote: false, // use double quotes
9+
bracketSpacing: false, // import {some} ... instead of import { some } ...
10+
arrowParens: "always", // braces even for single param in arrow functions (a) => { }
11+
jsxSingleQuote: false, // "" for react props, like in html
12+
bracketSameLine: false, // pretty JSX
13+
endOfLine: "lf", // 'lf' for linux, 'crlf' for windows, we need to use 'lf' for git
14+
};
15+
16+
export default config;
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import angular from "angular-eslint";
2+
import tseslint from "typescript-eslint";
3+
import eslint from "@eslint/js";
4+
5+
export default tseslint.config(
6+
{
7+
files: ["**/*.ts"],
8+
extends: [
9+
eslint.configs.recommended,
10+
...tseslint.configs.recommended,
11+
...tseslint.configs.stylistic,
12+
...angular.configs.tsRecommended,
13+
],
14+
processor: angular.processInlineTemplates,
15+
rules: {
16+
"@angular-eslint/directive-selector": [
17+
"error",
18+
{
19+
type: "attribute",
20+
prefix: "app",
21+
style: "camelCase",
22+
},
23+
],
24+
"@angular-eslint/component-selector": [
25+
"error",
26+
{
27+
type: "element",
28+
prefix: "app",
29+
style: "kebab-case",
30+
},
31+
],
32+
},
33+
},
34+
{
35+
files: ["**/*.html"],
36+
extends: [
37+
...angular.configs.templateRecommended,
38+
...angular.configs.templateAccessibility,
39+
],
40+
rules: {},
41+
}
42+
);
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
import eslint from "@eslint/js";
2+
import tseslint from "typescript-eslint";
3+
import angular from "angular-eslint";
4+
5+
const config = [
6+
{
7+
// Everything in this config object targets our TypeScript files (Components, Directives, Pipes etc)
8+
files: ["**/*.ts"],
9+
extends: [
10+
// Apply the recommended core rules
11+
eslint.configs.recommended,
12+
// Apply the recommended TypeScript rules
13+
...tseslint.configs.recommended,
14+
// Optionally apply stylistic rules from typescript-eslint that improve code consistency
15+
...tseslint.configs.stylistic,
16+
// Apply the recommended Angular rules
17+
...angular.configs.tsRecommended,
18+
],
19+
// Set the custom processor which will allow us to have our inline Component templates extracted
20+
// and treated as if they are HTML files (and therefore have the .html config below applied to them)
21+
processor: angular.processInlineTemplates,
22+
// Override specific rules for TypeScript files (these will take priority over the extended configs above)
23+
rules: {
24+
"@angular-eslint/directive-selector": [
25+
"error",
26+
{
27+
type: "attribute",
28+
prefix: "app",
29+
style: "camelCase",
30+
},
31+
],
32+
"@angular-eslint/component-selector": [
33+
"error",
34+
{
35+
type: "element",
36+
prefix: "app",
37+
style: "kebab-case",
38+
},
39+
],
40+
},
41+
},
42+
{
43+
// Everything in this config object targets our HTML files (external templates,
44+
// and inline templates as long as we have the `processor` set on our TypeScript config above)
45+
files: ["**/*.html"],
46+
extends: [
47+
// Apply the recommended Angular template rules
48+
...angular.configs.templateRecommended,
49+
// Apply the Angular template rules which focus on accessibility of our apps
50+
...angular.configs.templateAccessibility,
51+
],
52+
rules: {},
53+
},
54+
];
55+
56+
export default config;

0 commit comments

Comments
 (0)