@konomi-app/k2 0.8.1 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,19 @@
1
+ import { program } from 'commander';
2
+ import { lint } from '../lib/lint.js';
3
+ export default function command() {
4
+ program
5
+ .command('lint')
6
+ .description('Lint source files')
7
+ .option('-c, --config <config>', 'Config file path')
8
+ .action(action);
9
+ }
10
+ export async function action(options) {
11
+ try {
12
+ lint();
13
+ }
14
+ catch (error) {
15
+ throw error;
16
+ }
17
+ finally {
18
+ }
19
+ }
@@ -5,6 +5,7 @@ import { PLUGIN_CONTENTS_DIRECTORY } from '../lib/constants.js';
5
5
  import { importPluginConfig } from '../lib/import.js';
6
6
  import { getTailwindConfig, outputCss } from '../lib/tailwind.js';
7
7
  import base from './build-base.js';
8
+ import { lint } from '../lib/lint.js';
8
9
  export default function command() {
9
10
  program
10
11
  .command('build')
@@ -15,6 +16,9 @@ export async function action() {
15
16
  console.group('🍳 Build the project for production');
16
17
  try {
17
18
  const config = await importPluginConfig();
19
+ if (config?.lint?.build) {
20
+ await lint();
21
+ }
18
22
  if (!fs.existsSync(PLUGIN_CONTENTS_DIRECTORY)) {
19
23
  await fs.mkdir(PLUGIN_CONTENTS_DIRECTORY, { recursive: true });
20
24
  }
package/dist/index.js CHANGED
@@ -6,11 +6,13 @@ import dev from './commands/dev.js';
6
6
  import viteDev from './commands/dev-vite.js';
7
7
  import genkey from './commands/genkey.js';
8
8
  import esbuildBuild from './commands/build-esbuild.js';
9
- program.name('k2').version('0.8.0').description('k2 - 🍳 kintone kitchen 🍳');
9
+ import lint from './commands/lint.js';
10
+ program.name('k2').version('0.9.0').description('k2 - 🍳 kintone kitchen 🍳');
10
11
  build();
11
12
  viteBuild();
12
13
  esbuildBuild();
13
14
  dev();
14
15
  viteDev();
15
16
  genkey();
17
+ lint();
16
18
  program.parse(process.argv);
@@ -0,0 +1,54 @@
1
+ import { ESLint } from 'eslint';
2
+ export async function lint() {
3
+ const eslint = new ESLint({
4
+ baseConfig: {
5
+ env: {
6
+ browser: true,
7
+ es2021: true,
8
+ },
9
+ extends: [
10
+ 'eslint:recommended',
11
+ 'plugin:@typescript-eslint/recommended',
12
+ 'plugin:react/recommended',
13
+ 'prettier',
14
+ ],
15
+ parser: '@typescript-eslint/parser',
16
+ parserOptions: {
17
+ ecmaVersion: 'latest',
18
+ sourceType: 'module',
19
+ project: './tsconfig.json',
20
+ ecmaFeatures: {
21
+ jsx: true,
22
+ },
23
+ },
24
+ plugins: ['@typescript-eslint', 'react'],
25
+ rules: {
26
+ 'react/prop-types': 'off',
27
+ },
28
+ overrides: [
29
+ {
30
+ files: ['*.ts', '*.tsx'],
31
+ rules: {
32
+ 'react/prop-types': 'off',
33
+ },
34
+ },
35
+ ],
36
+ settings: {
37
+ react: {
38
+ version: 'detect',
39
+ },
40
+ },
41
+ },
42
+ });
43
+ const results = await eslint.lintFiles(['src/**/*.ts', 'src/**/*.tsx']);
44
+ const formatter = await eslint.loadFormatter('stylish');
45
+ const resultText = formatter.format(results);
46
+ console.group('👕 Lint Results');
47
+ console.log(resultText);
48
+ console.groupEnd();
49
+ const hasErrors = results.some((result) => result.errorCount > 0);
50
+ if (hasErrors) {
51
+ console.error('🚨 Lint errors found');
52
+ process.exit(1);
53
+ }
54
+ }
package/dist/plugin.js CHANGED
@@ -9,7 +9,8 @@ import manifest from './commands/manifest/index.js';
9
9
  import test from './commands/test/index.js';
10
10
  import upload from './commands/upload/index.js';
11
11
  import zip from './commands/plugin-zip.js';
12
- program.name('plugin').version('0.8.0').description('🍳 kintone kitchen 🍳 for kintone plugin');
12
+ import lint from './commands/lint.js';
13
+ program.name('plugin').version('0.9.0').description('🍳 kintone kitchen 🍳 for kintone plugin');
13
14
  build();
14
15
  esbuild();
15
16
  dev();
@@ -19,4 +20,5 @@ manifest();
19
20
  test();
20
21
  upload();
21
22
  zip();
23
+ lint();
22
24
  program.parse(process.argv);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@konomi-app/k2",
3
- "version": "0.8.1",
3
+ "version": "0.9.0",
4
4
  "description": "kintone sdk",
5
5
  "main": "./dist/index.js",
6
6
  "type": "module",
@@ -26,6 +26,8 @@
26
26
  "dependencies": {
27
27
  "@kintone/plugin-packer": "^8",
28
28
  "@kintone/plugin-uploader": "^9",
29
+ "@typescript-eslint/eslint-plugin": "^7.12.0",
30
+ "@typescript-eslint/parser": "^7.12.0",
29
31
  "archiver": "^7",
30
32
  "chalk": "^5",
31
33
  "chokidar": "^3",
@@ -34,6 +36,12 @@
34
36
  "cssnano": "^7.0.2",
35
37
  "dotenv": "^16",
36
38
  "esbuild": "^0.21",
39
+ "eslint": "^8.57.0",
40
+ "eslint-config-prettier": "^9.1.0",
41
+ "eslint-plugin-import": "^2.29.1",
42
+ "eslint-plugin-n": "^17.8.1",
43
+ "eslint-plugin-promise": "^6.2.0",
44
+ "eslint-plugin-react": "^7.34.2",
37
45
  "express": "^4",
38
46
  "fs-extra": "^11",
39
47
  "html-minifier": "^4",
package/types/plugin.d.ts CHANGED
@@ -101,6 +101,12 @@ declare namespace Plugin {
101
101
  /** 0から65535までのポート番号 */
102
102
  port?: number;
103
103
  };
104
+
105
+ lint?: {
106
+ build?: boolean;
107
+ dev?: boolean;
108
+ };
109
+
104
110
  /**
105
111
  * tailwindcssを使用している場合、設定ファイルのパスとCSSファイルのパスを指定することで、JavaScriptファイルのビルド時にCSSファイルを生成します
106
112
  *