The big question:
Like most systems there is an:
# Ignore built files except build/index.js
build/*
!build/index.js
Globbing is a way to write a string that represent s a search pattern in files to be processed. e.g. it give instructions as to which files to affect and which to ignore
All files in CWD
Files of a type in CWD
Recursively search down
Not these files
*.*
*.css
**/*.js
!*.min.js
What you can configure:
Full Guide: https://eslint.org/docs/user-guide/configuring
"eslintConfig": {
"parser": "babel-eslint",
"extends": "airbnb",
"plugins": [
"react",
"jsx-a11y",
"import"
],
"env": {
"browser": true,
"node": true,
"jest": true,
"es6": true
},
"rules": {
"global-require": 0,
"no-underscore-dangle": 0,
"no-console": 0,
"react/jsx-filename-extension": [
1,
{
"extensions": [
".js",
".jsx"
]
}
],
"import/no-extraneous-dependencies": [
"error",
{
"devDependencies": true
}
]
},
"globals": {
"__CLIENT__": true,
"__SERVER__": true,
"__DISABLE_SSR__": true,
"__DEV__": true,
"webpackIsomorphicTools": true
}
},
"stylelint": {
"extends": "stylelint-config-standard",
"rules": {
"string-quotes": "single",
"selector-pseudo-class-no-unknown": [
true,
{
"ignorePseudoClasses": [
"global",
"local"
]
}
]
}
},
$ eslint --init
Guide: https://eslint.org/docs/rules/ (disabling)
/* global var1, var2 */
Top of file inline annotations (globals)
Enable & disable inline commands (All rules)
/* eslint-disable */
alert('not checked here');
/* eslint-enable */
Enable & disable inline commands (Some rules)
/* eslint-disable no-alert */
alert('not checked here');
/* eslint-enable no-alert */
Enable & disable inline commands (rules levels)
/* eslint eqeqeq: "off", curly: "off" */
if (a == b) return; // no errors
/* eslint quotes: ["error", "double"], curly: 2 */
function greet(name) {
return 'Hello ' + name;
}
What if greet is called and name not passed?
// Hello undefined
We need some way to see:
function greet(name:string) {
return 'Hello ' + name; // returns a String
}
const greeting1 = greet(); // Error
const greeting2 = greet(true); // Error
const greeting3 = greet('Fred'); // Works!
What if we could put comments (or 'annotations') that would show what we expected things to be!
We need to be able to annotate our code to show how we expect the flow of data to work
The big question:
Credit: Kent C. Dodds
import greet from './modules/greet';
describe('Greet function', () => {
it('responds with the correct greeting', (done) => {
expect(greet('James')).toBe('Hello James');
});
it('throws an error if no name is provided', (done) => {
expect(() => {
greet();
}).toThrow('No name provided');
});
});
https://facebook.github.io/jest/docs/en/using-matchers.html
module.exports = {
testPathIgnorePatterns: ['e2e-small-demo/cypress'],
};
beforeAll(() => {
connectDB();
});
beforeEach(() => {
initializeCityDatabase();
});
afterEach(() => {
clearCityDatabase();
});
afterAll(() => {
disconnectDB();
});