Skip to content

Commit

Permalink
Add eslint configuration and fix linting issues
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmad-PH committed Dec 30, 2023
1 parent aac97c9 commit 6b0b26a
Show file tree
Hide file tree
Showing 14 changed files with 1,263 additions and 36 deletions.
47 changes: 47 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"env": {
"node": true,
"es2020": true
},
"extends": "eslint:recommended",
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "commonjs"
},
"rules": {
"no-unused-vars": ["error", {
/*
* The \^[A-Z][a-z]+\ pattern is intended to allow the importing of constructor functions (a.k.a classes)
* for the sole purpose of using them in JSDoc type annotations. Without this, eslint
* would complain, because it doesn't recognize usage in JSDoc comments as actual usage.
*/
"varsIgnorePattern": "^[A-Z][a-z]+|^_",
"argsIgnorePattern": "^_",
"caughtErrorsIgnorePattern": "^_"
}]
},
"overrides": [
{
"files": ["src/**/*.js"],
"env": {
"browser": true
},
"parserOptions": {
"sourceType": "module"
},
"globals": {
"chrome": "readonly",
"WEBPACK_MODE": "readonly"
}
},
{
"files": ["tests/**/*.js"],
"env": {
"jest": true
},
"parserOptions": {
"sourceType": "commonjs"
}
}
]
}
1 change: 1 addition & 0 deletions globals.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
declare var WEBPACK_MODE: string;
9 changes: 5 additions & 4 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// eslint-disable-next-line no-undef
module.exports = {
testMatch: ["<rootDir>/tests/**/*.test.js"],
// moduleNameMapper: {
// "^src/(.*)": "<rootDir>/src/$1"
// }
};
moduleNameMapper: {
"^src/(.*)": "<rootDir>/src/$1"
}
};
8 changes: 5 additions & 3 deletions jsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
"noEmit": true,
"target": "es6",
"module": "commonjs",
"lib": ["es2016", "dom"],
"typeRoots": ["node_modules/@types"]
"lib": ["es2019", "dom"],
"typeRoots": ["node_modules/@types"],
"types": ["chrome"]
},
"include": [
"src/**/*"
"src/**/*",
"globals.d.ts"
]
}
Loading

0 comments on commit 6b0b26a

Please sign in to comment.