This repository has been archived by the owner on Aug 1, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b42432a
commit a4c09bf
Showing
23 changed files
with
26 additions
and
31 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,8 +11,8 @@ | |
* Currently only lints javascript files using ESlint (see https://eslint.org/). However, there are plans to | ||
* support different file types in the future. | ||
* | ||
* The configuration for ESlint can be found ../eslint/.eslintrc.js (relative to this file). It uses some default rules | ||
* (see documentation: https://eslint.org/docs/rules/) but also implements custom rules (see ../eslint/rules). | ||
* The configuration for ESlint can be found in ./eslint/.eslintrc.js (relative to this file). It uses some default | ||
* rules (see documentation: https://eslint.org/docs/rules/) but also implements custom rules (see ./eslint/rules). | ||
* | ||
* @author Brandon Li <[email protected]> | ||
*/ | ||
|
@@ -23,48 +23,44 @@ module.exports = ( () => { | |
// modules | ||
const eslint = require( 'eslint' ); | ||
const grunt = require( 'grunt' ); | ||
const md5 = require( 'md5' ); | ||
const path = require( 'path' ); | ||
const Util = require( './Util' ); | ||
|
||
class Linter { | ||
|
||
/** | ||
* Lints the entire root directory that invoked the command, using the ESlint configuration defined in | ||
* ../eslint/.eslintrc.js (relative to this file). Uses some custom rules (see ../eslint/rules). | ||
* ./eslint/.eslintrc.js (relative to this file). Uses some custom rules (see ./eslint/rules). | ||
* @public | ||
* | ||
* @param {boolean} useCache - indicates if the ESlint cache should be used. Caching doesn't re-lint files that | ||
* haven't changed. | ||
* @returns {Object} - ESlint report object | ||
*/ | ||
static eslint( useCache ) { | ||
Util.assert( typeof useCache === 'boolean', `invalid useCache: ${ useCache }` ); | ||
|
||
// Use the Node.js ESLint API. See https://eslint.org/docs/developer-guide/nodejs-api. | ||
const linter = new eslint.CLIEngine( { | ||
|
||
// Use the ESlint configuration defined in ../eslint/.eslintrc.js | ||
// Use the ESlint configuration defined in ./eslint/.eslintrc.js | ||
baseConfig: { | ||
extends: [ `${ Util.GRUNT_CONFIG_PATH }/eslint/.eslintrc.js` ] | ||
extends: [ `${ Util.GRUNT_CONFIG_PATH }/src/eslint/.eslintrc.js` ] | ||
}, | ||
|
||
// Current working directory - Lints the entire root directory that invoked the command | ||
cwd: Util.REPO_PATH, | ||
|
||
// Caching checks changed files or when the list of rules is changed. Changing the implementation of | ||
// a custom rule does not invalidate the cache. Caches are formated in .eslintcache files inside of | ||
// ../eslint/cache/**.eslintcache (relative to this file). | ||
// a custom rule does not invalidate the cache. | ||
cache: useCache, | ||
|
||
// Indicates where to store the target-specific cache file. Use md5 to hash the file name. This path is relative | ||
// to the root directory of which the command was invoked, so we use the Util.GRUNT_CONFIG_PATH to find the | ||
// correct path inside of grunt-config. | ||
cacheFile: `${ Util.GRUNT_CONFIG_PATH }/eslint/cache/${ md5( path.basename( Util.REPO_PATH ) ) }.eslintcache`, | ||
// Indicates where to store the target-specific cache file. This path is relative to the root directory of which | ||
// the command was invoked, so we use the Util.REPO_PATH to find the correct path inside of the repo. | ||
cacheFile: `${ Util.REPO_PATH }/.eslintcache`, | ||
|
||
// Indicates where the custom rules are. This path is relative to the root directory of which the command was | ||
// invoked, so we use the Util.GRUNT_CONFIG_PATH to find the correct rules path located inside of grunt-config | ||
rulePaths: [ `${ Util.GRUNT_CONFIG_PATH }/eslint/rules` ], | ||
// Indicates where the custom rules are. This path is relative to grunt-config, so we use | ||
// Util.GRUNT_CONFIG_PATH to find the correct rules path located inside of grunt-config | ||
rulePaths: [ `${ Util.GRUNT_CONFIG_PATH }/src/eslint/rules` ], | ||
|
||
// Files and directories to skip when linting. | ||
ignorePattern: Util.IGNORE_PATTERN | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
// Copyright © 2020 Brandon Li. All rights reserved. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
// Copyright © 2020 Brandon Li. All rights reserved. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
// Copyright © 2020 Brandon Li. All rights reserved. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
// Copyright © 2020 Brandon Li. All rights reserved. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
// Copyright © 2020 Brandon Li. All rights reserved. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
// Copyright © 2020 Brandon Li. All rights reserved. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
// Copyright © 2020 Brandon Li. All rights reserved. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
// Copyright © 2020 Brandon Li. All rights reserved. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
eslint/rules/require-statement-match.js → src/eslint/rules/require-statement-match.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
eslint/rules/sort-require-statements.js → src/eslint/rules/sort-require-statements.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters