Skip to content

Commit

Permalink
Merge a93e826 into bd96c70
Browse files Browse the repository at this point in the history
  • Loading branch information
williaster committed Dec 19, 2022
2 parents bd96c70 + a93e826 commit befbe42
Show file tree
Hide file tree
Showing 99 changed files with 4,298 additions and 2,370 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
82 changes: 82 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
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: {
'@typescript-eslint/no-explicit-any': [
'warn',
{
fixToUnknown: false,
},
],
'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',
},
},
],
};
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
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,
};
97 changes: 97 additions & 0 deletions config-eslint/base.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
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 = {
root: true,

parser: 'babel-eslint',

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',
},
},
],
};

0 comments on commit befbe42

Please sign in to comment.