Compare commits
5 Commits
@advdomini
...
@advdomini
| Author | SHA1 | Date | |
|---|---|---|---|
|
e1756bd60f
|
|||
|
ea33198344
|
|||
|
ca88f622d1
|
|||
|
9131e220d2
|
|||
|
4012b982a6
|
@@ -8,13 +8,13 @@
|
||||
|
||||
## Публикация новых версий
|
||||
|
||||
```
|
||||
```bash
|
||||
yarn lerna publish
|
||||
```
|
||||
|
||||
## Обновление зависимостей
|
||||
|
||||
```shell
|
||||
```bash
|
||||
yarn set version stable
|
||||
|
||||
yarn install
|
||||
|
||||
@@ -1,129 +1,25 @@
|
||||
/* eslint-disable unicorn/no-useless-spread */
|
||||
import nunjucks from 'nunjucks';
|
||||
|
||||
import js from '@eslint/js';
|
||||
import eslintConfigPrettier from 'eslint-config-prettier';
|
||||
import simpleImportSort from 'eslint-plugin-simple-import-sort';
|
||||
import eslintPluginUnicorn from 'eslint-plugin-unicorn';
|
||||
import pluginVue from 'eslint-plugin-vue';
|
||||
import globals from 'globals';
|
||||
const babelPluginNunjucks = ({types: t}) => {
|
||||
return {
|
||||
pre(state) {
|
||||
const options = state.opts.plugins[0].options;
|
||||
this.njkenv = new nunjucks.Environment(new nunjucks.FileSystemLoader(options.templatesFolder));
|
||||
if (options.globals) {
|
||||
for (const {name, value} of options.globals) {
|
||||
this.njkenv.addGlobal(name, value);
|
||||
}
|
||||
}
|
||||
},
|
||||
visitor: {
|
||||
TaggedTemplateExpression(path) {
|
||||
if (path.get('tag').isIdentifier({name: 'njk'})) {
|
||||
const render = this.njkenv.renderString(path.node.quasi.quasis[0].value.raw);
|
||||
path.replaceWith(t.stringLiteral(render));
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
const config = [
|
||||
{
|
||||
languageOptions: {
|
||||
ecmaVersion: 'latest',
|
||||
sourceType: 'module',
|
||||
globals: {
|
||||
...globals.browser,
|
||||
...globals.nodeBuiltin,
|
||||
},
|
||||
},
|
||||
},
|
||||
js.configs.recommended,
|
||||
{
|
||||
rules: {
|
||||
...{
|
||||
'array-callback-return': 'error',
|
||||
'no-await-in-loop': 'warn',
|
||||
'no-duplicate-imports': 'warn',
|
||||
'no-promise-executor-return': 'error',
|
||||
'no-self-compare': 'error',
|
||||
'no-template-curly-in-string': 'warn',
|
||||
'no-unassigned-vars': 'warn',
|
||||
'no-unmodified-loop-condition': 'error',
|
||||
'no-unreachable-loop': 'error',
|
||||
'no-use-before-define': 'error',
|
||||
'no-useless-assignment': 'warn',
|
||||
},
|
||||
...{
|
||||
'dot-notation': 'warn',
|
||||
'eqeqeq': 'error',
|
||||
'no-implicit-coercion': 'warn',
|
||||
'no-negated-condition': 'warn',
|
||||
'no-useless-concat': 'warn',
|
||||
'object-shorthand': 'warn',
|
||||
'func-style': 'error',
|
||||
'no-console': ['warn', { allow: ['warn', 'error'] }],
|
||||
'no-param-reassign': 'error',
|
||||
'no-var': 'error',
|
||||
'one-var': ['warn', 'never'],
|
||||
'prefer-const': 'warn',
|
||||
'prefer-template': 'warn',
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
plugins: {
|
||||
'simple-import-sort': simpleImportSort,
|
||||
},
|
||||
rules: {
|
||||
'simple-import-sort/imports': 'warn',
|
||||
},
|
||||
},
|
||||
{
|
||||
plugins: {
|
||||
unicorn: eslintPluginUnicorn,
|
||||
},
|
||||
rules: {
|
||||
...Object.fromEntries(
|
||||
Object.entries(eslintPluginUnicorn.configs.recommended.rules).map(([rule, level]) => [
|
||||
rule,
|
||||
level === 'off' ? 'off' : 'warn',
|
||||
]),
|
||||
),
|
||||
'unicorn/better-regex': 'warn',
|
||||
'unicorn/filename-case': ['warn', { cases: { kebabCase: true, pascalCase: true } }],
|
||||
'unicorn/prefer-global-this': 'off',
|
||||
'unicorn/prefer-import-meta-properties': 'warn',
|
||||
'unicorn/prefer-top-level-await': 'off',
|
||||
'unicorn/prevent-abbreviations': 'off',
|
||||
},
|
||||
},
|
||||
...pluginVue.configs['flat/recommended'],
|
||||
{
|
||||
rules: {
|
||||
...{
|
||||
'vue/no-v-html': 'off',
|
||||
'vue/one-component-per-file': 'off',
|
||||
},
|
||||
...{
|
||||
'vue/component-name-in-template-casing': 'warn',
|
||||
'vue/component-options-name-casing': 'warn',
|
||||
'vue/custom-event-name-casing': 'warn',
|
||||
'vue/match-component-file-name': ['warn', { extensions: ['vue'], shouldMatchCase: true }],
|
||||
'vue/match-component-import-name': 'warn',
|
||||
'vue/no-boolean-default': 'warn',
|
||||
'vue/no-potential-component-option-typo': 'warn',
|
||||
'vue/no-useless-mustaches': 'warn',
|
||||
'vue/no-useless-v-bind': 'warn',
|
||||
'vue/require-direct-export': 'warn',
|
||||
'vue/require-name-property': 'warn',
|
||||
'vue/v-for-delimiter-style': 'warn',
|
||||
'vue/v-on-handler-style': ['warn', 'inline'],
|
||||
},
|
||||
...{
|
||||
'vue/dot-notation': 'warn',
|
||||
'vue/eqeqeq': 'error',
|
||||
'vue/no-console': ['warn', { allow: ['warn', 'error'] }],
|
||||
'vue/no-constant-condition': 'error',
|
||||
'vue/no-empty-pattern': 'error',
|
||||
'vue/no-implicit-coercion': 'warn',
|
||||
'vue/no-irregular-whitespace': 'error',
|
||||
'vue/no-loss-of-precision': 'error',
|
||||
'vue/no-negated-condition': 'warn',
|
||||
'vue/no-sparse-arrays': 'error',
|
||||
'vue/no-useless-concat': 'warn',
|
||||
'vue/object-shorthand': 'warn',
|
||||
'vue/prefer-template': 'warn',
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
files: ['**/*.vue'],
|
||||
rules: {
|
||||
'no-useless-assignment': 'off', // ESLint не умеет работать с этим правилом внутри <template>
|
||||
},
|
||||
},
|
||||
eslintConfigPrettier,
|
||||
];
|
||||
|
||||
export default config;
|
||||
export default babelPluginNunjucks;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@advdominion/babel-plugin-nunjucks",
|
||||
"version": "3.0.1",
|
||||
"version": "3.0.2",
|
||||
"type": "module",
|
||||
"main": "index.js",
|
||||
"repository": {
|
||||
|
||||
53
packages/lightningcss-loader/README.md
Normal file
53
packages/lightningcss-loader/README.md
Normal file
@@ -0,0 +1,53 @@
|
||||
# lightningcss-loader
|
||||
|
||||
[Lightning CSS](https://lightningcss.dev) loader for [Webpack](https://webpack.js.org)
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
import { transform } from 'lightningcss';
|
||||
|
||||
return {
|
||||
...,
|
||||
rules: [
|
||||
{
|
||||
test: /\.css$/,
|
||||
use: [
|
||||
{
|
||||
loader: '@advdominion/lightningcss-loader',
|
||||
options: {
|
||||
implementation: transform,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
};
|
||||
```
|
||||
|
||||
### Passing options to Lightning CSS
|
||||
|
||||
```js
|
||||
import { transform } from 'lightningcss';
|
||||
|
||||
return {
|
||||
...,
|
||||
rules: [
|
||||
{
|
||||
test: /\.css$/,
|
||||
use: [
|
||||
{
|
||||
loader: '@advdominion/lightningcss-loader',
|
||||
options: {
|
||||
implementation: transform,
|
||||
drafts: {
|
||||
customMedia: true,
|
||||
},
|
||||
minify: false,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
};
|
||||
```
|
||||
22
packages/lightningcss-loader/index.js
Normal file
22
packages/lightningcss-loader/index.js
Normal file
@@ -0,0 +1,22 @@
|
||||
const lightningcssLoader = (source, sourceMap) => {
|
||||
const { implementation, ...options } = this.getOptions();
|
||||
const callback = this.async();
|
||||
|
||||
if (typeof implementation !== 'function') {
|
||||
throw new TypeError(
|
||||
`[lightningcss-loader]: The "implementation" option is required and must provide "transform" function of the LightningCSS`,
|
||||
);
|
||||
}
|
||||
|
||||
const { code, map } = implementation({
|
||||
filename: this.resourcePath,
|
||||
code: Buffer.from(source),
|
||||
sourceMap: this.sourceMap,
|
||||
inputSourceMap: this.sourceMap && sourceMap ? JSON.stringify(sourceMap) : undefined,
|
||||
...options,
|
||||
});
|
||||
|
||||
callback(undefined, code.toString(), map && JSON.parse(map.toString()));
|
||||
}
|
||||
|
||||
export default lightningcssLoader;
|
||||
14
packages/lightningcss-loader/package.json
Normal file
14
packages/lightningcss-loader/package.json
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"name": "@advdominion/lightningcss-loader",
|
||||
"version": "1.0.1",
|
||||
"type": "module",
|
||||
"main": "index.js",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://gitea.optiweb.ru/public/frontend.git"
|
||||
},
|
||||
"license": "MIT",
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
}
|
||||
}
|
||||
@@ -43,6 +43,12 @@ __metadata:
|
||||
languageName: unknown
|
||||
linkType: soft
|
||||
|
||||
"@advdominion/lightningcss-loader@workspace:packages/lightningcss-loader":
|
||||
version: 0.0.0-use.local
|
||||
resolution: "@advdominion/lightningcss-loader@workspace:packages/lightningcss-loader"
|
||||
languageName: unknown
|
||||
linkType: soft
|
||||
|
||||
"@advdominion/pluralize@workspace:packages/pluralize":
|
||||
version: 0.0.0-use.local
|
||||
resolution: "@advdominion/pluralize@workspace:packages/pluralize"
|
||||
|
||||
Reference in New Issue
Block a user