UNPKG

7.07 kBMarkdownView Raw
1Alfa Laboratory UI Presets
2==========================
3
4[![npm][npm-img]][npm]
5[![license][license-img]][license]
6[![travis][travis-img]][travis]
7[![appveyor][appveyor-img]][appveyor]
8[![greenkeeper][greenkeeper-img]][greenkeeper]
9
10[appveyor]: https://ci.appveyor.com/project/teryaew/arui-presets
11[appveyor-img]: https://img.shields.io/appveyor/ci/teryaew/arui-presets/master.svg?label=win
12[greenkeeper]: https://greenkeeper.io
13[greenkeeper-img]: https://badges.greenkeeper.io/alfa-laboratory/arui-presets.svg
14[license]: https://opensource.org/licenses/MIT
15[license-img]: https://img.shields.io/badge/License-MIT-brightgreen.svg
16[npm-img]: https://img.shields.io/npm/v/arui-presets.svg
17[npm]: https://www.npmjs.org/package/arui-presets
18[travis]: https://travis-ci.org/alfa-laboratory/arui-presets?branch=master
19[travis-img]: https://img.shields.io/travis/alfa-laboratory/arui-presets/master.svg?label=unix
20
21<br />
22
23Набор конфигурационных файлов для компиляции и валидации проектов, основанных на [arui-feather](https://github.com/alfa-laboratory/arui-feather).
24
25Установка
26---------
27```
28npm install arui-presets --save-dev
29```
30
31Или, если вы используете yarn:
32```
33yarn add arui-presets --dev
34```
35
36Использование линтеров
37----------------------
38
39#### commitlint
40Вы можете унаследовать конфигурацию вашего commitlint от `arui-presets/commitlint`.
41
42
43Файл `commitlint.config.js` вашего проекта:
44```js
45module.exports = {
46 extends: ['arui-presets/commitlint']
47};
48```
49
50
51#### eslint
52Вы можете унаследовать конфигурацию вашего eslint от `arui-presets/eslint`.
53
54
55Файл `.eslintrc.js` вашего проекта:
56```js
57module.exports = {
58 extends: require.resolve('arui-presets/eslint')
59};
60```
61
62#### stylelint
63Вы можете унаследовать конфигурацию вашего stylelint от `arui-presets/stylelint`.
64
65
66Файл `stylelint.config.js` вашего проекта:
67```js
68module.exports = {
69 extends: 'arui-presets/stylelint'
70};
71```
72
73В зависимостях этого проекта уже имеются stylelint и eslint с нужными наборами плагинов, поэтому
74для использования валидации достаточно добавить в "scripts" вашего package.json
75```
76"lint-css": "stylelint ./src/**/*.css",
77"lint-js": "eslint ./src/ --ext .js,.jsx",
78"lint": "npm run lint-css && npm run lint-js",
79```
80
81Конфигурация компиляторов
82-------------------------
83
84#### babel
85Вы можете использовать preset `arui-presets/babel`.
86
87
88Файл `.babelrc` вашего проекта:
89```json
90{
91 "presets": ["arui-presets/babel"]
92}
93```
94
95Настройки основаны на [babel-presets-env](https://babeljs.io/docs/plugins/preset-env/) с добавлением плагинов для
96поддержки декораторов и нескольких оптимизаций для react.
97
98Вы можете передать любые настройки, поддерживаемые `babel-presets-env`.
99Если вы хотите получить более адекватную для последних версий node версии компиляцию
100(например не компилировать `async/await`) вам необходимо определить env переменную `BABEL_TARGET=node`.
101Без этой env переменной сборка будет происходить в расчете на [поддерживаемые arui-feather](https://github.com/alfa-laboratory/arui-feather#%D0%9F%D0%BE%D0%B4%D0%B4%D0%B5%D1%80%D0%B6%D0%B8%D0%B2%D0%B0%D0%B5%D0%BC%D1%8B%D0%B5-%D0%B1%D1%80%D0%B0%D1%83%D0%B7%D0%B5%D1%80%D1%8B)
102версии браузеров.
103
104
105#### postcss
106Конфигурация для postcss требует настроек плагина postcss-custom-media. Взять их можно в `arui-feather/mq`.
107
108Файл postcss.config.js вашего проекта:
109```js
110const mq = require('arui-feather/mq/mq.json');
111const aruiConfig = require('arui-presets/postcss');
112module.exports = aruiConfig(mq);
113```
114
115Использование настроек webpack
116------------------------------
117
118В пакете также содержатся файлы с конфигурацией webpack.
119
120- `webpack.base.js` - общий шаблон для webpack
121- `webpack.development.js` - настройки для разработческой среды
122- `webpack.production.js` - настройки для боевой среды
123- `webpack.typescript.js` - настройки для использования typescript в проекте
124
125Лучший способ использовать их — объединять их пакетом [webpack-merge](https://github.com/survivejs/webpack-merge)
126
127```js
128const ARUI_TEMPLATE = require('arui-presets/webpack.base');
129const ARUI_DEV_TEMPLATE = require('arui-presets/webpack.development');
130const ARUI_PROD_TEMPLATE = require('arui-presets/webpack.production');
131const merge = require('webpack-merge');
132
133module.exports = merge.smart(
134 { entry: 'src/index.js' },
135 ARUI_TEMPLATE,
136 process.env.NODE_ENV === 'production' ? ARUI_PROD_TEMPLATE : ARUI_DEV_TEMPLATE
137);
138```
139
140Использование в typescript проектах
141-----------------------------------
142
143#### Конфигурация tslint
144Вы можете унаследовать конфигурацию вашего tslint от `arui-presets/tslint`.
145```json
146{
147 "extends": "arui-presets/tslint"
148}
149```
150
151Использование в package.json вашего проекта
152```
153"lint-ts": "tslint -c tslint.json --project ./tsconfig.json --type-check src/**/*.ts"
154```
155
156Лицензия
157--------
158
159```
160The MIT License (MIT)
161
162Copyright (c) 2017 Alfa Laboratory
163
164Permission is hereby granted, free of charge, to any person obtaining a copy
165of this software and associated documentation files (the "Software"), to deal
166in the Software without restriction, including without limitation the rights
167to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
168copies of the Software, and to permit persons to whom the Software is
169furnished to do so, subject to the following conditions:
170
171The above copyright notice and this permission notice shall be included in
172all copies or substantial portions of the Software.
173
174THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
175IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
176FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
177AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
178LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
179OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
180THE SOFTWARE.
181```