Skip to content

Commit

Permalink
internal: migrate off nimbus (#1609)
Browse files Browse the repository at this point in the history
* internal(dev/babel): migrate off nimbus

* internal(dev/prettier): migrate off nimbus

* internal(dev/prettier): add more ignore patterns

* internal(dev/eslint): migrate off nimbus

* internal(dev/typescript): remove nimbus deps, config, gitignore

* internal(dev/typescript): commit all tsconfigs

* internal(dev/jest): remove nimbus deps, add jest deps, update gitignore

* internal(dev/eslint): eslint-presets/* => config-eslint/*

* internal(dev/jest): add jest.config.js + setup files

* internal(dev/types): add and run scripts/updateTsReferences

* fix(demo): fix tsconfig

* internal(dev/type): remove verbose in type script

* internal(dev/jest): add mocks, fix enzyme setup, fix script

* deps: remove nimbus

* yarn lint --fix

* fix(dev/eslint): fix babel parser

* fix(lint): batch of manual fixes

* fix(lint): another batch of manual fixes

* fix(lint): another batch of manual fixes

* fix: run prettier

* fix(axis): fix Orientation type

* fix(xychart): fix event types

* dev(CONTRIBUTING): update single-package build + type scripts

* fix(xychart): more event type fixes

* fix(demo): happo/* => src/happo/*

* fix(zoom): return ReactElement not ReactNode

* fix(lint): try to fix parser

* fix(lint): try to fix parser

* fix: bump required node version to >16.10.0

* lint(demo/happo)

* fix(demo/text): fix happo name
  • Loading branch information
williaster committed Dec 21, 2022
1 parent 0cb5b2f commit fa743a4
Show file tree
Hide file tree
Showing 377 changed files with 74,993 additions and 4,850 deletions.
10 changes: 9 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
.happo/
.next/
coverage/
node_modules/
public/
esm/
lib/
tmp/
dist/
*.d.ts
out/
*.d.ts
lerna.json
npm-shrinkwrap.json
package.json
package-lock.json
tsconfig.json
76 changes: 76 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
module.exports = {
root: true,
extends: [
// these are relics of nimbus, we could definitely simplify + consolidate
'./config-eslint/base.js',
'./config-eslint/next.js',
'./config-eslint/typescript.js',
'./config-eslint/prettier.js',
],
overrides: [
{
files: '*.test.{js,jsx,ts,tsx}',
rules: {
'import/no-extraneous-dependencies': 'off',
'jest/require-to-throw-message': 'off',
},
},
{
files: '*.{js,jsx,ts,tsx}',
rules: {
'arrow-parens': 'off',
'consistent-return': 'off',
'import/prefer-default-export': 'off',
'linebreak-style': 'off',
'lines-between-class-members': 'off',
'no-console': 'off',
'no-nested-ternary': 'off',
'no-param-reassign': 'warn',
'no-restricted-syntax': 'off',
'no-use-before-define': 'off',
'no-useless-rename': 'off',
'object-curly-newline': 'off',
'operator-linebreak': 'off',
'promise/param-names': 'off',
'react/destructuring-assignment': 'off',
'react/forbid-prop-types': 'off',
'react/jsx-curly-brace-presence': 'off',
'react/jsx-filename-extension': 'off',
'react/jsx-no-literals': 'off',
'react/jsx-props-no-spreading': 'off',
'react/jsx-sort-default-props': 'off',
'react/jsx-sort-props': 'off',
'react/no-array-index-key': 'off',
'react/no-children-prop': 'off',
'react/require-default-props': 'off',
'react/sort-comp': 'off',
'react/sort-prop-types': 'off',
'unicorn/catch-error-name': 'off',
'unicorn/no-fn-reference-in-iterator': 'off',
'unicorn/prefer-node-append': 'off',
},
},
{
files: './packages/visx-demo/**',
rules: {
'import/no-unresolved': [
'error',
{
ignore: ['^!!raw-loader!.*'],
},
],
'import/no-webpack-loader-syntax': 'off',
'jsx-a11y/anchor-is-valid': 'off',
'jsx-a11y/label-has-associated-control': 'off',
'jsx-a11y/no-onchange': 'off',
'no-alert': 'off',
'no-param-reassign': 'off',
'react/button-has-type': 'off',
'react/no-danger': 'off',
'react/no-unescaped-entities': 'off',
'react/prop-types': 'off',
'react/state-in-constructor': 'off',
},
},
],
};
2 changes: 1 addition & 1 deletion .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
- uses: actions/checkout@v2 # checkout visx + this commit
- uses: actions/setup-node@v2
with:
node-version: '12'
node-version: '16.10.0'

- name: Get yarn cache directory path
id: yarn-cache-dir-path
Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
fetch-depth: '0'
- uses: actions/setup-node@v2
with:
node-version: '12'
node-version: '16.10.0'
registry-url: 'https://registry.npmjs.org'

- name: Get yarn cache directory path
Expand Down Expand Up @@ -89,7 +89,7 @@ jobs:
git add .
git commit -m "bot(${GITHUB_SHA}): build gh-pages"
git push -f "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$GITHUB_REPOSITORY.git" HEAD:gh-pages
- name: 🦛 Run happo
# not running happo on push results in stale base shas in pull_request
run: yarn run happo-ci-github-actions
Expand All @@ -98,4 +98,3 @@ jobs:
HAPPO_API_KEY: ${{ secrets.HAPPO_API_KEY }}
HAPPO_API_SECRET: ${{ secrets.HAPPO_API_SECRET }}
HAPPO_COMMAND: '../../node_modules/happo.io/build/cli.js'

10 changes: 0 additions & 10 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,6 @@ tmp/

# Configs (provided by Nimbus)
.babelrc
.eslintignore
.eslintrc.js
.flowconfig
.prettierignore
babel.config.js
jest.config.js
prettier.config.js
tsconfig.eslint.json
tsconfig.json
tsconfig.options.json
*.tsbuildinfo
webpack.config.js

Expand Down
3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
.happo/
.next/
coverage/
node_modules/
public/
esm/
lib/
tmp/
dist/
out/
*.d.ts
lerna.json
npm-shrinkwrap.json
Expand Down
13 changes: 6 additions & 7 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,14 @@ specify multiple packages to build this way, and optionally append `--watch` to
for changes.

```sh
# build the specified package(s) as cjs version
# example `yarn build:workspaces --workspaces=@visx/shape`
yarn build:workspaces --workspaces=@visx/package[,@visx/package,...]

# build the esm version (the @visx/demo next server sources these files)
yarn build:workspaces --workspaces=@visx/package[,@visx/package,...] --esm
# build the specified package(s) as cjs + esm versions
# example `PKG=@visx/axis yarn babel:pkg`
PKG=@visx/{package[,package]} yarn babel:pkg

# generate d.ts(definition files) the specified package(s)
yarn type:workspaces --workspaces=@visx/package[,@visx/package,...]
# and rebuild any other packages the specified package(s) depend on
# example `PKG=@visx/axis yarn type:pkg`
PKG=@visx/{package[,package]} yarn type:pkg
```

from the `visx` monorepo root to re-build the package with your changes.
Expand Down
53 changes: 53 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
const esm = process.env.ESM;

const envOptions = {
loose: true,
modules: esm ? false : 'commonjs',
shippedProposals: true,
targets: {
ie: 11,
},
bugfixes: false,
};

const presets = [
['@babel/preset-env', envOptions],
'@babel/preset-react',
'@babel/preset-typescript',
];

const plugins = ['babel-plugin-typescript-to-proptypes'];

const ignore = [
'coverage/',
'node_modules/',
'public/',
'esm/',
'lib/',
'tmp/',
'dist/',
'*.d.ts',
'__tests__',
'__mocks__',
];

switch (process.env.NODE_ENV) {
case 'test': {
envOptions.modules = 'commonjs';
envOptions.targets = { node: 'current' };
plugins.push('babel-plugin-dynamic-import-node');
break;
}

case 'development':
case 'production':
default: {
break;
}
}

module.exports = {
ignore,
plugins,
presets,
};
95 changes: 95 additions & 0 deletions config-eslint/base.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
const EXTS = ['.ts', '.tsx', '.js', '.jsx', '.json'];
const EXTS_GROUP = '{ts,tsx,js,jsx}';
const ASSET_EXT_PATTERN = /\.(ttf|eot|otf|svg|woff|woff2|mp3|png|jpg|jpeg|gif|ico)$/;

module.exports = {
parser: '@babel/eslint-parser',

parserOptions: {
requireConfigFile: false,
},

extends: ['airbnb', 'plugin:jsx-a11y/recommended'],

plugins: ['import', 'react', 'react-hooks'],

globals: {
// Metrics and analytics providers
ga: 'readonly',
// Mostly for easier compatibility between browsers, workers, etc
global: 'readonly',
// Mostly references to `process.env.NODE_ENV`
process: 'readonly',
},

env: {
browser: true,
node: false,
},

reportUnusedDisableDirectives: true,

settings: {
propWrapperFunctions: ['forbidExtraProps', 'exact', 'Object.freeze'],
'import/ignore': ['node_modules', '\\.json$', ASSET_EXT_PATTERN.source],
'import/extensions': EXTS,
'import/resolver': {
node: {
extensions: EXTS,
},
},
},

rules: {
'react-hooks/exhaustive-deps': 'error',
'react-hooks/rules-of-hooks': 'error',
},

overrides: [
{
files: [`*.test.${EXTS_GROUP}`],
plugins: ['jest'],
globals: {
jsdom: 'readonly',
},
env: {
jest: true,
node: true,
},
rules: {
'max-classes-per-file': 'off',
'no-magic-numbers': 'off',
'sort-keys': 'off',

// JEST
'jest/expect-expect': 'error',
'jest/no-alias-methods': 'error',
'jest/no-done-callback': 'error',
'jest/no-disabled-tests': 'error',
'jest/no-duplicate-hooks': 'error',
'jest/no-export': 'error',
'jest/no-focused-tests': 'error',
'jest/no-identical-title': 'error',
'jest/no-if': 'error',
'jest/no-jasmine-globals': 'error',
'jest/no-standalone-expect': 'error',
'jest/no-test-prefixes': 'error',
'jest/no-test-return-statement': 'error',
'jest/prefer-hooks-on-top': 'error',
'jest/prefer-spy-on': 'error',
'jest/prefer-todo': 'error',
'jest/prefer-to-be': 'error',
'jest/prefer-to-contain': 'error',
'jest/prefer-to-have-length': 'error',
'jest/require-to-throw-message': 'error',
'jest/require-top-level-describe': 'error',
'jest/valid-describe-callback': 'error',
'jest/valid-expect': 'error',
'jest/valid-title': 'error',

// REACT
'react/function-component-definition': 'off',
},
},
],
};
Loading

0 comments on commit fa743a4

Please sign in to comment.