Skip to content

Commit

Permalink
Upgrade packages. Use node 12+ (#75)
Browse files Browse the repository at this point in the history
  • Loading branch information
goliney authored Jan 9, 2022
1 parent f21d2d7 commit 84a4b2a
Show file tree
Hide file tree
Showing 12 changed files with 810 additions and 618 deletions.
48 changes: 8 additions & 40 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,49 +1,17 @@
module.exports = {
extends: [
'airbnb-typescript',
'plugin:@typescript-eslint/recommended', // Uses the recommended rules from the @typescript-eslint/eslint-plugin
'prettier/react',
'prettier/@typescript-eslint', // Uses eslint-config-prettier to disable ESLint rules from @typescript-eslint/eslint-plugin that would conflict with prettier
'plugin:prettier/recommended', // Enables eslint-plugin-prettier and displays prettier errors as ESLint errors. Make sure this is always the last configuration in the extends array.
],
root: true,
env: {
node: true,
jest: true,
},
plugins: ['react-hooks'],
parser: '@typescript-eslint/parser',
parserOptions: {
project: './tsconfig.eslint.json',
},
plugins: ['react-hooks', '@typescript-eslint'],
extends: ['plugin:@typescript-eslint/recommended', 'prettier'],
rules: {
// Too restrictive, writing ugly code to defend against a very unlikely scenario: https://eslint.org/docs/rules/no-prototype-builtins
'no-prototype-builtins': 'off',
// https://basarat.gitbooks.io/typescript/docs/tips/defaultIsBad.html
'import/prefer-default-export': 'off',
'import/no-default-export': 'error',
// Too restrictive: https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/destructuring-assignment.md
'react/destructuring-assignment': 'off',
// No jsx extension: https://github.com/facebook/create-react-app/issues/87#issuecomment-234627904
'react/jsx-filename-extension': 'off',
// Use function hoisting to improve code readability
'no-use-before-define': ['error', { functions: false, classes: true, variables: true }],
'@typescript-eslint/no-use-before-define': [
'error',
{ functions: false, classes: true, variables: true, typedefs: true },
],
// If we can delete it - we should delete it: https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-unused-vars.md
'@typescript-eslint/no-unused-vars': 'error',
//Too restrictive: https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/explicit-function-return-type.md
'@typescript-eslint/explicit-function-return-type': 'off',
// The Rules of Hooks: https://reactjs.org/docs/hooks-rules.html
'react-hooks/rules-of-hooks': 'error',
'react-hooks/exhaustive-deps': 'warn',
// https://github.com/typescript-eslint/typescript-eslint/issues/420
'no-useless-constructor': 'off',
'@typescript-eslint/no-useless-constructor': 'error',
// We use any and warnings are becoming distracting
'@typescript-eslint/no-explicit-any': 'off',
// We use underscore dangle, especially in tests
'no-underscore-dangle': 'off',
// let useEffect return either nothing or a callback
'consistent-return': 'off',
// we use typescript, so no default props
'react/require-default-props': 'off',
'@typescript-eslint/no-var-requires': 'off',
},
};
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:

strategy:
matrix:
node-version: [10.x, 16.x]
node-version: [12.x, 16.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

steps:
Expand Down
4 changes: 2 additions & 2 deletions dist/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ Object.defineProperty(exports, "__esModule", {
});
exports.app = void 0;

var _ink = require("ink");

var _react = _interopRequireDefault(require("react"));

var _ink = require("ink");

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

const app = (0, _ink.render)( /*#__PURE__*/_react.default.createElement(_ink.Text, null, "Initializing..."), {
Expand Down
3 changes: 0 additions & 3 deletions dist/bin/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,10 @@ if (program.config) {
const CONFIG_FILEPATH = _path.default.join(cwd, program.config);

if (_fs.default.existsSync(CONFIG_FILEPATH)) {
/* eslint-disable @typescript-eslint/no-var-requires,global-require,import/no-dynamic-require */
const _require = require('./runner'),
runner = _require.runner;

const garsonConfig = require(CONFIG_FILEPATH);
/* eslint-enable @typescript-eslint/no-var-requires,global-require,import/no-dynamic-require */


runner(garsonConfig);
} else {
Expand Down
4 changes: 3 additions & 1 deletion dist/prompts/multi-choices/use-multi-choices-navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ function _iterableToArrayLimit(arr, i) { var _i = arr && (typeof Symbol !== "und

function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }

function useMultiChoicesNavigation(items, onChangeMiddleware = () => {}) {
function useMultiChoicesNavigation(items, onChangeMiddleware = () => {
return;
}) {
const _useState = (0, _react.useState)(items[0]),
_useState2 = _slicedToArray(_useState, 2),
highlightedItem = _useState2[0],
Expand Down
35 changes: 17 additions & 18 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "garson",
"version": "1.0.1",
"version": "2.0.0",
"main": "dist/index.js",
"bin": "dist/bin/index.js",
"files": [
Expand Down Expand Up @@ -39,28 +39,27 @@
"@types/node": "^14.0.27",
"@types/react": "^16.8.23",
"@types/react-dom": "^16.8.4",
"@typescript-eslint/eslint-plugin": "^1.12.0",
"eslint": "^6.8.0",
"eslint-config-airbnb": "^17.1.1",
"eslint-config-airbnb-typescript": "^4.0.1",
"eslint-config-prettier": "^6.0.0",
"eslint-plugin-import": "^2.18.2",
"eslint-plugin-jsx-a11y": "^6.2.3",
"eslint-plugin-prettier": "^3.1.0",
"eslint-plugin-react": "^7.14.2",
"eslint-plugin-react-hooks": "^1.6.1",
"ink-testing-library": "^2.0.1",
"@typescript-eslint/eslint-plugin": "^5.9.0",
"@typescript-eslint/parser": "^5.9.0",
"eslint": "^8.6.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-import": "^2.25.4",
"eslint-plugin-jsx-a11y": "^6.5.1",
"eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-react": "^7.28.0",
"eslint-plugin-react-hooks": "^4.3.0",
"ink-testing-library": "^2.1.0",
"jest": "^25.1.0",
"prettier": "^1.18.2",
"typescript": "^3.8.3"
"prettier": "^2.5.1",
"typescript": "^4.5.4"
},
"dependencies": {
"commander": "^5.0.0",
"core-js": "^3.6.4",
"core-js": "^3.20.2",
"figures": "^3.2.0",
"glob": "^7.1.6",
"ink": "^3.0.8",
"ink-text-input": "^4.0.0",
"glob": "^7.2.0",
"ink": "^3.2.0",
"ink-text-input": "^4.0.2",
"react": ">=16.8.0",
"vscode-fuzzy-scorer": "^0.0.4"
}
Expand Down
1 change: 0 additions & 1 deletion src/@types/fz-search/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// TypeScript Version: 3.5.3

declare module 'fz-search' {
// eslint-disable-next-line import/no-default-export
export default class FuzzySearch<T> {
public constructor(options: FuzzySearchOptions<T>);

Expand Down
2 changes: 1 addition & 1 deletion src/app.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Text, render } from 'ink';
import React from 'react';
import { Text, render } from 'ink';

export const app = render(<Text>Initializing...</Text>, {
debug: false,
Expand Down
2 changes: 0 additions & 2 deletions src/bin/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,8 @@ if (program.config) {
const CONFIG_FILEPATH = path.join(cwd, program.config);

if (fs.existsSync(CONFIG_FILEPATH)) {
/* eslint-disable @typescript-eslint/no-var-requires,global-require,import/no-dynamic-require */
const { runner } = require('./runner');
const garsonConfig = require(CONFIG_FILEPATH);
/* eslint-enable @typescript-eslint/no-var-requires,global-require,import/no-dynamic-require */
runner(garsonConfig);
} else {
throw new Error(`Config file was not found: ${CONFIG_FILEPATH}`);
Expand Down
12 changes: 7 additions & 5 deletions src/prompts/multi-choices/use-multi-choices-navigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,16 @@ import { MultiChoiceOption } from './components/item';

export function useMultiChoicesNavigation(
items: MultiChoiceOption[],
onChangeMiddleware: onChoiceChangeMiddlewareCallback<MultiChoiceOption> = () => {}
onChangeMiddleware: onChoiceChangeMiddlewareCallback<MultiChoiceOption> = () => {
return;
}
) {
const [highlightedItem, setHighlightedItem] = useState(items[0]);
const [selectedItems, setSelectedItems] = useState<MultiChoiceOption[]>([]);

// pre-select default items
useEffect(() => {
setSelectedItems(items.filter(item => item.isSelected));
setSelectedItems(items.filter((item) => item.isSelected));
}, [items]);

const highlightPrevItem = useCallback(() => {
Expand All @@ -35,8 +37,8 @@ export function useMultiChoicesNavigation(
}, [highlightedItem, items]);

const toggleSelection = useCallback(() => {
const oldSelectedItems = items.filter(item => selectedItems.includes(item));
const newSelectedItems = items.filter(item => {
const oldSelectedItems = items.filter((item) => selectedItems.includes(item));
const newSelectedItems = items.filter((item) => {
const isAlreadySelected = selectedItems.includes(item);
const isHighlighted = item === highlightedItem;
return (isAlreadySelected && !isHighlighted) || (!isAlreadySelected && isHighlighted);
Expand All @@ -46,7 +48,7 @@ export function useMultiChoicesNavigation(
}, [highlightedItem, selectedItems, items, onChangeMiddleware]);

const handleKey = useCallback(
key => {
(key) => {
switch (key) {
case ARROW_UP:
highlightPrevItem();
Expand Down
13 changes: 13 additions & 0 deletions tsconfig.eslint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"extends": "./tsconfig.json",
"include": [
".eslintrc.js",
"**/*.js",
"**/*.jsx",
"**/*.ts",
"**/*.tsx"
],
"exclude": [
// do not exclude anything that we want to lint
]
}
Loading

0 comments on commit 84a4b2a

Please sign in to comment.