diff --git a/.eslintrc.js b/.eslintrc.js index 5b4dbd01..24bc9c33 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -16,11 +16,13 @@ module.exports = { plugins: ['babel', 'flowtype', 'import', 'prettier'], parser: 'babel-eslint', rules: { + 'consistent-return': 'error', 'import/no-extraneous-dependencies': 'error', 'lint/extra-arrow-initializer': 'off', 'max-len': 'off', - 'no-alert': 'off', - 'no-console-disallow': 'off', + 'no-alert': 'error', + 'no-console': 'error', + 'no-unused-vars': 'error', 'no-var': 'off', 'prefer-arrow-callback': 'off', 'prefer-const': ['warn', {destructuring: 'all'}], diff --git a/packages/metro-memory-fs/src/__tests__/index-test.js b/packages/metro-memory-fs/src/__tests__/index-test.js index 6ab9153d..0d357108 100644 --- a/packages/metro-memory-fs/src/__tests__/index-test.js +++ b/packages/metro-memory-fs/src/__tests__/index-test.js @@ -38,11 +38,13 @@ it('works without binding functions', () => { it('can write then read a file (async)', done => { fs.writeFile('/foo.txt', 'test', wrError => { if (wrError) { - return done(wrError); + done(wrError); + return; } fs.readFile('/foo.txt', 'utf8', (rdError, str) => { if (rdError) { - return done(rdError); + done(rdError); + return; } expect(str).toEqual('test'); done(); @@ -57,8 +59,9 @@ it('can write then read a file as buffer', () => { it('can write a file with a stream', done => { const st = fs.createWriteStream('/foo.txt'); - let opened = false, - closed = false; + let opened = false; + let closed = false; + st.on('open', () => (opened = true)); st.on('close', () => (closed = true)); st.write('test'); @@ -73,8 +76,9 @@ it('can write a file with a stream', done => { it('can write a file with a stream, as buffer', done => { const st = fs.createWriteStream('/foo.txt'); - let opened = false, - closed = false; + let opened = false; + let closed = false; + st.on('open', () => (opened = true)); st.on('close', () => (closed = true)); st.write(Buffer.from('test')); @@ -90,8 +94,9 @@ it('can write a file with a stream, as buffer', done => { it('can write a file with a stream, with a starting position', done => { fs.writeFileSync('/foo.txt', 'test bar'); const st = fs.createWriteStream('/foo.txt', {start: 5, flags: 'r+'}); - let opened = false, - closed = false; + let opened = false; + let closed = false; + st.on('open', () => (opened = true)); st.on('close', () => (closed = true)); st.write('beep'); @@ -217,7 +222,8 @@ it('throws when trying to read a directory entry', () => { it('throws when trying to read inexistent file (async)', done => { fs.readFile('/foo.txt', error => { if (error.code !== 'ENOENT') { - return done(error); + done(error); + return; } expect(error.message).toMatchSnapshot(); done(); diff --git a/scripts/watch.js b/scripts/watch.js index bd952b6b..ad81125d 100644 --- a/scripts/watch.js +++ b/scripts/watch.js @@ -39,6 +39,7 @@ getPackages().forEach(p => { const filePath = path.resolve(srcDir, filename); if ((event === 'change' || event === 'rename') && exists(filePath)) { + // eslint-disable-next-line no-console console.log(chalk.green('->'), `${event}: ${filename}`); rebuild(filePath); } else { @@ -69,4 +70,5 @@ setInterval(() => { } }, 100); +// eslint-disable-next-line no-console console.log(chalk.red('->'), chalk.cyan('Watching for changes...'));