Skip to content

zextras/carbonio-ui-configs

Repository files navigation

Carbonio UI Configs

This is the configurations set used by Zextras Carbonio ui projects

Contributors Activity License Project Twitter

Installation

npm install --save-dev @zextras/carbonio-ui-configs

Setup

To use the configuration set, you need to configure eslint, prettier and typescript to extend the rules defined in this package.

Eslint

The eslint configuration to extends is included in rules/eslint.js, extends your configuration file as the following

// .eslintrc.js

module.exports = {
  extends: ['./node_modules/@zextras/carbonio-ui-configs/rules/eslint.js']
};

In order to make eslint recognize the plugins configured within this package, an additional parameter is required when running eslint command: --resolve-plugins-relative-to node_modules/@zextras/carbonio-ui-configs

You can configure a script inside the package.json and then run npm run lint to easily run eslint with the required configuration:

// package.json
{
    "scripts": {
        "lint": "eslint --ext .js,.jsx,.ts,.tsx --resolve-plugins-relative-to node_modules/@zextras/carbonio-ui-configs src"
        // other scripts
    }
}

Prettier

Prettier needs to be configured to extend the rules defined in rules/prettier.js

// .prettierrc.js
module.exports = {
  ...require('@zextras/carbonio-ui-configs/rules/prettier')
}

Typescript

There are two typescript configuration available, one for type-checking Carbonio modules projects, the other for creating the types for the integrations exported by the module, so that the types can be used by other projects to type the used integrations.

The configuration for the type-check is the rules/tsconfig.type-check.json and should be used as extension in the main tsconfig.json of the projects.

// tsconfig.json
{
  "extends": "@zextras/carbonio-ui-configs/rules/tsconfig.type-check.json"
}
// package.json
{
  "scripts": {
    // ... other scripts ...
    "type-check": "tsc"
  }
}

The second one, to generate a package type, is the rules/tsconfig.lib.json and should be used as an extension in a specific tsconfig (e.g. tsconfig.lib.json), which is then used in a build:lib script of the package.json

// tsconfig.lib.json
{
  "extends": "@zextras/carbonio-ui-configs/rules/tsconfig.lib.json",
  "compilerOptions": {
    "types": ["node", /* add here additional types declarations, like styled-components.d.ts and i18next.d.ts */],
    "outDir": "lib"
  },
  "files": [
    // the entry point(s) for the integration exports, e.g. src/lib.ts
  ]
}
// package.json
{
  "name": "@zextras/carbonio-<module>-ui",
  "files": ["lib", "THIRDPARTIES"],
  "exports": {
    ".": {
      "types": "lib/<entry point>.d.ts" // e.g. lib/lib.d.ts if the entry point is src/lib.ts
    },
    "./*": null
  },
  "scripts": {
    // ... other scripts ...
    "build:lib": "rm -rf lib && tsc -P tsconfig.lib.json",
    "prepare": "(is-ci || husky); npm run build:lib"
  }
}

Remember to exclude the lib folder from git by adding an entry to the .gitignore

// .gitignore

// ... other entries ...
/lib

License

Carbonio UI Configs - Configurations set for Zextras Carbonio UI projects

Copyright (C) 2022 Zextras https://www.zextras.com

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, version 3 only of the License.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License along with this program. If not, see Licenses - GNU Project - Free Software Foundation

See COPYING file for the project license details

See THIRDPARTIES file for other licenses details

Copyright notice

All non-software material (such as, for example, names, images, logos, sounds) is owned by Zextras s.r.l. and is licensed under CC-BY-NC-SA.

Where not specified, all source files owned by Zextras s.r.l. are licensed under AGPL-3.0-only

About

Configurations set used by Zextras Carbonio UI projects

Resources

License

Stars

Watchers

Forks

Packages

No packages published