1 | Alfa 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 | ```
|
28 | npm install arui-presets --save-dev
|
29 | ```
|
30 |
|
31 | Или, если вы используете yarn:
|
32 | ```
|
33 | yarn add arui-presets --dev
|
34 | ```
|
35 |
|
36 | Использование линтеров
|
37 | ----------------------
|
38 |
|
39 | #### commitlint
|
40 | Вы можете унаследовать конфигурацию вашего commitlint от `arui-presets/commitlint`.
|
41 |
|
42 |
|
43 | Файл `commitlint.config.js` вашего проекта:
|
44 | ```js
|
45 | module.exports = {
|
46 | extends: ['arui-presets/commitlint']
|
47 | };
|
48 | ```
|
49 |
|
50 |
|
51 | #### eslint
|
52 | Вы можете унаследовать конфигурацию вашего eslint от `arui-presets/eslint`.
|
53 |
|
54 |
|
55 | Файл `.eslintrc.js` вашего проекта:
|
56 | ```js
|
57 | module.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
|
68 | module.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
|
110 | const mq = require('arui-feather/mq/mq.json');
|
111 | const aruiConfig = require('arui-presets/postcss');
|
112 | module.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
|
128 | const ARUI_TEMPLATE = require('arui-presets/webpack.base');
|
129 | const ARUI_DEV_TEMPLATE = require('arui-presets/webpack.development');
|
130 | const ARUI_PROD_TEMPLATE = require('arui-presets/webpack.production');
|
131 | const merge = require('webpack-merge');
|
132 |
|
133 | module.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 | ```
|
160 | The MIT License (MIT)
|
161 |
|
162 | Copyright (c) 2017 Alfa Laboratory
|
163 |
|
164 | Permission is hereby granted, free of charge, to any person obtaining a copy
|
165 | of this software and associated documentation files (the "Software"), to deal
|
166 | in the Software without restriction, including without limitation the rights
|
167 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
168 | copies of the Software, and to permit persons to whom the Software is
|
169 | furnished to do so, subject to the following conditions:
|
170 |
|
171 | The above copyright notice and this permission notice shall be included in
|
172 | all copies or substantial portions of the Software.
|
173 |
|
174 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
175 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
176 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
177 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
178 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
179 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
180 | THE SOFTWARE.
|
181 | ```
|