Skip to content

Commit

Permalink
feat: Add import checks
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan Krems committed Aug 25, 2017
1 parent 5c3d500 commit f849bdc
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 2 deletions.
5 changes: 5 additions & 0 deletions examples/eslint/node6/invalid-import.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
'use strict';

require('./does-not-exist.js');

require(process.argv[2]);
3 changes: 3 additions & 0 deletions examples/eslint/node6/invalid-import.js.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"errorCount": 1
}
36 changes: 34 additions & 2 deletions node6.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ module.exports = {
sourceType: 'script',
},
plugins: [
'import',
'node',
'prettier',
],
Expand All @@ -20,11 +21,12 @@ module.exports = {
trailingComma: 'es5',
}],
'lines-around-directive': ['error', 'always'],
'import/newline-after-import': 'error',

// Code convention
'no-underscore-dangle': [2, { allowAfterThis: true }],
// TODO: Make sure it will be auto-fixed
'no-undef-init': 'error',
'no-undef-init': 'off', // pending: Can't be auto-fixed
'import/no-dynamic-require': 'off', // pending: Can't be auto-fixed

// Bug prevention
strict: [2, 'global'],
Expand All @@ -43,5 +45,35 @@ module.exports = {
'no-label-var': 'error',
'no-delete-var': 'error',
'no-catch-shadow': 'off',

'import/no-unresolved': ['error', { commonjs: true, caseSensitive: true }],
'import/no-extraneous-dependencies': ['error', {
devDependencies: [
'test/**', // tape, common npm pattern
'tests/**', // also common npm pattern
'spec/**', // mocha, rspec-like pattern
'**/__tests__/**', // jest pattern
'test.{js,jsx}', // repos with a single test file
'test-*.{js,jsx}', // repos with multiple top-level test files
'**/*.{test,spec}.{js,jsx}', // tests where the extension denotes that it is a test
'**/jest.config.js', // jest config
'**/webpack.config.js', // webpack config
'**/webpack.config.*.js', // webpack config
'**/rollup.config.js', // rollup config
'**/rollup.config.*.js', // rollup config
'**/gulpfile.js', // gulp config
'**/gulpfile.*.js', // gulp config
'**/Gruntfile{,.js}', // grunt config
'**/protractor.conf.*.js', // protractor config

// Allow script & example files
'scripts/**',
'tasks/**',
'examples/**',
'example/**',
],
optionalDependencies: true, // allow optional deps to be required
}],
'import/no-duplicates': 'error',
}
};
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
"name": "Jan Krems",
"email": "jan.krems@groupon.com"
},
"files": [
"*.js",
"lib"
],
"dependencies": {
"coffeelint-forbidden-keywords": "~0.1.1",
"coffeelint-no-mocha-only": "^1.0.0",
Expand Down

0 comments on commit f849bdc

Please sign in to comment.