June 2019 (version 1.26.0)
1.26.0 Update
Hi!
Welcome to the new DeepScan updates.
Please kindly go ahead with the highlights for the latest release.
Release Summary
This version includes a number of updates that we hope you've found some of them helpful.
The key highlights are:
- New rules - New rules for the Code Quality category.
- Enhanced React support - Now we support the React function component and Hooks API!
- Extended language support - Now we support the latest TypeScript 3.5!
- Analysis improvements - Inter-module analysis of dynamically imported module.
New Rules
We have enhanced our rules mainly under the Code Quality category.
Check the new rules!
- BAD_RANGE_IN_CHARACTER_CLASS - Do not use a character range from an uppercase to a lowercase in a regular expression
- DUPLICATES_IN_CHARACTER_CLASS - Do not use duplicate characters in a regular expression
- PREFER_INEQUALITY_OPERATOR - Prefer the inequality operator rather than negating the equality comparison result
- REACT_REDUX_UNUSED_OWN_PROPS_PARAM - Check the unused
ownPropsparameter of React ReduxmapStateToProps() - REACT_USELESS_FORWARD_REF - Check the unused
refparameter ofReact.forwardRef() - USELESS_CALL - Check the useless
call(). Just invoke the function directly whenthiscontext remains the same.
Enhanced React Support
React Function Component and Hooks API Support
DeepScan now supports React function component and Hooks API.
- Function components are recognized precisely by combining various usage information.
- The following rules are extended for function components and Hooks API:
- REACT_BAD_API_RETURN_VALUE: Check the return value of a function component
- REACT_BAD_SPECIAL_PROPS: Check the usage of special props in a function component
- REACT_INEFFICIENT_PURE_COMPONENT_PROP: Suggest to use Hooks API if the pure component is used inside a function component
- REACT_MISMATCHED_TYPE_OF_ARG: Check the argument types of Hooks API
- REACT_MISMATCHED_TYPE_OF_PROP and REACT_USELESS_PROP_TYPES: Check the propType declarations of a function component
Enhanced Support for Various React Components
Previously, DeepScan supported class components better than other kinds of components regarding propTypes and inter-module analysis. Now, we provide a uniform support for the following component kinds:
- Components from
React.memo(),React.forwardRef()andcreateReactClass() - Components from React Redux
connect() - Components lazily loaded via
React.lazy() - Function components
Extended Language Support
We have added support for the latest TypeScript 3.5. You can analyze your TypeScript code leveraging the new syntaxes like const assertions.
- Support TypeScript
readonlytype modifier - Support TypeScript
as constassertion
Analysis Improvements
- Better ES Specification Compliance
- Report SYNTAX_ERROR for duplicate
exportnames - Report SYNTAX_ERROR for duplicate function names at ES module
- Report SYNTAX_ERROR for duplicate parameter names of strict-mode function
- Report SYNTAX_ERROR for duplicate
- Support inter-module analysis of dynamically imported module
- Support the analysis of the async function return value that goes through
awaitasync function logAssets(artifacts, audits) { const allAssets = await prepareAssets(artifacts, audits); // ARRAY_CALLBACK_RETURN_MISSING alarm is detected since the type of 'allAssets' is now known as an array. allAssets.map(passAssets => { // no return statements. }); } async function prepareAssets(artifacts, audits) { const passNames = Object.keys(artifacts.traces); const assets = []; for (const passName of passNames) { // push items into assets. } return assets; }
Miscellaneous
- Better SYNTAX_ERROR message when
awaitis used inside non-async function (ES module only) - REACT_MISUSED_UPDATE_IN_SET_STATE is improved to trace non-trivial data-flow and detect more alarms
- Filter-out REACT_BAD_API_RETURN_VALUE alarms occurring at the false branches that are likely to be infeasible in practice
- In 404 page, a detailed message for the invalid invitation link is shown
Bug Fixes
- A false alarm for SYNTAX_ERROR occurs when TypeScript
thisparameter is used on getter or setter - A false alarm for SYNTAX_ERROR occurs when template literal is used at TypeScript type annotation
- A SYNTAX_ERROR is not reported when TypeScript type assertion is used at arrow function parameter
- A SYNTAX_ERROR is not reported when assign pattern is used at
for-inorfor-ofloop left-hand side