Skip to content

Commit

Permalink
Merge pull request #1260 from brionmario/fix-lint-errors
Browse files Browse the repository at this point in the history
Add environment specific ESLint Configs
  • Loading branch information
brionmario committed Oct 22, 2020
2 parents a38be25 + 7d3c797 commit a8d25b3
Show file tree
Hide file tree
Showing 9 changed files with 177 additions and 5 deletions.
26 changes: 25 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
/**
* Copyright (c) 2020, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/

// Base ESLint Config which can be extended to be used in the development environment.

module.exports = {
extends: [
"eslint:recommended",
Expand Down Expand Up @@ -108,7 +129,10 @@ module.exports = {
variables: false,
typedefs: false
}
]
],
// In development, error level is set to `warn`. This will be overridden
// by the production env linting config.
"no-debugger": 1
}
}
]
Expand Down
30 changes: 30 additions & 0 deletions .prod.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/**
* Copyright (c) 2020, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/

// Base ESLint Config which can be extended to be used in the production environment.

module.exports = {
extends: [
"./.eslintrc.js"
],
rules: {
// In production, build should fail if debug points are used.
"no-debugger": 2,
}
};
21 changes: 21 additions & 0 deletions apps/console/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
/**
* Copyright (c) 2020, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/

// ESLint Config which will be used by the IDE/Editors & webpack in development environments.

module.exports = {
extends: [
"../../.eslintrc.js"
Expand Down
28 changes: 28 additions & 0 deletions apps/console/.prod.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/**
* Copyright (c) 2020, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/

// ESLint Config which will be used by webpack in production environments.
// Override any of the rules that has to specifically apply to the app's production build
// which are not there in the base prod config.

module.exports = {
extends: [
"../../.prod.eslintrc.js"
]
};
Original file line number Diff line number Diff line change
Expand Up @@ -321,8 +321,6 @@ export const InboundSAMLForm: FunctionComponent<InboundSAMLFormPropsInterface> =
(
<Forms
onSubmit={ (values) => {
// eslint-disable-next-line no-debugger
debugger;
if (isEmpty(assertionConsumerUrls)) {
setAssertionConsumerUrlError(true);
scrollToInValidField("consumerURL");
Expand All @@ -331,8 +329,6 @@ export const InboundSAMLForm: FunctionComponent<InboundSAMLFormPropsInterface> =
}
} }
onSubmitError={ (requiredFields: Map<string, boolean>, validFields: Map<string, Validation>) => {
// eslint-disable-next-line no-debugger
debugger;
const iterator = requiredFields.entries();
let result = iterator.next();

Expand Down
12 changes: 12 additions & 0 deletions apps/console/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ const isSourceMapsEnabledInProduction = false;
// Enable/Disable profiling in Production.
const isProfilingEnabledInProduction = false;

// ESLint Config File Names
const DEVELOPMENT_ESLINT_CONFIG = ".eslintrc.js";
const PRODUCTION_ESLINT_CONFIG = ".prod.eslintrc.js";

module.exports = (env) => {

// Build Environments.
Expand All @@ -57,6 +61,13 @@ module.exports = (env) => {
const distFolder = path.resolve(__dirname, "build", basename);
const titleText = deploymentConfig.ui.appTitle;

// Paths to configs & other required files.
const PATHS = {
eslintrc: isProduction
? path.resolve(__dirname, PRODUCTION_ESLINT_CONFIG)
: path.resolve(__dirname, DEVELOPMENT_ESLINT_CONFIG)
};

return {
devServer: {
before: function (app) {
Expand Down Expand Up @@ -166,6 +177,7 @@ module.exports = (env) => {
{
loader: "eslint-loader",
options: {
configFile: PATHS.eslintrc,
happyPackMode: true,
transpileOnly: true
}
Expand Down
21 changes: 21 additions & 0 deletions apps/myaccount/.eslintrc.js
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
/**
* Copyright (c) 2020, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/

// ESLint Config which will be used by the IDE/Editors & webpack in development environments.

module.exports = {
extends: [
"../../.eslintrc.js"
Expand Down
28 changes: 28 additions & 0 deletions apps/myaccount/.prod.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/**
* Copyright (c) 2020, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/

// ESLint Config which will be used by webpack in production environments.
// Override any of the rules that has to specifically apply to the app's production build
// which are not there in the base prod config.

module.exports = {
extends: [
"../../.prod.eslintrc.js"
]
};
12 changes: 12 additions & 0 deletions apps/myaccount/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ const isSourceMapsEnabledInProduction = false;
// Enable/Disable profiling in Production.
const isProfilingEnabledInProduction = false;

// ESLint Config File Names
const DEVELOPMENT_ESLINT_CONFIG = ".eslintrc.js";
const PRODUCTION_ESLINT_CONFIG = ".prod.eslintrc.js";

module.exports = (env) => {

// Build Environments.
Expand All @@ -57,6 +61,13 @@ module.exports = (env) => {
const distFolder = path.resolve(__dirname, "build", basename);
const titleText = deploymentConfig.ui.appTitle;

// Paths to configs & other required files.
const PATHS = {
eslintrc: isProduction
? path.resolve(__dirname, PRODUCTION_ESLINT_CONFIG)
: path.resolve(__dirname, DEVELOPMENT_ESLINT_CONFIG)
};

return {
devServer: {
contentBase: distFolder,
Expand Down Expand Up @@ -160,6 +171,7 @@ module.exports = (env) => {
{
loader: "eslint-loader",
options: {
configFile: PATHS.eslintrc,
happyPackMode: true,
transpileOnly: true
}
Expand Down

0 comments on commit a8d25b3

Please sign in to comment.