You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// constants.jsexportconst{a: {// `b` would have been undefined, but we will default the value with a string
b ='default value',},}={a: {// `b` doesn't exist herec: 'test',},};
...
// foo.jsimport{b}from'./constants';// And it results inerrorbnotfoundin'./constants'import/named
It shouldn't throw an error because we have a default value for the key there.
The text was updated successfully, but these errors were encountered:
ardok
changed the title
False positives on export missing key object with default value
False positives on export (destructuring) missing key object with default value
Aug 18, 2017
Code and my app run just fine because it's valid destructuring (with export).
It's just lint complaining about that.
If that's confusing, maybe this is clearer.
// let's say this is an external package called ardo-styles
export default {
colors: {
white: '#ffffff',
black: '#000000',
},
padding: {
small: '8px',
large: '16px',
},
};
// ==== Now, this is my project called ArdoFoo ====
// <root>/constants/styles.js
import ArdoStyles from 'ardo-styles';
export const {
colors: {
white,
black,
// this doesn't exist from ardo-styles, but I just want to put it here.
// it's cleaner to put it here rather than having another `export const customBlack = '..'`
customBlack = '#000001',
}
} = ArdoStyles;
// <root>/components/modal.js
import {white, black, customBlack} from '<root>/constants/styles';
// It shouldn't complain about `customBlack` not being defined
It shouldn't throw an error because we have a default value for the key there.
The text was updated successfully, but these errors were encountered: