Make eslint rules more strict

Reviewed By: cpojer

Differential Revision: D7123137

fbshipit-source-id: 68f82124ed565f223c6bf546c22e55ca401f1996
This commit is contained in:
Rafael Oleza 2018-03-01 05:38:58 -08:00 committed by Facebook Github Bot
parent cfb8516925
commit 59cfe85cca
3 changed files with 21 additions and 11 deletions

View File

@ -16,11 +16,13 @@ module.exports = {
plugins: ['babel', 'flowtype', 'import', 'prettier'], plugins: ['babel', 'flowtype', 'import', 'prettier'],
parser: 'babel-eslint', parser: 'babel-eslint',
rules: { rules: {
'consistent-return': 'error',
'import/no-extraneous-dependencies': 'error', 'import/no-extraneous-dependencies': 'error',
'lint/extra-arrow-initializer': 'off', 'lint/extra-arrow-initializer': 'off',
'max-len': 'off', 'max-len': 'off',
'no-alert': 'off', 'no-alert': 'error',
'no-console-disallow': 'off', 'no-console': 'error',
'no-unused-vars': 'error',
'no-var': 'off', 'no-var': 'off',
'prefer-arrow-callback': 'off', 'prefer-arrow-callback': 'off',
'prefer-const': ['warn', {destructuring: 'all'}], 'prefer-const': ['warn', {destructuring: 'all'}],

View File

@ -38,11 +38,13 @@ it('works without binding functions', () => {
it('can write then read a file (async)', done => { it('can write then read a file (async)', done => {
fs.writeFile('/foo.txt', 'test', wrError => { fs.writeFile('/foo.txt', 'test', wrError => {
if (wrError) { if (wrError) {
return done(wrError); done(wrError);
return;
} }
fs.readFile('/foo.txt', 'utf8', (rdError, str) => { fs.readFile('/foo.txt', 'utf8', (rdError, str) => {
if (rdError) { if (rdError) {
return done(rdError); done(rdError);
return;
} }
expect(str).toEqual('test'); expect(str).toEqual('test');
done(); done();
@ -57,8 +59,9 @@ it('can write then read a file as buffer', () => {
it('can write a file with a stream', done => { it('can write a file with a stream', done => {
const st = fs.createWriteStream('/foo.txt'); const st = fs.createWriteStream('/foo.txt');
let opened = false, let opened = false;
closed = false; let closed = false;
st.on('open', () => (opened = true)); st.on('open', () => (opened = true));
st.on('close', () => (closed = true)); st.on('close', () => (closed = true));
st.write('test'); 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 => { it('can write a file with a stream, as buffer', done => {
const st = fs.createWriteStream('/foo.txt'); const st = fs.createWriteStream('/foo.txt');
let opened = false, let opened = false;
closed = false; let closed = false;
st.on('open', () => (opened = true)); st.on('open', () => (opened = true));
st.on('close', () => (closed = true)); st.on('close', () => (closed = true));
st.write(Buffer.from('test')); 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 => { it('can write a file with a stream, with a starting position', done => {
fs.writeFileSync('/foo.txt', 'test bar'); fs.writeFileSync('/foo.txt', 'test bar');
const st = fs.createWriteStream('/foo.txt', {start: 5, flags: 'r+'}); const st = fs.createWriteStream('/foo.txt', {start: 5, flags: 'r+'});
let opened = false, let opened = false;
closed = false; let closed = false;
st.on('open', () => (opened = true)); st.on('open', () => (opened = true));
st.on('close', () => (closed = true)); st.on('close', () => (closed = true));
st.write('beep'); 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 => { it('throws when trying to read inexistent file (async)', done => {
fs.readFile('/foo.txt', error => { fs.readFile('/foo.txt', error => {
if (error.code !== 'ENOENT') { if (error.code !== 'ENOENT') {
return done(error); done(error);
return;
} }
expect(error.message).toMatchSnapshot(); expect(error.message).toMatchSnapshot();
done(); done();

View File

@ -39,6 +39,7 @@ getPackages().forEach(p => {
const filePath = path.resolve(srcDir, filename); const filePath = path.resolve(srcDir, filename);
if ((event === 'change' || event === 'rename') && exists(filePath)) { if ((event === 'change' || event === 'rename') && exists(filePath)) {
// eslint-disable-next-line no-console
console.log(chalk.green('->'), `${event}: ${filename}`); console.log(chalk.green('->'), `${event}: ${filename}`);
rebuild(filePath); rebuild(filePath);
} else { } else {
@ -69,4 +70,5 @@ setInterval(() => {
} }
}, 100); }, 100);
// eslint-disable-next-line no-console
console.log(chalk.red('->'), chalk.cyan('Watching for changes...')); console.log(chalk.red('->'), chalk.cyan('Watching for changes...'));