mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-18 03:01:05 +01:00
specify jest environment for tests and use airbnb-base for node
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
"@typescript-eslint/parser": "^2.12.0",
|
||||
"babel-eslint": "^10.0.3",
|
||||
"eslint": "^7.2.0",
|
||||
"eslint-config-airbnb-base": "^14.2.0",
|
||||
"eslint-config-prettier": "^6.4.0",
|
||||
"eslint-config-react-app": "^5.0.2",
|
||||
"eslint-plugin-flowtype": "^4.3.0",
|
||||
|
||||
@@ -22,29 +22,65 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
module.exports = {
|
||||
parser: "@typescript-eslint/parser",
|
||||
env: {
|
||||
node: false,
|
||||
browser: true
|
||||
},
|
||||
extends: ["react-app", "plugin:prettier/recommended", "plugin:@typescript-eslint/recommended"],
|
||||
rules: {
|
||||
const rules = {
|
||||
"prettier/prettier": "warn",
|
||||
semi: ["error", "always"],
|
||||
quotes: ["error", "double", "avoid-escape"],
|
||||
"jsx-a11y/href-no-hash": [0],
|
||||
"no-var": "error"
|
||||
};
|
||||
|
||||
const nodeConfiguration = {
|
||||
extends: ["airbnb-base", "plugin:prettier/recommended"],
|
||||
rules
|
||||
};
|
||||
|
||||
const typescriptConfiguration = {
|
||||
parser: "@typescript-eslint/parser",
|
||||
extends: ["react-app", "plugin:@typescript-eslint/recommended"],
|
||||
rules: {
|
||||
"@typescript-eslint/explicit-function-return-type": "off",
|
||||
"@typescript-eslint/ban-ts-ignore": "warn",
|
||||
"no-console": "error"
|
||||
},
|
||||
"no-console": "error",
|
||||
"jsx-a11y/href-no-hash": [0],
|
||||
...rules
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
overrides: [
|
||||
{
|
||||
files: ["*.test.js"],
|
||||
env: {
|
||||
node: true,
|
||||
jest: true,
|
||||
browser: false
|
||||
},
|
||||
...nodeConfiguration
|
||||
},
|
||||
{
|
||||
files: ["*.js"],
|
||||
env: {
|
||||
node: true,
|
||||
browser: false
|
||||
}
|
||||
},
|
||||
...nodeConfiguration
|
||||
},
|
||||
{
|
||||
files: ["*.test.ts", "*.test.tsx"],
|
||||
env: {
|
||||
node: true,
|
||||
jest: true,
|
||||
browser: false
|
||||
},
|
||||
...typescriptConfiguration
|
||||
},
|
||||
{
|
||||
files: ["*.ts", "*.tsx"],
|
||||
env: {
|
||||
node: false,
|
||||
browser: true
|
||||
},
|
||||
...typescriptConfiguration
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
@@ -1,3 +1,27 @@
|
||||
/*
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2020-present Cloudogu GmbH and Contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
const { ESLint } = require("eslint");
|
||||
const path = require("path");
|
||||
|
||||
@@ -8,7 +32,7 @@ describe("should lint files", () => {
|
||||
const lint = async file => {
|
||||
const results = await eslint.lintFiles([path.join(resource, file)]);
|
||||
|
||||
const messages = results[0].messages;
|
||||
const { messages } = results[0];
|
||||
|
||||
const warnings = messages.filter(m => m.severity === 1).map(m => m.ruleId);
|
||||
const errors = messages.filter(m => m.severity === 2).map(m => m.ruleId);
|
||||
@@ -19,10 +43,8 @@ describe("should lint files", () => {
|
||||
};
|
||||
|
||||
const expectContains = (results, ...ids) => {
|
||||
for (const id of ids) {
|
||||
expect(results).toContain(id);
|
||||
}
|
||||
}
|
||||
ids.forEach(id => expect(results).toContain(id));
|
||||
};
|
||||
|
||||
it("should lint tsx files", async () => {
|
||||
const { errors, warnings } = await lint("TypescriptWithJsx.tsx");
|
||||
@@ -32,7 +54,7 @@ describe("should lint files", () => {
|
||||
|
||||
it("should lint js files", async () => {
|
||||
const { errors, warnings } = await lint("Node.js");
|
||||
expectContains(errors, "no-var", "no-console", "quotes", "semi");
|
||||
expectContains(errors, "no-var", "quotes", "semi");
|
||||
expectContains(warnings, "prettier/prettier");
|
||||
});
|
||||
|
||||
|
||||
37
yarn.lock
37
yarn.lock
@@ -4098,11 +4098,6 @@ babel-code-frame@^6.22.0:
|
||||
esutils "^2.0.2"
|
||||
js-tokens "^3.0.2"
|
||||
|
||||
babel-core@7.0.0-bridge.0:
|
||||
version "7.0.0-bridge.0"
|
||||
resolved "https://registry.yarnpkg.com/babel-core/-/babel-core-7.0.0-bridge.0.tgz#95a492ddd90f9b4e9a4a1da14eb335b87b634ece"
|
||||
integrity sha512-poPX9mZH/5CSanm50Q+1toVci6pv5KSRv/5TWCwtzQS5XEwn40BcCrgIeMFWP9CKKIniKXNxoIOnOq4VVlGXhg==
|
||||
|
||||
babel-eslint@^10.0.3:
|
||||
version "10.1.0"
|
||||
resolved "https://registry.yarnpkg.com/babel-eslint/-/babel-eslint-10.1.0.tgz#6968e568a910b78fb3779cdd8b6ac2f479943232"
|
||||
@@ -6963,6 +6958,15 @@ escodegen@^1.9.1:
|
||||
optionalDependencies:
|
||||
source-map "~0.6.1"
|
||||
|
||||
eslint-config-airbnb-base@^14.2.0:
|
||||
version "14.2.0"
|
||||
resolved "https://registry.yarnpkg.com/eslint-config-airbnb-base/-/eslint-config-airbnb-base-14.2.0.tgz#fe89c24b3f9dc8008c9c0d0d88c28f95ed65e9c4"
|
||||
integrity sha512-Snswd5oC6nJaevs3nZoLSTvGJBvzTfnBqOIArkf3cbyTyq9UD79wOk8s+RiL6bhca0p/eRO6veczhf6A/7Jy8Q==
|
||||
dependencies:
|
||||
confusing-browser-globals "^1.0.9"
|
||||
object.assign "^4.1.0"
|
||||
object.entries "^1.1.2"
|
||||
|
||||
eslint-config-prettier@^6.4.0:
|
||||
version "6.11.0"
|
||||
resolved "https://registry.yarnpkg.com/eslint-config-prettier/-/eslint-config-prettier-6.11.0.tgz#f6d2238c1290d01c859a8b5c1f7d352a0b0da8b1"
|
||||
@@ -7431,7 +7435,7 @@ fast-levenshtein@^2.0.6, fast-levenshtein@~2.0.6:
|
||||
resolved "https://registry.yarnpkg.com/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz#3d8a5c66883a16a30ca8643e851f19baa7797917"
|
||||
integrity sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=
|
||||
|
||||
fault@^1.0.0:
|
||||
fault@^1.0.0, fault@^1.0.2:
|
||||
version "1.0.4"
|
||||
resolved "https://registry.yarnpkg.com/fault/-/fault-1.0.4.tgz#eafcfc0a6d214fc94601e170df29954a4f842f13"
|
||||
integrity sha512-CJ0HCB5tL5fYTEA7ToAq5+kTwd++Borf1/bifxd9iT70QcXr4MRrO3Llf8Ifs70q+SJcGHFtnIE/Nw6giCtECA==
|
||||
@@ -7965,7 +7969,7 @@ gitconfiglocal@^1.0.0:
|
||||
dependencies:
|
||||
ini "^1.3.2"
|
||||
|
||||
gitdiff-parser@^0.1.2, "gitdiff-parser@https://github.com/scm-manager/gitdiff-parser#617747460280bf4522bb84d217a9064ac8eb6d3d":
|
||||
gitdiff-parser@^0.1.2:
|
||||
version "0.1.2"
|
||||
resolved "https://github.com/scm-manager/gitdiff-parser#617747460280bf4522bb84d217a9064ac8eb6d3d"
|
||||
|
||||
@@ -10771,7 +10775,7 @@ lower-case@^2.0.1:
|
||||
dependencies:
|
||||
tslib "^1.10.0"
|
||||
|
||||
lowlight@1.13.1, lowlight@^1.13.0, lowlight@~1.11.0:
|
||||
lowlight@^1.13.0:
|
||||
version "1.13.1"
|
||||
resolved "https://registry.yarnpkg.com/lowlight/-/lowlight-1.13.1.tgz#c4f0e03906ebd23fedf2d258f6ab2f6324cf90eb"
|
||||
integrity sha512-kQ71/T6RksEVz9AlPq07/2m+SU/1kGvt9k39UtvHX760u4SaWakaYH7hYgH5n6sTsCWk4MVYzUzLU59aN5CSmQ==
|
||||
@@ -10779,6 +10783,14 @@ lowlight@1.13.1, lowlight@^1.13.0, lowlight@~1.11.0:
|
||||
fault "^1.0.0"
|
||||
highlight.js "~9.16.0"
|
||||
|
||||
lowlight@~1.11.0:
|
||||
version "1.11.0"
|
||||
resolved "https://registry.yarnpkg.com/lowlight/-/lowlight-1.11.0.tgz#1304d83005126d4e8b1dc0f07981e9b689ec2efc"
|
||||
integrity sha512-xrGGN6XLL7MbTMdPD6NfWPwY43SNkjf/d0mecSx/CW36fUZTjRHEq0/Cdug3TWKtRXLWi7iMl1eP0olYxj/a4A==
|
||||
dependencies:
|
||||
fault "^1.0.2"
|
||||
highlight.js "~9.13.0"
|
||||
|
||||
lru-cache@^5.1.1:
|
||||
version "5.1.1"
|
||||
resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-5.1.1.tgz#1da27e6710271947695daf6848e847f01d84b920"
|
||||
@@ -11779,6 +11791,15 @@ object.entries@^1.1.0, object.entries@^1.1.1:
|
||||
function-bind "^1.1.1"
|
||||
has "^1.0.3"
|
||||
|
||||
object.entries@^1.1.2:
|
||||
version "1.1.2"
|
||||
resolved "https://registry.yarnpkg.com/object.entries/-/object.entries-1.1.2.tgz#bc73f00acb6b6bb16c203434b10f9a7e797d3add"
|
||||
integrity sha512-BQdB9qKmb/HyNdMNWVr7O3+z5MUIx3aiegEIJqjMBbBf0YT9RRxTJSim4mzFqtyr7PDAHigq0N9dO0m0tRakQA==
|
||||
dependencies:
|
||||
define-properties "^1.1.3"
|
||||
es-abstract "^1.17.5"
|
||||
has "^1.0.3"
|
||||
|
||||
"object.fromentries@^2.0.0 || ^1.0.0", object.fromentries@^2.0.2:
|
||||
version "2.0.2"
|
||||
resolved "https://registry.yarnpkg.com/object.fromentries/-/object.fromentries-2.0.2.tgz#4a09c9b9bb3843dd0f89acdb517a794d4f355ac9"
|
||||
|
||||
Reference in New Issue
Block a user