Przeglądaj źródła

organize packages

Yuki Takei 4 lat temu
rodzic
commit
434319f79b

+ 4 - 0
.eslintrc.js

@@ -26,5 +26,9 @@ module.exports = {
         FunctionExpression: { body: 1, parameters: 2 },
         FunctionExpression: { body: 1, parameters: 2 },
       },
       },
     ],
     ],
+    'jest/no-standalone-expect': [
+      'error',
+      { additionalTestBlockFunctions: ['each.test'] },
+    ],
   },
   },
 };
 };

+ 1 - 6
packages/core/.eslintignore

@@ -1,6 +1 @@
-/.github/**
-/.vscode/**
-/node_modules/**
-/public/**
-/test/**
-/tmp/**
+/dist/**

+ 60 - 0
packages/core/jest.config.js

@@ -0,0 +1,60 @@
+// For a detailed explanation regarding each configuration property, visit:
+// https://jestjs.io/docs/en/configuration.html
+
+const MODULE_NAME_MAPPING = {
+  '^~/(.+)$': '<rootDir>/src/$1',
+};
+
+module.exports = {
+
+  preset: 'ts-jest/presets/js-with-ts',
+
+  moduleNameMapper: MODULE_NAME_MAPPING,
+
+  // Automatically clear mock calls and instances between every test
+  clearMocks: true,
+
+  // Indicates whether the coverage information should be collected while executing the test
+  collectCoverage: true,
+
+  // An array of glob patterns indicating a set of files for which coverage information should be collected
+  // collectCoverageFrom: undefined,
+
+  // The directory where Jest should output its coverage files
+  coverageDirectory: 'coverage',
+
+  // An array of regexp pattern strings used to skip coverage collection
+  coveragePathIgnorePatterns: [
+    '/node_modules/',
+  ],
+
+  // An object that configures minimum threshold enforcement for coverage results
+  // TODO: activate -- 2020.03.24 Yuki Takei
+  // coverageThreshold: {
+  //   global: {
+  //     branches: 70,
+  //     functions: 70,
+  //     lines: 70,
+  //     statements: 70,
+  //   },
+  // },
+
+  // An array of file extensions your modules use
+  moduleFileExtensions: [
+    'js',
+    'json',
+    'jsx',
+    'ts',
+    'tsx',
+    'node',
+  ],
+
+  // The test environment that will be used for testing
+  testEnvironment: 'node',
+
+  // The glob patterns Jest uses to detect test files
+  testMatch: [
+    '**/src/**/__tests__/**/*.[jt]s?(x)',
+    '**/src/**/?(*.)+(spec|test).[tj]s?(x)',
+  ],
+};

+ 8 - 38
packages/core/package.json

@@ -1,7 +1,8 @@
 {
 {
-  "name": "growi-commons",
-  "version": "5.0.4",
-  "description": "GROWI Commons Libraries",
+  "name": "@growi/core",
+  "version": "4.3.3-RC",
+  "description": "GROWI Core Libraries",
+  "license": "MIT",
   "keywords": [
   "keywords": [
     "growi"
     "growi"
   ],
   ],
@@ -10,52 +11,21 @@
     "src"
     "src"
   ],
   ],
   "scripts": {
   "scripts": {
-    "lint:js:fix": "eslint **/*.{js,jsx} --fix",
     "lint:js": "eslint **/*.{js,jsx}",
     "lint:js": "eslint **/*.{js,jsx}",
-    "lint:styles:fix": "prettier-stylelint --quiet --write src/styles/scss/**/*.scss",
     "lint:styles": "stylelint src/styles/scss/**/*.scss",
     "lint:styles": "stylelint src/styles/scss/**/*.scss",
-    "lint": "npm-run-all -p lint:js lint:styles",
+    "lint": "npm-run-all -p lint:*",
     "test": "jest --verbose"
     "test": "jest --verbose"
   },
   },
-  "repository": "https://github.com/weseek/growi-commons.git",
-  "author": "Yuki Takei <yuki@weseek.co.jp>",
-  "license": "MIT",
-  "bugs": {
-    "url": "https://github.com/weseek/growi-commons/issues"
-  },
   "dependencies": {},
   "dependencies": {},
-  "homepage": "https://github.com/weseek/growi-commons#readme",
   "devDependencies": {
   "devDependencies": {
-    "@babel/preset-env": "^7.4.3",
-    "babel-eslint": "^10.0.1",
-    "babel-plugin-rewire": "^1.2.0",
-    "eslint": "^6.0.1",
-    "eslint-config-weseek": "^1.0.2",
-    "eslint-plugin-import": "^2.18.0",
-    "eslint-plugin-jest": "^22.7.2",
-    "eslint-plugin-react": "^7.14.2",
-    "jest": "^24.7.1",
-    "jest-localstorage-mock": "^2.4.0",
-    "module-alias": "^2.2.0",
+    "jest": "^27.0.6",
+    "jest-localstorage-mock": "^2.4.14",
     "npm-run-all": "^4.1.5",
     "npm-run-all": "^4.1.5",
-    "prettier-stylelint": "^0.4.2"
-  },
-  "_moduleAliases": {
-    "@root": ".",
-    "@src": "src"
+    "ts-jest": "^27.0.4"
   },
   },
   "jest": {
   "jest": {
-    "moduleNameMapper": {
-      "@root/(.+)": "<rootDir>/$1",
-      "@src/(.+)": "<rootDir>/src/$1"
-    },
     "setupFiles": [
     "setupFiles": [
       "jest-localstorage-mock"
       "jest-localstorage-mock"
     ]
     ]
-  },
-  "engines": {
-    "node": ">=8.11.1 <15",
-    "npm": ">=5.6.0 <7",
-    "yarn": ">=1.5.1 <2"
   }
   }
 }
 }

+ 14 - 0
packages/core/tsconfig.json

@@ -0,0 +1,14 @@
+{
+  "extends": "../../tsconfig.base.json",
+  "compilerOptions": {
+    "baseUrl": ".",
+    "paths": {
+      "~/*": ["./src/*"],
+    }
+  },
+  "exclude": [
+    "node_modules",
+    "dist",
+    "**/*.test.ts"
+  ]
+}

+ 5 - 0
yarn.lock

@@ -10963,6 +10963,11 @@ jest-leak-detector@^27.0.6:
     jest-get-type "^27.0.6"
     jest-get-type "^27.0.6"
     pretty-format "^27.0.6"
     pretty-format "^27.0.6"
 
 
+jest-localstorage-mock@^2.4.14:
+  version "2.4.14"
+  resolved "https://registry.yarnpkg.com/jest-localstorage-mock/-/jest-localstorage-mock-2.4.14.tgz#f42f2ce66ac2675955d537c99f93cff807967d0f"
+  integrity sha512-B+Y0y3J4wBOHdmcFSicWmVYMFAZFbJvjs1EfRIzUJRg2UAK+YVVUgTn7/MdjENey5xbBKmraBmKY5EX+x1NJXA==
+
 jest-matcher-utils@^27.0.6:
 jest-matcher-utils@^27.0.6:
   version "27.0.6"
   version "27.0.6"
   resolved "https://registry.yarnpkg.com/jest-matcher-utils/-/jest-matcher-utils-27.0.6.tgz#2a8da1e86c620b39459f4352eaa255f0d43e39a9"
   resolved "https://registry.yarnpkg.com/jest-matcher-utils/-/jest-matcher-utils-27.0.6.tgz#2a8da1e86c620b39459f4352eaa255f0d43e39a9"