presetter-preset-react 3.1.0 → 3.3.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.
package/README.md CHANGED
@@ -4,14 +4,14 @@
4
4
 
5
5
  🏄🏻 _A collection of opinionated configurations for a React project in typescript for presetter_
6
6
 
7
- •   [Quick Start](#quick-start)   •   [Project Structure](#project-structure)   •   [Customisation](#customisation)   •   [Scripts](#script-template-summary)   •
7
+ •   [Quick Start](#quick-start)   •   [Project Structure](#project-structure)   •   [Customization](#customization)   •   [Scripts](#script-template-summary)   •
8
8
 
9
9
  [![npm](https://img.shields.io/npm/v/presetter-preset-react?style=flat-square)](https://github.com/alvis/presetter/releases)
10
10
  [![build](https://img.shields.io/github/workflow/status/alvis/presetter/code%20test?style=flat-square)](https://github.com/alvis/presetter/actions)
11
11
  [![maintainability](https://img.shields.io/codeclimate/maintainability/alvis/presetter?style=flat-square)](https://codeclimate.com/github/alvis/presetter/maintainability)
12
12
  [![coverage](https://img.shields.io/codeclimate/coverage/alvis/presetter?style=flat-square)](https://codeclimate.com/github/alvis/presetter/test_coverage)
13
13
  [![security](https://img.shields.io/snyk/vulnerabilities/github/alvis/presetter/packages/preset-react/package.json.svg?style=flat-square)](https://snyk.io/test/github/alvis/presetter?targetFile=packages/preset-react/package.json&style=flat-square)
14
- [![dependencies](https://img.shields.io/david/alvis/presetter?path=packages/preset-react&style=flat-square)](https://david-dm.org/alvis/presetter?path=packages/preset-react)
14
+ [![dependencies](https://img.shields.io/librariesio/release/npm/presetter-preset-react?style=flat-square)](https://libraries.io/npm/presetter-preset-react)
15
15
  [![license](https://img.shields.io/github/license/alvis/presetter.svg?style=flat-square)](https://github.com/alvis/presetter/blob/master/LICENSE)
16
16
 
17
17
  </div>
@@ -49,13 +49,13 @@ After installation, your project file structure should resemble the following or
49
49
 
50
50
  Implement your business logic under `source` and prepare tests under `spec`. The `.d.ts` files are handy type definitions for you to import `.css` or image files in typescript.
51
51
 
52
- **TIPS** You can always change the source directory to other (e.g. src) by setting the `source` variable in `.presetterrc.json`. See the [customisation](https://github.com/alvis/presetter/blob/master/packages/preset-react#customisation) section below for more details.
52
+ **TIPS** You can always change the source directory to other (e.g. src) by setting the `source` variable in `.presetterrc.json`. See the [customization](https://github.com/alvis/presetter/blob/master/packages/preset-react#customization) section below for more details.
53
53
 
54
54
  ```
55
55
  (root)
56
56
  ├─ .eslintrc.json
57
57
  ├─ .git
58
- ├─ .preseterrc.json
58
+ ├─ .presetterrc.json
59
59
  ├─ node_modules
60
60
  ├─ source
61
61
  │ ├─ <folders>
@@ -71,10 +71,10 @@ Implement your business logic under `source` and prepare tests under `spec`. The
71
71
  └─ tsconfig.json
72
72
  ```
73
73
 
74
- ## Customisation
74
+ ## Customization
75
75
 
76
76
  By default, this preset exports a handy configuration set for a React project written in typescript.
77
- But you can further customise (either extending or replacing) the configuration by specifying the change in the config file (`.presetterrc` or `.presetterrc.json`).
77
+ But you can further customize (either extending or replacing) the configuration by specifying the change in the config file (`.presetterrc` or `.presetterrc.json`).
78
78
 
79
79
  These settings are available in the `config` field in the config file. For directories, the setting is specified in the `variable` field.
80
80
 
@@ -12,9 +12,3 @@ rules:
12
12
  contexts:
13
13
  - FunctionDeclaration:has(BlockStatement > ReturnStatement:not([argument.type='JSXElement']))
14
14
  - ArrowFunctionExpression:has(BlockStatement > ReturnStatement:not([argument.type='JSXElement']))
15
- overrides:
16
- - files:
17
- - '**/__tests__/**/*.[jt]sx'
18
- - '**/?(*.)+(spec|test).[jt]sx'
19
- extends:
20
- - plugin:testing-library/react
package/lib/index.js CHANGED
@@ -1,86 +1,37 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
2
+ Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.DEFAULT_VARIABLE = void 0;
7
- exports.default = _default;
8
-
9
- var _path = require("path");
10
-
11
- /*
12
- * *** MIT LICENSE ***
13
- * -------------------------------------------------------------------------
14
- * This code may be modified and distributed under the MIT license.
15
- * See the LICENSE file for details.
16
- * -------------------------------------------------------------------------
17
- *
18
- * @summary Preset for a React project
19
- *
20
- * @author Alvis HT Tang <alvis@hilbert.space>
21
- * @license MIT
22
- * @copyright Copyright (c) 2021 - All Rights Reserved.
23
- * -------------------------------------------------------------------------
24
- */
25
- // paths to the template directory
26
- const TEMPLATES = (0, _path.resolve)(__dirname, '..', 'templates');
27
- const CONFIGS = (0, _path.resolve)(__dirname, '..', 'configs');
28
- /** config for this preset */
29
-
30
- const DEFAULT_VARIABLE = {
31
- source: 'source',
32
- types: 'types',
33
- output: 'lib'
4
+ const path_1 = require("path");
5
+ const TEMPLATES = (0, path_1.resolve)(__dirname, '..', 'templates');
6
+ const CONFIGS = (0, path_1.resolve)(__dirname, '..', 'configs');
7
+ exports.DEFAULT_VARIABLE = {
8
+ source: 'source',
9
+ types: 'types',
10
+ output: 'lib',
34
11
  };
35
- exports.DEFAULT_VARIABLE = DEFAULT_VARIABLE;
36
12
  const IMAGE_TYPE = 'image.d.ts';
37
13
  const STYLE_TYPE = 'style.d.ts';
38
-
39
- const template = ({
40
- custom: {
41
- variable: {
42
- types
43
- }
44
- }
45
- }) => ({
46
- '.eslintrc.json': (0, _path.resolve)(TEMPLATES, 'eslintrc.yaml'),
47
- 'tsconfig.json': (0, _path.resolve)(TEMPLATES, 'tsconfig.yaml'),
48
- [(0, _path.join)(types, IMAGE_TYPE)]: (0, _path.resolve)(TEMPLATES, IMAGE_TYPE),
49
- [(0, _path.join)(types, STYLE_TYPE)]: (0, _path.resolve)(TEMPLATES, STYLE_TYPE)
14
+ const template = ({ custom: { variable: { types }, }, }) => ({
15
+ '.eslintrc.json': (0, path_1.resolve)(TEMPLATES, 'eslintrc.yaml'),
16
+ 'tsconfig.json': (0, path_1.resolve)(TEMPLATES, 'tsconfig.yaml'),
17
+ [(0, path_1.join)(types, IMAGE_TYPE)]: (0, path_1.resolve)(TEMPLATES, IMAGE_TYPE),
18
+ [(0, path_1.join)(types, STYLE_TYPE)]: (0, path_1.resolve)(TEMPLATES, STYLE_TYPE),
50
19
  });
51
-
52
- const noSymlinks = ({
53
- custom: {
54
- variable: {
55
- types
56
- }
57
- }
58
- }) => [(0, _path.join)(types, IMAGE_TYPE), (0, _path.join)(types, STYLE_TYPE)];
59
-
20
+ const noSymlinks = ({ custom: { variable: { types }, }, }) => [(0, path_1.join)(types, IMAGE_TYPE), (0, path_1.join)(types, STYLE_TYPE)];
60
21
  const supplementaryConfig = {
61
- eslint: (0, _path.resolve)(CONFIGS, 'eslint.yaml'),
62
- gitignore: ({
63
- custom: {
64
- variable: {
65
- types
66
- }
67
- }
68
- }) => [(0, _path.join)('/', types, IMAGE_TYPE), (0, _path.join)('/', types, STYLE_TYPE)],
69
- jest: (0, _path.resolve)(CONFIGS, 'jest.yaml'),
70
- lintstaged: (0, _path.resolve)(CONFIGS, 'lintstaged.yaml'),
71
- rollup: (0, _path.resolve)(CONFIGS, 'rollup.yaml')
22
+ eslint: (0, path_1.resolve)(CONFIGS, 'eslint.yaml'),
23
+ gitignore: ({ custom: { variable: { types }, }, }) => [(0, path_1.join)('/', types, IMAGE_TYPE), (0, path_1.join)('/', types, STYLE_TYPE)],
24
+ jest: (0, path_1.resolve)(CONFIGS, 'jest.yaml'),
25
+ lintstaged: (0, path_1.resolve)(CONFIGS, 'lintstaged.yaml'),
26
+ rollup: (0, path_1.resolve)(CONFIGS, 'rollup.yaml'),
72
27
  };
73
- /**
74
- * get the list of templates provided by this preset
75
- * @returns list of preset templates
76
- */
77
-
78
- async function _default() {
79
- return {
80
- template,
81
- noSymlinks,
82
- supplementaryConfig,
83
- variable: DEFAULT_VARIABLE
84
- };
28
+ async function default_1() {
29
+ return {
30
+ template,
31
+ noSymlinks,
32
+ supplementaryConfig,
33
+ variable: exports.DEFAULT_VARIABLE,
34
+ };
85
35
  }
86
- //# sourceMappingURL=index.js.map
36
+ exports.default = default_1;
37
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW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,6 @@
1
1
  {
2
2
  "name": "presetter-preset-react",
3
- "version": "3.1.0",
3
+ "version": "3.3.0",
4
4
  "description": "An opinionated presetter preset for a React project",
5
5
  "keywords": [
6
6
  "presetter",
@@ -30,12 +30,11 @@
30
30
  "watch": "run watch"
31
31
  },
32
32
  "peerDependencies": {
33
- "@babel/preset-react": "^7.0.0",
34
33
  "@testing-library/react": "^12.0.0",
35
34
  "@types/react": "^17.0.0",
36
35
  "eslint-plugin-react": "^7.0.0",
37
36
  "eslint-plugin-testing-library": "^5.0.0",
38
- "presetter": "^3.1.0"
37
+ "presetter": "^3.3.0"
39
38
  },
40
39
  "devDependencies": {
41
40
  "presetter": "file:../presetter",
@@ -11,3 +11,15 @@ rules:
11
11
  - warn
12
12
  - callbacksLast: true
13
13
  shorthandFirst: true
14
+ overrides:
15
+ - files:
16
+ - '**/__tests__/**/*.[jt]sx'
17
+ - '**/?(*.)+(spec|test).[jt]sx'
18
+ extends:
19
+ - plugin:testing-library/react
20
+ - files:
21
+ - src/**/*.tsx
22
+ rules:
23
+ max-lines-per-function:
24
+ - warn
25
+ - max: 120
@@ -4,7 +4,7 @@ compilerOptions:
4
4
  module: commonjs # node doesn't support anything non commonjs code yet
5
5
  target: ES2017 # use ES2017 as it's the latest standard node 10 can be fully compatible with
6
6
  declaration: true
7
- sourceMap: true
7
+ inlineSourceMap: true
8
8
 
9
9
  # compatibility
10
10
  allowSyntheticDefaultImports: true
package/lib/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../source/index.ts"],"names":["TEMPLATES","__dirname","CONFIGS","DEFAULT_VARIABLE","source","types","output","IMAGE_TYPE","STYLE_TYPE","template","custom","variable","noSymlinks","supplementaryConfig","eslint","gitignore","jest","lintstaged","rollup"],"mappings":";;;;;;;;AAeA;;AAfA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAMA;AACA,MAAMA,SAAS,GAAG,mBAAQC,SAAR,EAAmB,IA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AD,EAA+B,gBAAK,GAAL,EAAUF,KAAV,EAAiBG,UAAjB,CAA/B,CANwD;AAO9DQ,EAAAA,IAAI,EAAE,mBAAQd,OAAR,EAAiB,WAAjB,CAPwD;AAQ9De,EAAAA,UAAU,EAAE,mBAAQf,OAAR,EAAiB,iBAAjB,CARkD;AAS9DgB,EAAAA,MAAM,EAAE,mBAAQhB,OAAR,EAAiB,aAAjB;AATsD,CAAhE;AAYA;AACA;AACA;AACA;;AACe,0BAAwC;AACrD,SAAO;AACLO,IAAAA,QADK;AAELG,IAAAA,UAFK;AAGLC,IAAAA,mBAHK;AAILF,IAAAA,QAAQ,EAAER;AAJL,GAAP;AAMD","sourcesContent":["/*\n * *** MIT LICENSE ***\n * -------------------------------------------------------------------------\n * This code may be modified and distributed under the MIT license.\n * See the LICENSE file for details.\n * -------------------------------------------------------------------------\n *\n * @summary Preset for a React project\n *\n * @author Alvis HT Tang <alvis@hilbert.space>\n * @license MIT\n * @copyright Copyright (c) 2021 - All Rights Reserved.\n * -------------------------------------------------------------------------\n */\n\nimport { join, resolve } from 'path';\n\nimport type { PresetAsset } from 'presetter';\n\n// paths to the template directory\nconst TEMPLATES = resolve(__dirname, '..', 'templates');\nconst CONFIGS = resolve(__dirname, '..', 'configs');\n\n/** config for this preset */\nexport type PresetConfig = {\n /** configuration to be merged with .eslintrc */\n eslint?: Record<string, unknown>;\n /** configuration to be merged with tsconfig.json */\n tsconfig?: Record<string, unknown>;\n};\n\n/** list of configurable variables */\nexport type Variable = {\n /** the directory containing all source code (default: source) */\n source?: string;\n /** the directory containing all extra typing files (default: types) */\n types?: string;\n /** the directory containing all the compiled files (default: lib) */\n output?: string;\n};\n\nexport const DEFAULT_VARIABLE: Variable = {\n source: 'source',\n types: 'types',\n output: 'lib',\n};\n\nconst IMAGE_TYPE = 'image.d.ts';\nconst STYLE_TYPE = 'style.d.ts';\n\nconst template: PresetAsset['template'] = ({\n custom: {\n variable: { types },\n },\n}) => ({\n '.eslintrc.json': resolve(TEMPLATES, 'eslintrc.yaml'),\n 'tsconfig.json': resolve(TEMPLATES, 'tsconfig.yaml'),\n [join(types, IMAGE_TYPE)]: resolve(TEMPLATES, IMAGE_TYPE),\n [join(types, STYLE_TYPE)]: resolve(TEMPLATES, STYLE_TYPE),\n});\n\nconst noSymlinks: PresetAsset['noSymlinks'] = ({\n custom: {\n variable: { types },\n },\n}) => [join(types, IMAGE_TYPE), join(types, STYLE_TYPE)];\n\nconst supplementaryConfig: PresetAsset['supplementaryConfig'] = {\n eslint: resolve(CONFIGS, 'eslint.yaml'),\n gitignore: ({\n custom: {\n variable: { types },\n },\n }) => [join('/', types, IMAGE_TYPE), join('/', types, STYLE_TYPE)],\n jest: resolve(CONFIGS, 'jest.yaml'),\n lintstaged: resolve(CONFIGS, 'lintstaged.yaml'),\n rollup: resolve(CONFIGS, 'rollup.yaml'),\n};\n\n/**\n * get the list of templates provided by this preset\n * @returns list of preset templates\n */\nexport default async function (): Promise<PresetAsset> {\n return {\n template,\n noSymlinks,\n supplementaryConfig,\n variable: DEFAULT_VARIABLE,\n };\n}\n"],"file":"index.js"}