Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: v4 changes #258

Merged
merged 20 commits into from
Feb 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions .babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@
}
],
"@babel/preset-typescript",
"@babel/preset-react"
[
"@babel/preset-react",
{
"runtime": "automatic"
}
]
],
"plugins": []
}
}
12 changes: 7 additions & 5 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,27 @@
"extends": [
"@gravity-ui/eslint-config",
"@gravity-ui/eslint-config/client",
"@gravity-ui/eslint-config/import-order",
"@gravity-ui/eslint-config/prettier",
"@gravity-ui/eslint-config/a11y"
"@gravity-ui/eslint-config/import-order",
"@gravity-ui/eslint-config/a11y",
"plugin:react/jsx-runtime"
],
"root": true,
"rules": {
"react/jsx-fragments": ["error", "element"],
"no-restricted-syntax": [
"error",
{
"selector": "ImportDeclaration[source.value='react'] :matches(ImportNamespaceSpecifier, ImportSpecifier)",
"message": "Please use import React from 'react' instead."
"selector": "ImportDeclaration[source.value='react'] :matches(ImportDefaultSpecifier, ImportSpecifier)",
"message": "Please use `import * as React from 'react'` instead."
},
{
"selector": "TSTypeReference>TSQualifiedName[left.name='React'][right.name='FC']",
"message": "Don't use React.FC"
}
],
"jsx-a11y/no-autofocus": 0
"jsx-a11y/no-autofocus": 0,
"import/no-extraneous-dependencies": 0
},
"overrides": [
{
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- name: Setup Node
uses: actions/setup-node@v2
with:
node-version: 18
node-version: 20
cache: npm
- name: Install Packages
run: npm ci
Expand All @@ -38,7 +38,7 @@ jobs:
- name: Setup Node
uses: actions/setup-node@v2
with:
node-version: 18
node-version: 20
cache: npm
- name: Install Packages
run: npm ci
Expand All @@ -54,7 +54,7 @@ jobs:
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 18
node-version: 20
cache: npm
- name: Install Packages
run: npm ci
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/main-preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Setup Node
uses: actions/setup-node@v2
with:
node-version: 18
node-version: 20
- name: Install Packages
run: npm ci
shell: bash
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pr-preview-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ jobs:
steps:
- uses: gravity-ui/preview-build-action@v1
with:
node-version: 18
node-version: 20
2 changes: 1 addition & 1 deletion .github/workflows/release-beta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 18
node-version: 20
registry-url: 'https://registry.npmjs.org'
- run: npm ci
shell: bash
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ jobs:
with:
github-token: ${{ secrets.GRAVITY_UI_BOT_GITHUB_TOKEN }}
npm-token: ${{ secrets.GRAVITY_UI_BOT_NPM_TOKEN }}
node-version: 18
node-version: 20
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
18
20
2 changes: 1 addition & 1 deletion .storybook/decorators/withLang.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import * as React from 'react';

import {settings} from '@gravity-ui/date-utils';
import {configure} from '@gravity-ui/uikit';
Expand Down
2 changes: 0 additions & 2 deletions .storybook/decorators/withMobile.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import React from 'react';

import {MobileProvider} from '@gravity-ui/uikit';
import type {Decorator} from '@storybook/react';

Expand Down
2 changes: 1 addition & 1 deletion .storybook/decorators/withStrictMode.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import * as React from 'react';

import type {Decorator} from '@storybook/react';

Expand Down
2 changes: 0 additions & 2 deletions .storybook/decorators/withTheme.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import React from 'react';

import {ThemeProvider} from '@gravity-ui/uikit';
import type {Decorator} from '@storybook/react';

Expand Down
64 changes: 0 additions & 64 deletions .storybook/docs.tsx

This file was deleted.

22 changes: 14 additions & 8 deletions .storybook/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,29 @@
const {join} = require('path');

const config: StorybookConfig = {
framework: {
name: '@storybook/react-webpack5',
options: {},
},

framework: '@storybook/react-webpack5',
stories: ['../src/**/*.stories.@(ts|tsx)'],

addons: [
'@storybook/preset-scss',
{
name: '@storybook/addon-styling-webpack',
options: {
rules: [
{
test: /\.s?css$/i,
use: ['style-loader', 'css-loader', 'sass-loader'],
},
],
},
},
{name: '@storybook/addon-essentials', options: {backgrounds: false}},
'./theme-addon/register.tsx',
'@storybook/addon-webpack5-compiler-babel',
'@storybook/addon-a11y',
'@storybook/addon-webpack5-compiler-babel',
],

webpackFinal: (storybookBaseConfig) => {
storybookBaseConfig?.module?.rules.push({
storybookBaseConfig?.module?.rules?.push({
test: /\.md$/,
include: [join(__dirname, '../src')],
use: [{loader: 'markdown-loader'}],
Expand All @@ -27,7 +33,7 @@

// to turn fileName in context.parameters into path form number in production bundle
if (storybookBaseConfig?.optimization) {
storybookBaseConfig.optimization.moduleIds = 'named';

Check warning on line 36 in .storybook/main.ts

View workflow job for this annotation

GitHub Actions / Verify Files

Assignment to property of function parameter 'storybookBaseConfig'

Check warning on line 36 in .storybook/main.ts

View workflow job for this annotation

GitHub Actions / Verify Files

Assignment to property of function parameter 'storybookBaseConfig'
}

return storybookBaseConfig;
Expand Down
4 changes: 0 additions & 4 deletions .storybook/preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,10 @@ import {withLang} from './decorators/withLang';
import {withMobile} from './decorators/withMobile';
import {withStrictMode} from './decorators/withStrictMode';
import {withTheme} from './decorators/withTheme';
import {Docs} from './docs';

const preview: Preview = {
decorators: [withLang, withMobile, withTheme, withStrictMode],
parameters: {
docs: {
page: Docs,
},
jsx: {showFunctions: true},
viewport: {
viewports: MINIMAL_VIEWPORTS,
Expand Down
2 changes: 1 addition & 1 deletion .storybook/theme-addon/register.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import * as React from 'react';

import {getThemeType} from '@gravity-ui/uikit';
import {type API, addons, types, useGlobals} from '@storybook/manager-api';
Expand All @@ -22,6 +22,6 @@
const [{theme}] = useGlobals();
React.useEffect(() => {
api.setOptions({theme: themes[getThemeType(theme)]});
}, [theme]);

Check warning on line 25 in .storybook/theme-addon/register.tsx

View workflow job for this annotation

GitHub Actions / Verify Files

React Hook React.useEffect has a missing dependency: 'api'. Either include it or remove the dependency array

Check warning on line 25 in .storybook/theme-addon/register.tsx

View workflow job for this annotation

GitHub Actions / Verify Files

React Hook React.useEffect has a missing dependency: 'api'. Either include it or remove the dependency array
return null;
}
70 changes: 49 additions & 21 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -1,36 +1,64 @@
/* eslint-env node */
const path = require('path');

const utils = require('@gravity-ui/gulp-utils');
const {task, src, dest, series, parallel} = require('gulp');
const sass = require('gulp-dart-sass');
const replace = require('gulp-replace');
const ts = require('gulp-typescript');
const sass = require('gulp-sass')(require('sass'));
const sourcemaps = require('gulp-sourcemaps');
const {rimrafSync} = require('rimraf');

const BUILD_DIR = path.resolve('build');

task('clean', (done) => {
rimrafSync(BUILD_DIR);
rimrafSync('styles/**/*.css');
rimrafSync('styles/**/*.css', {glob: true});
done();
});

function compileTs(modules = false) {
const tsProject = ts.createProject('tsconfig.json', {
declaration: true,
module: modules ? 'esnext' : 'commonjs',
async function compileTs(modules = false) {
const tsProject = await utils.createTypescriptProject({
compilerOptions: {
declaration: true,
module: modules ? 'esnext' : 'nodenext',
moduleResolution: modules ? 'bundler' : 'nodenext',
...(modules ? undefined : {verbatimModuleSyntax: false}),
},
});

return src([
'src/**/*.{ts,tsx}',
'!src/demo/**/*',
'!src/stories/**/*',
'!src/**/__stories__/**/*',
'!src/**/__tests__/**/*',
])
.pipe(replace(/(import.+)\.scss/g, '$1.css'))
.pipe(tsProject())
.pipe(dest(path.resolve(BUILD_DIR, modules ? 'esm' : 'cjs')));
const transformers = [
tsProject.customTransformers.transformScssImports,
tsProject.customTransformers.transformLocalModules,
];
return new Promise((resolve) => {
src([
'src/**/*.{ts,tsx}',
'!src/demo/**/*',
'!src/stories/**/*',
'!src/**/__stories__/**/*',
'!src/**/__tests__/**/*',
'!src/**/__mocks__/**/*',
'!src/**/*.test.{ts,tsx}',
'!src/**/__snapshots__/**/*',
])
.pipe(sourcemaps.init())
.pipe(
tsProject({
customTransformers: {
before: transformers,
afterDeclarations: transformers,
},
}),
)
.pipe(sourcemaps.write('.', {includeContent: true, sourceRoot: '../../src'}))
.pipe(
utils.addVirtualFile({
fileName: 'package.json',
text: JSON.stringify({type: modules ? 'module' : 'commonjs'}),
}),
)
.pipe(dest(path.resolve(BUILD_DIR, modules ? 'esm' : 'cjs')))
.on('end', resolve);
});
}

task('compile-to-esm', () => {
Expand All @@ -50,11 +78,11 @@ task('copy-i18n', () => {
task('styles-components', () => {
return src(['src/components/**/*.scss', '!src/components/**/__stories__/**/*'])
.pipe(
sass({
includePaths: ['node_modules'],
sass.sync({loadPaths: ['node_modules']}).on('error', function (error) {
sass.logError.call(this, error);
process.exit(1);
}),
)
.pipe(sass().on('error', sass.logError))
.pipe(dest(path.resolve(BUILD_DIR, 'esm', 'components')))
.pipe(dest(path.resolve(BUILD_DIR, 'cjs', 'components')));
});
Expand Down
1 change: 0 additions & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ module.exports = {
transform: {
'\\.[jt]sx?$': ['ts-jest', {tsconfig: './tsconfig.test.json'}],
},
transformIgnorePatterns: ['node_modules/(?!(@gravity-ui|tinygesture))'],
coverageDirectory: './coverage',
collectCoverageFrom: ['src/**/*.{ts,tsx}', '!**/__stories__/**/*', '!**/*/*.stories.{ts,tsx}'],
testEnvironment: 'jsdom',
Expand Down
Loading
Loading