Skip to content

Commit af01d5c

Browse files
author
Abdelhalim Dadouche
committed
eslint upgrade + fixing eslint issues
1 parent 11f8e8d commit af01d5c

10 files changed

+241
-215
lines changed

.eslintrc.js

Lines changed: 0 additions & 68 deletions
This file was deleted.

eslint.config.mjs

Lines changed: 76 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,80 @@
1+
import typescriptEslintEslintPlugin from "@typescript-eslint/eslint-plugin";
2+
import tsdoc from "eslint-plugin-tsdoc";
13
import globals from "globals";
2-
import pluginJs from "@eslint/js";
3-
import tseslint from "typescript-eslint";
4+
import tsParser from "@typescript-eslint/parser";
5+
import path from "node:path";
6+
import { fileURLToPath } from "node:url";
7+
import js from "@eslint/js";
8+
import { FlatCompat } from "@eslint/eslintrc";
49

10+
const __filename = fileURLToPath(import.meta.url);
11+
const __dirname = path.dirname(__filename);
512

6-
/** @type {import('eslint').Linter.Config[]} */
7-
export default [
8-
{files: ["**/*.{js,mjs,cjs,ts}"]},
9-
{files: ["**/*.js"], languageOptions: {sourceType: "commonjs"}},
10-
{languageOptions: { globals: globals.browser }},
11-
pluginJs.configs.recommended,
12-
...tseslint.configs.recommended,
13+
import { includeIgnoreFile } from "@eslint/compat";
14+
const gitignorePath = path.resolve(__dirname, ".gitignore");
15+
16+
const compat = new FlatCompat({
17+
baseDirectory: __dirname,
18+
recommendedConfig: js.configs.recommended,
19+
allConfig: js.configs.all
20+
});
21+
22+
export default [...compat.extends(
23+
"eslint:recommended",
24+
"plugin:@typescript-eslint/recommended",
25+
"plugin:prettier/recommended",
26+
), {
27+
plugins: {
28+
"@typescript-eslint": typescriptEslintEslintPlugin,
29+
tsdoc,
30+
},
31+
32+
languageOptions: {
33+
globals: {
34+
...globals.browser,
35+
...globals.node,
36+
...globals.jest,
37+
...globals.commonjs,
38+
},
39+
40+
parser: tsParser,
41+
ecmaVersion: "latest",
42+
sourceType: "module",
43+
44+
parserOptions: {
45+
sourceType: 'module',
46+
project: './tsconfig.json',
47+
},
48+
},
49+
50+
rules: {
51+
"tsdoc/syntax": "warn",
52+
53+
"max-len": ["error", {
54+
code: 150,
55+
ignoreUrls: true,
56+
ignoreStrings: true,
57+
ignoreTemplateLiterals: true,
58+
ignoreComments: true,
59+
ignoreRegExpLiterals: true,
60+
}],
61+
62+
"prettier/prettier": ["error", {
63+
singleQuote: true,
64+
trailingComma: "es5",
65+
}],
66+
},
67+
68+
ignores: [
69+
"jest.config.js",
70+
"package.json",
71+
"package-lock.json",
72+
"tsconfig.json",
73+
"typedoc.json",
74+
],
75+
},
76+
includeIgnoreFile(gitignorePath),
77+
{
78+
// your overrides
79+
},
1380
];

jest.config.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
module.exports = {
2-
testEnvironment: 'node',
3-
roots: ['<rootDir>/test'],
4-
testMatch: ['**/*.test.ts'],
1+
export default {
2+
testEnvironment: "node",
3+
roots: ["<rootDir>/test"],
4+
testMatch: ["**/*.test.ts"],
55
transform: {
6-
'^.+\\.tsx?$': 'ts-jest',
6+
"^.+\\.tsx?$": "ts-jest",
77
},
88
};

lib/build-image-pipeline.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ export interface BuildImagePipelineProps extends cdk.StackProps {
3535
readonly serverAccessLogsPrefix?: string;
3636
/** Artifact bucket to use */
3737
readonly artifactBucket?: s3.Bucket;
38-
3938
}
4039

4140
/**
@@ -107,10 +106,10 @@ export class BuildImagePipelineStack extends cdk.Stack {
107106

108107
let accessLoggingBucket: s3.IBucket;
109108

110-
if (props.accessLoggingBucket){
109+
if (props.accessLoggingBucket) {
111110
accessLoggingBucket = props.accessLoggingBucket;
112111
} else {
113-
accessLoggingBucket = new s3.Bucket(this, 'ArtifactAccessLogging', {
112+
accessLoggingBucket = new s3.Bucket(this, 'ArtifactAccessLogging', {
114113
versioned: true,
115114
enforceSSL: true,
116115
autoDeleteObjects: true,
@@ -120,13 +119,13 @@ export class BuildImagePipelineStack extends cdk.Stack {
120119

121120
let artifactBucket: s3.IBucket;
122121

123-
if (props.artifactBucket){
122+
if (props.artifactBucket) {
124123
artifactBucket = props.artifactBucket;
125124
} else {
126125
const encryptionKey = new kms.Key(this, 'PipelineArtifactKey', {
127-
removalPolicy: RemovalPolicy.DESTROY,
128-
enableKeyRotation: true,
129-
});
126+
removalPolicy: RemovalPolicy.DESTROY,
127+
enableKeyRotation: true,
128+
});
130129
artifactBucket = new s3.Bucket(this, 'PipelineArtifacts', {
131130
versioned: true,
132131
enforceSSL: true,

0 commit comments

Comments
 (0)